sys-filesystem 1.4.1 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGES.md +3 -0
- data/Gemfile +1 -7
- data/README.md +2 -0
- data/Rakefile +3 -3
- data/examples/example_mount.rb +3 -2
- data/lib/sys/filesystem.rb +1 -1
- data/lib/sys/unix/sys/filesystem.rb +33 -33
- data/lib/sys/unix/sys/filesystem/constants.rb +2 -4
- data/lib/sys/unix/sys/filesystem/functions.rb +13 -11
- data/lib/sys/unix/sys/filesystem/structs.rb +32 -14
- data/lib/sys/windows/sys/filesystem.rb +27 -28
- data/lib/sys/windows/sys/filesystem/functions.rb +10 -10
- data/lib/sys/windows/sys/filesystem/helper.rb +1 -1
- data/spec/sys_filesystem_unix_spec.rb +10 -7
- data/spec/sys_filesystem_windows_spec.rb +1 -1
- data/sys-filesystem.gemspec +3 -3
- metadata +9 -9
- metadata.gz.sig +3 -5
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: ef992a58a28ea604cbcce569c09abaee7212b04dbe7f7d0fd6b69d7ce4d62835
         | 
| 4 | 
            +
              data.tar.gz: f51965f0faec2fb982893f002c01d4499424d4838d7550cf44ff99c1ca859ea4
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 41001e2db9ba3048671910f0f4ebb264b781ef509d682353a02116434308386ad6c363a6409c311696729a28ea7fafa5edaf042f7f118485f0e31b0f5633c9e2
         | 
| 7 | 
            +
              data.tar.gz: 53e972089622fae12ad436e6634988d60fab6f271c391fc122d670c53cbc8d91312a4ba659d0e5f3e709bbaaf1969e4a9cb61ca2dd9b7e9152be478d0ae5347c
         | 
    
        checksums.yaml.gz.sig
    CHANGED
    
    | Binary file | 
    
        data.tar.gz.sig
    CHANGED
    
    | Binary file | 
    
        data/CHANGES.md
    CHANGED
    
    | @@ -1,3 +1,6 @@ | |
| 1 | 
            +
            ## 1.4.2 - 22-Jul-2021
         | 
| 2 | 
            +
            * Fixed support for 32-bit Linux. Thanks go to ciprianbadescu for the spot.
         | 
| 3 | 
            +
             | 
| 1 4 | 
             
            ## 1.4.1 - 30-Dec-2020
         | 
| 2 5 | 
             
            * Fix an FFI function declaration bug for Big Sur and later on Mac. Thanks go
         | 
| 3 6 | 
             
              to Roman Gaufman for the spot and Martins Polakovs for testing.
         | 
    
        data/Gemfile
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    
    
        data/Rakefile
    CHANGED
    
    | @@ -6,9 +6,9 @@ CLEAN.include('**/*.gem', '**/*.rbc', '**/*.rbx', '**/*.lock') | |
| 6 6 |  | 
| 7 7 | 
             
            namespace :gem do
         | 
| 8 8 | 
             
              desc "Build the sys-filesystem gem"
         | 
| 9 | 
            -
              task :create => [:clean] do | 
| 9 | 
            +
              task :create => [:clean] do
         | 
| 10 10 | 
             
                require 'rubygems/package'
         | 
| 11 | 
            -
                spec =  | 
| 11 | 
            +
                spec = Gem::Specification.load('sys-filesystem.gemspec')
         | 
| 12 12 | 
             
                spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
         | 
| 13 13 | 
             
                Gem::Package.build(spec)
         | 
| 14 14 | 
             
              end
         | 
| @@ -21,7 +21,7 @@ namespace :gem do | |
| 21 21 | 
             
            end
         | 
| 22 22 |  | 
| 23 23 | 
             
            desc "Run the example program"
         | 
| 24 | 
            -
            task :example do | 
| 24 | 
            +
            task :example do
         | 
| 25 25 | 
             
              sh "ruby -Ilib -Ilib/unix -Ilib/windows examples/example_stat.rb"
         | 
| 26 26 | 
             
            end
         | 
| 27 27 |  | 
    
        data/examples/example_mount.rb
    CHANGED
    
    | @@ -7,11 +7,12 @@ | |
| 7 7 | 
             
            require 'optparse'
         | 
| 8 8 |  | 
| 9 9 | 
             
            options = {:mount_options => []}
         | 
| 10 | 
            +
             | 
| 10 11 | 
             
            OptionParser.new do |opts|
         | 
| 11 12 | 
             
              opts.banner = "Usage: #$0 [-o options] [-t external_type] special node"
         | 
| 12 13 |  | 
| 13 | 
            -
              opts.on("-o=OPTIONS",       "Set one or many mount options (comma delimited)") do | | 
| 14 | 
            -
                options[:mount_options] +=  | 
| 14 | 
            +
              opts.on("-o=OPTIONS",       "Set one or many mount options (comma delimited)") do |cli_opts|
         | 
| 15 | 
            +
                options[:mount_options] += cli_opts.split(',')
         | 
| 15 16 | 
             
              end
         | 
| 16 17 |  | 
| 17 18 | 
             
              opts.on("-r",               "Set readonly flag") do
         | 
    
        data/lib/sys/filesystem.rb
    CHANGED
    
    
| @@ -11,44 +11,44 @@ module Sys | |
| 11 11 | 
             
                include Sys::Filesystem::Structs
         | 
| 12 12 | 
             
                extend Sys::Filesystem::Functions
         | 
| 13 13 |  | 
| 14 | 
            -
                private
         | 
| 15 | 
            -
             | 
| 16 14 | 
             
                # Readable versions of constant names
         | 
| 17 15 | 
             
                OPT_NAMES = {
         | 
| 18 | 
            -
                  MNT_RDONLY | 
| 19 | 
            -
                  MNT_SYNCHRONOUS | 
| 20 | 
            -
                  MNT_NOEXEC | 
| 21 | 
            -
                  MNT_NOSUID | 
| 22 | 
            -
                  MNT_NODEV | 
| 23 | 
            -
                  MNT_UNION | 
| 24 | 
            -
                  MNT_ASYNC | 
| 25 | 
            -
                  MNT_CPROTECT | 
| 26 | 
            -
                  MNT_EXPORTED | 
| 27 | 
            -
                  MNT_QUARANTINE | 
| 28 | 
            -
                  MNT_LOCAL | 
| 29 | 
            -
                  MNT_QUOTA | 
| 30 | 
            -
                  MNT_ROOTFS | 
| 31 | 
            -
                  MNT_DONTBROWSE | 
| 16 | 
            +
                  MNT_RDONLY => 'read-only',
         | 
| 17 | 
            +
                  MNT_SYNCHRONOUS => 'synchronous',
         | 
| 18 | 
            +
                  MNT_NOEXEC => 'noexec',
         | 
| 19 | 
            +
                  MNT_NOSUID => 'nosuid',
         | 
| 20 | 
            +
                  MNT_NODEV => 'nodev',
         | 
| 21 | 
            +
                  MNT_UNION => 'union',
         | 
| 22 | 
            +
                  MNT_ASYNC => 'asynchronous',
         | 
| 23 | 
            +
                  MNT_CPROTECT => 'content-protection',
         | 
| 24 | 
            +
                  MNT_EXPORTED => 'exported',
         | 
| 25 | 
            +
                  MNT_QUARANTINE => 'quarantined',
         | 
| 26 | 
            +
                  MNT_LOCAL => 'local',
         | 
| 27 | 
            +
                  MNT_QUOTA => 'quotas',
         | 
| 28 | 
            +
                  MNT_ROOTFS => 'rootfs',
         | 
| 29 | 
            +
                  MNT_DONTBROWSE => 'nobrowse',
         | 
| 32 30 | 
             
                  MNT_IGNORE_OWNERSHIP => 'noowners',
         | 
| 33 | 
            -
                  MNT_AUTOMOUNTED | 
| 34 | 
            -
                  MNT_JOURNALED | 
| 35 | 
            -
                  MNT_NOUSERXATTR | 
| 36 | 
            -
                  MNT_DEFWRITE | 
| 37 | 
            -
                  MNT_NOATIME | 
| 31 | 
            +
                  MNT_AUTOMOUNTED => 'automounted',
         | 
| 32 | 
            +
                  MNT_JOURNALED => 'journaled',
         | 
| 33 | 
            +
                  MNT_NOUSERXATTR => 'nouserxattr',
         | 
| 34 | 
            +
                  MNT_DEFWRITE => 'defwrite',
         | 
| 35 | 
            +
                  MNT_NOATIME => 'noatime'
         | 
| 38 36 | 
             
                }.freeze
         | 
| 39 37 |  | 
| 38 | 
            +
                private_constant :OPT_NAMES
         | 
| 39 | 
            +
             | 
| 40 40 | 
             
                # File used to read mount informtion from.
         | 
| 41 41 | 
             
                if File.exist?('/etc/mtab')
         | 
| 42 | 
            -
                  MOUNT_FILE = '/etc/mtab'
         | 
| 42 | 
            +
                  MOUNT_FILE = '/etc/mtab'.freeze
         | 
| 43 43 | 
             
                elsif File.exist?('/etc/mnttab')
         | 
| 44 | 
            -
                  MOUNT_FILE = '/etc/mnttab'
         | 
| 44 | 
            +
                  MOUNT_FILE = '/etc/mnttab'.freeze
         | 
| 45 45 | 
             
                elsif File.exist?('/proc/mounts')
         | 
| 46 | 
            -
                  MOUNT_FILE = '/proc/mounts'
         | 
| 46 | 
            +
                  MOUNT_FILE = '/proc/mounts'.freeze
         | 
| 47 47 | 
             
                else
         | 
| 48 | 
            -
                  MOUNT_FILE = 'getmntinfo'
         | 
| 48 | 
            +
                  MOUNT_FILE = 'getmntinfo'.freeze
         | 
| 49 49 | 
             
                end
         | 
| 50 50 |  | 
| 51 | 
            -
                 | 
| 51 | 
            +
                private_constant :MOUNT_FILE
         | 
| 52 52 |  | 
| 53 53 | 
             
                # The error raised if any of the Filesystem methods fail.
         | 
| 54 54 | 
             
                class Error < StandardError; end
         | 
| @@ -278,17 +278,17 @@ module Sys | |
| 278 278 |  | 
| 279 279 | 
             
                    ptr = buf.get_pointer(0)
         | 
| 280 280 |  | 
| 281 | 
            -
                    num.times | 
| 281 | 
            +
                    num.times do
         | 
| 282 282 | 
             
                      mnt = Statfs.new(ptr)
         | 
| 283 283 | 
             
                      obj = Sys::Filesystem::Mount.new
         | 
| 284 284 | 
             
                      obj.name = mnt[:f_mntfromname].to_s
         | 
| 285 285 | 
             
                      obj.mount_point = mnt[:f_mntonname].to_s
         | 
| 286 286 | 
             
                      obj.mount_type = mnt[:f_fstypename].to_s
         | 
| 287 287 |  | 
| 288 | 
            -
                      string =  | 
| 288 | 
            +
                      string = ''
         | 
| 289 289 | 
             
                      flags = mnt[:f_flags] & MNT_VISFLAGMASK
         | 
| 290 290 |  | 
| 291 | 
            -
                      OPT_NAMES.each | 
| 291 | 
            +
                      OPT_NAMES.each do |key, val|
         | 
| 292 292 | 
             
                        if flags & key > 0
         | 
| 293 293 | 
             
                          if string.empty?
         | 
| 294 294 | 
             
                            string << val
         | 
| @@ -297,7 +297,7 @@ module Sys | |
| 297 297 | 
             
                          end
         | 
| 298 298 | 
             
                        end
         | 
| 299 299 | 
             
                        flags &= ~key
         | 
| 300 | 
            -
                       | 
| 300 | 
            +
                      end
         | 
| 301 301 |  | 
| 302 302 | 
             
                      obj.options = string
         | 
| 303 303 |  | 
| @@ -308,7 +308,7 @@ module Sys | |
| 308 308 | 
             
                      end
         | 
| 309 309 |  | 
| 310 310 | 
             
                      ptr += Statfs.size
         | 
| 311 | 
            -
                     | 
| 311 | 
            +
                    end
         | 
| 312 312 | 
             
                  else
         | 
| 313 313 | 
             
                    begin
         | 
| 314 314 | 
             
                      if respond_to?(:setmntent, true)
         | 
| @@ -385,7 +385,7 @@ module Sys | |
| 385 385 | 
             
                  dev = File.stat(file).dev
         | 
| 386 386 | 
             
                  val = file
         | 
| 387 387 |  | 
| 388 | 
            -
                   | 
| 388 | 
            +
                  mounts.each do |mnt|
         | 
| 389 389 | 
             
                    mp = mnt.mount_point
         | 
| 390 390 | 
             
                    begin
         | 
| 391 391 | 
             
                      if File.stat(mp).dev == dev
         | 
| @@ -395,7 +395,7 @@ module Sys | |
| 395 395 | 
             
                    rescue Errno::EACCES
         | 
| 396 396 | 
             
                      next
         | 
| 397 397 | 
             
                    end
         | 
| 398 | 
            -
                   | 
| 398 | 
            +
                  end
         | 
| 399 399 |  | 
| 400 400 | 
             
                  val
         | 
| 401 401 | 
             
                end
         | 
| @@ -1,8 +1,6 @@ | |
| 1 1 | 
             
            module Sys
         | 
| 2 2 | 
             
              class Filesystem
         | 
| 3 3 | 
             
                module Constants
         | 
| 4 | 
            -
                  private
         | 
| 5 | 
            -
             | 
| 6 4 | 
             
                  MNT_RDONLY      = 0x00000001 # read only filesystem
         | 
| 7 5 | 
             
                  MNT_SYNCHRONOUS = 0x00000002 # file system written synchronously
         | 
| 8 6 | 
             
                  MNT_NOEXEC      = 0x00000004 # can't exec from filesystem
         | 
| @@ -33,7 +31,7 @@ module Sys | |
| 33 31 | 
             
                    MNT_LOCAL  | MNT_QUOTA |
         | 
| 34 32 | 
             
                    MNT_ROOTFS | MNT_DOVOLFS | MNT_DONTBROWSE |
         | 
| 35 33 | 
             
                    MNT_IGNORE_OWNERSHIP | MNT_AUTOMOUNTED | MNT_JOURNALED |
         | 
| 36 | 
            -
                    MNT_NOUSERXATTR | MNT_DEFWRITE | 
| 34 | 
            +
                    MNT_NOUSERXATTR | MNT_DEFWRITE | MNT_MULTILABEL |
         | 
| 37 35 | 
             
                    MNT_NOATIME | MNT_CPROTECT
         | 
| 38 36 | 
             
                  )
         | 
| 39 37 |  | 
| @@ -58,7 +56,7 @@ module Sys | |
| 58 56 | 
             
                  MS_SHARED = 1 << 20
         | 
| 59 57 | 
             
                  MS_RELATIME = 1 << 21
         | 
| 60 58 | 
             
                  MS_KERNMOUNT = 1 << 22
         | 
| 61 | 
            -
                  MS_I_VERSION = | 
| 59 | 
            +
                  MS_I_VERSION = 1 << 23
         | 
| 62 60 | 
             
                  MS_STRICTATIME = 1 << 24
         | 
| 63 61 | 
             
                  MS_ACTIVE = 1 << 30
         | 
| 64 62 | 
             
                  MS_NOUSER = 1 << 31
         | 
| @@ -7,14 +7,16 @@ module Sys | |
| 7 7 |  | 
| 8 8 | 
             
                  ffi_lib FFI::Library::LIBC
         | 
| 9 9 |  | 
| 10 | 
            -
                  if RbConfig::CONFIG['host_os'] =~ /sunos|solaris | 
| 11 | 
            -
                    attach_function(:statvfs, :statvfs64, [ | 
| 10 | 
            +
                  if RbConfig::CONFIG['host_os'] =~ /sunos|solaris/i
         | 
| 11 | 
            +
                    attach_function(:statvfs, :statvfs64, %i[string pointer], :int)
         | 
| 12 | 
            +
                  elsif RbConfig::CONFIG['host_os'] =~ /linux/i && RbConfig::CONFIG['arch'] =~ /64/
         | 
| 13 | 
            +
                    attach_function(:statvfs, :statvfs64, %i[string pointer], :int)
         | 
| 12 14 | 
             
                  else
         | 
| 13 | 
            -
                    attach_function(:statvfs, [ | 
| 15 | 
            +
                    attach_function(:statvfs, %i[string pointer], :int)
         | 
| 14 16 | 
             
                  end
         | 
| 15 17 |  | 
| 16 18 | 
             
                  attach_function(:strerror, [:int], :string)
         | 
| 17 | 
            -
                  attach_function(:mount_c, :mount, [ | 
| 19 | 
            +
                  attach_function(:mount_c, :mount, %i[string string string ulong string], :int)
         | 
| 18 20 |  | 
| 19 21 | 
             
                  begin
         | 
| 20 22 | 
             
                    attach_function(:umount_c, :umount, [:string], :int)
         | 
| @@ -28,26 +30,26 @@ module Sys | |
| 28 30 |  | 
| 29 31 | 
             
                  begin
         | 
| 30 32 | 
             
                    if RbConfig::CONFIG['host_os'] =~ /sunos|solaris/i
         | 
| 31 | 
            -
                      attach_function(:fopen, [ | 
| 33 | 
            +
                      attach_function(:fopen, %i[string string], :pointer)
         | 
| 32 34 | 
             
                      attach_function(:fclose, [:pointer], :int)
         | 
| 33 | 
            -
                      attach_function(:getmntent, [ | 
| 35 | 
            +
                      attach_function(:getmntent, %i[pointer pointer], :int)
         | 
| 34 36 | 
             
                      private_class_method :fopen, :fclose, :getmntent
         | 
| 35 37 | 
             
                    else
         | 
| 36 38 | 
             
                      attach_function(:getmntent, [:pointer], :pointer)
         | 
| 37 | 
            -
                      attach_function(:setmntent, [ | 
| 39 | 
            +
                      attach_function(:setmntent, %i[string string], :pointer)
         | 
| 38 40 | 
             
                      attach_function(:endmntent, [:pointer], :int)
         | 
| 39 | 
            -
                      attach_function(:umount2, [ | 
| 41 | 
            +
                      attach_function(:umount2, %i[string int], :int)
         | 
| 40 42 | 
             
                      private_class_method :getmntent, :setmntent, :endmntent, :umount2
         | 
| 41 43 | 
             
                    end
         | 
| 42 44 | 
             
                  rescue FFI::NotFoundError
         | 
| 43 45 | 
             
                    if RbConfig::CONFIG['host_os'] =~ /darwin|osx|mach/i
         | 
| 44 46 | 
             
                      begin
         | 
| 45 | 
            -
                        attach_function(:getmntinfo, :getmntinfo64, [ | 
| 47 | 
            +
                        attach_function(:getmntinfo, :getmntinfo64, %i[pointer int], :int)
         | 
| 46 48 | 
             
                      rescue FFI::NotFoundError
         | 
| 47 | 
            -
                        attach_function(:getmntinfo, [ | 
| 49 | 
            +
                        attach_function(:getmntinfo, %i[pointer int], :int) # Big Sur and later
         | 
| 48 50 | 
             
                      end
         | 
| 49 51 | 
             
                    else
         | 
| 50 | 
            -
                      attach_function(:getmntinfo, [ | 
| 52 | 
            +
                      attach_function(:getmntinfo, %i[pointer int], :int)
         | 
| 51 53 | 
             
                    end
         | 
| 52 54 | 
             
                    private_class_method :getmntinfo
         | 
| 53 55 | 
             
                  end
         | 
| @@ -40,20 +40,37 @@ module Sys | |
| 40 40 | 
             
                        :f_mntonname, [:char, MNAMELEN]
         | 
| 41 41 | 
             
                      )
         | 
| 42 42 | 
             
                    elsif RbConfig::CONFIG['host_os'] =~ /linux/i
         | 
| 43 | 
            -
                       | 
| 44 | 
            -
                         | 
| 45 | 
            -
             | 
| 46 | 
            -
             | 
| 47 | 
            -
             | 
| 48 | 
            -
             | 
| 49 | 
            -
             | 
| 50 | 
            -
             | 
| 51 | 
            -
             | 
| 52 | 
            -
             | 
| 53 | 
            -
             | 
| 54 | 
            -
             | 
| 55 | 
            -
             | 
| 56 | 
            -
             | 
| 43 | 
            +
                      if RbConfig::CONFIG['arch'] =~ /64/
         | 
| 44 | 
            +
                        layout(
         | 
| 45 | 
            +
                          :f_type, :ulong,
         | 
| 46 | 
            +
                          :f_bsize, :ulong,
         | 
| 47 | 
            +
                          :f_blocks, :uint64,
         | 
| 48 | 
            +
                          :f_bfree, :uint64,
         | 
| 49 | 
            +
                          :f_bavail, :uint64,
         | 
| 50 | 
            +
                          :f_files, :uint64,
         | 
| 51 | 
            +
                          :f_ffree, :uint64,
         | 
| 52 | 
            +
                          :f_fsid, [:int, 2],
         | 
| 53 | 
            +
                          :f_namelen, :ulong,
         | 
| 54 | 
            +
                          :f_frsize, :ulong,
         | 
| 55 | 
            +
                          :f_flags, :ulong,
         | 
| 56 | 
            +
                          :f_spare, [:ulong, 4]
         | 
| 57 | 
            +
                        )
         | 
| 58 | 
            +
                      else
         | 
| 59 | 
            +
                        layout(
         | 
| 60 | 
            +
                          :f_type, :ulong,
         | 
| 61 | 
            +
                          :f_bsize, :ulong,
         | 
| 62 | 
            +
                          :f_blocks, :uint32,
         | 
| 63 | 
            +
                          :f_bfree, :uint32,
         | 
| 64 | 
            +
                          :f_bavail, :uint32,
         | 
| 65 | 
            +
                          :f_files, :uint32,
         | 
| 66 | 
            +
                          :f_ffree, :uint32,
         | 
| 67 | 
            +
                          :f_fsid, [:int, 2],
         | 
| 68 | 
            +
                          :f_namelen, :ulong,
         | 
| 69 | 
            +
                          :f_frsize, :ulong,
         | 
| 70 | 
            +
                          :f_flags, :ulong,
         | 
| 71 | 
            +
                          :f_spare, [:ulong, 4]
         | 
| 72 | 
            +
                        )
         | 
| 73 | 
            +
                      end
         | 
| 57 74 | 
             
                    else
         | 
| 58 75 | 
             
                      layout(
         | 
| 59 76 | 
             
                        :f_bsize, :uint32,
         | 
| @@ -134,6 +151,7 @@ module Sys | |
| 134 151 | 
             
                        :f_ffree, :uint,
         | 
| 135 152 | 
             
                        :f_favail, :uint,
         | 
| 136 153 | 
             
                        :f_fsid, :ulong,
         | 
| 154 | 
            +
                        :f_unused, :int,
         | 
| 137 155 | 
             
                        :f_flag, :ulong,
         | 
| 138 156 | 
             
                        :f_namemax, :ulong,
         | 
| 139 157 | 
             
                        :f_spare, [:int, 6]
         | 
| @@ -181,7 +181,7 @@ module Sys | |
| 181 181 |  | 
| 182 182 | 
             
                  boot_time = get_boot_time
         | 
| 183 183 |  | 
| 184 | 
            -
                  drives.each | 
| 184 | 
            +
                  drives.each do |drive|
         | 
| 185 185 | 
             
                    mount  = Mount.new
         | 
| 186 186 | 
             
                    volume = FFI::MemoryPointer.new(:char, MAXPATH)
         | 
| 187 187 | 
             
                    fsname = FFI::MemoryPointer.new(:char, MAXPATH)
         | 
| @@ -206,7 +206,7 @@ module Sys | |
| 206 206 |  | 
| 207 207 | 
             
                    # Skip unmounted floppies or cd-roms, or inaccessible drives
         | 
| 208 208 | 
             
                    unless bool
         | 
| 209 | 
            -
                      if [5,21].include?(FFI.errno) # ERROR_NOT_READY or ERROR_ACCESS_DENIED
         | 
| 209 | 
            +
                      if [5, 21].include?(FFI.errno) # ERROR_NOT_READY or ERROR_ACCESS_DENIED
         | 
| 210 210 | 
             
                        next
         | 
| 211 211 | 
             
                      else
         | 
| 212 212 | 
             
                        raise SystemCallError.new('GetVolumeInformation', FFI.errno)
         | 
| @@ -218,7 +218,7 @@ module Sys | |
| 218 218 |  | 
| 219 219 | 
             
                    name = 0.chr * MAXPATH
         | 
| 220 220 |  | 
| 221 | 
            -
                    if QueryDosDeviceA(drive[0,2], name, name.size) == 0
         | 
| 221 | 
            +
                    if QueryDosDeviceA(drive[0, 2], name, name.size) == 0
         | 
| 222 222 | 
             
                      raise SystemCallError.new('QueryDosDevice', FFI.errno)
         | 
| 223 223 | 
             
                    end
         | 
| 224 224 |  | 
| @@ -231,7 +231,7 @@ module Sys | |
| 231 231 | 
             
                    else
         | 
| 232 232 | 
             
                      mounts << mount
         | 
| 233 233 | 
             
                    end
         | 
| 234 | 
            -
                   | 
| 234 | 
            +
                  end
         | 
| 235 235 |  | 
| 236 236 | 
             
                  mounts # Nil if the block form was used.
         | 
| 237 237 | 
             
                end
         | 
| @@ -397,8 +397,6 @@ module Sys | |
| 397 397 | 
             
                  self
         | 
| 398 398 | 
             
                end
         | 
| 399 399 |  | 
| 400 | 
            -
                private
         | 
| 401 | 
            -
             | 
| 402 400 | 
             
                # This method is used to get the boot time of the system, which is used
         | 
| 403 401 | 
             
                # for the mount_time attribute within the File.mounts method.
         | 
| 404 402 | 
             
                #
         | 
| @@ -411,36 +409,37 @@ module Sys | |
| 411 409 | 
             
                    raise Error, e
         | 
| 412 410 | 
             
                  else
         | 
| 413 411 | 
             
                    query = 'select LastBootupTime from Win32_OperatingSystem'
         | 
| 414 | 
            -
                     | 
| 415 | 
            -
                     | 
| 416 | 
            -
             | 
| 417 | 
            -
                      return Time.mktime(*time_array)
         | 
| 418 | 
            -
                    }
         | 
| 412 | 
            +
                    ole = wmi.ExecQuery(query).ItemIndex(0)
         | 
| 413 | 
            +
                    time_array = Time.parse(ole.LastBootupTime.split('.').first)
         | 
| 414 | 
            +
                    Time.mktime(*time_array)
         | 
| 419 415 | 
             
                  end
         | 
| 420 416 | 
             
                end
         | 
| 421 417 |  | 
| 418 | 
            +
                private_class_method :get_boot_time
         | 
| 419 | 
            +
             | 
| 422 420 | 
             
                # Private method that converts filesystem flags into a comma separated
         | 
| 423 421 | 
             
                # list of strings. The presentation is meant as a rough analogue to the
         | 
| 424 422 | 
             
                # way options are presented for Unix filesystems.
         | 
| 425 423 | 
             
                #
         | 
| 426 424 | 
             
                def self.get_options(flags)
         | 
| 427 | 
            -
             | 
| 428 | 
            -
             | 
| 429 | 
            -
             | 
| 430 | 
            -
             | 
| 431 | 
            -
             | 
| 432 | 
            -
             | 
| 433 | 
            -
             | 
| 434 | 
            -
             | 
| 435 | 
            -
             | 
| 436 | 
            -
             | 
| 437 | 
            -
             | 
| 438 | 
            -
             | 
| 439 | 
            -
             | 
| 440 | 
            -
             | 
| 441 | 
            -
             | 
| 442 | 
            -
             | 
| 443 | 
            -
                   str
         | 
| 425 | 
            +
                  str = ''
         | 
| 426 | 
            +
                  str << ' casepres' if CASE_PRESERVED_NAMES & flags > 0
         | 
| 427 | 
            +
                  str << ' casesens' if CASE_SENSITIVE_SEARCH & flags > 0
         | 
| 428 | 
            +
                  str << ' compression' if FILE_COMPRESSION & flags > 0
         | 
| 429 | 
            +
                  str << ' namedstreams' if NAMED_STREAMS & flags > 0
         | 
| 430 | 
            +
                  str << ' pacls' if PERSISTENT_ACLS & flags > 0
         | 
| 431 | 
            +
                  str << ' ro' if READ_ONLY_VOLUME & flags > 0
         | 
| 432 | 
            +
                  str << ' encryption' if SUPPORTS_ENCRYPTION & flags > 0
         | 
| 433 | 
            +
                  str << ' objids' if SUPPORTS_OBJECT_IDS & flags > 0
         | 
| 434 | 
            +
                  str << ' rpoints' if SUPPORTS_REPARSE_POINTS & flags > 0
         | 
| 435 | 
            +
                  str << ' sparse' if SUPPORTS_SPARSE_FILES & flags > 0
         | 
| 436 | 
            +
                  str << ' unicode' if UNICODE_ON_DISK & flags > 0
         | 
| 437 | 
            +
                  str << ' compressed' if VOLUME_IS_COMPRESSED & flags > 0
         | 
| 438 | 
            +
             | 
| 439 | 
            +
                  str.tr!(' ', ',')
         | 
| 440 | 
            +
                  str[1..-1] # Ignore the first comma
         | 
| 444 441 | 
             
                end
         | 
| 442 | 
            +
             | 
| 443 | 
            +
                private_class_method :get_options
         | 
| 445 444 | 
             
              end
         | 
| 446 445 | 
             
            end
         | 
| @@ -15,21 +15,21 @@ module Sys | |
| 15 15 | 
             
                  end
         | 
| 16 16 |  | 
| 17 17 | 
             
                  attach_pfunc :DeleteVolumeMountPointA, [:string], :bool
         | 
| 18 | 
            -
                  attach_pfunc :GetDiskFreeSpaceW, [ | 
| 19 | 
            -
                  attach_pfunc :GetDiskFreeSpaceExW, [ | 
| 20 | 
            -
                  attach_pfunc :GetLogicalDriveStringsA, [ | 
| 18 | 
            +
                  attach_pfunc :GetDiskFreeSpaceW, %i[buffer_in pointer pointer pointer pointer], :bool
         | 
| 19 | 
            +
                  attach_pfunc :GetDiskFreeSpaceExW, %i[buffer_in pointer pointer pointer], :bool
         | 
| 20 | 
            +
                  attach_pfunc :GetLogicalDriveStringsA, %i[ulong pointer], :ulong
         | 
| 21 21 |  | 
| 22 22 | 
             
                  attach_pfunc :GetVolumeInformationA,
         | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 23 | 
            +
                               %i[buffer_in pointer ulong pointer pointer pointer pointer ulong],
         | 
| 24 | 
            +
                               :bool
         | 
| 25 25 |  | 
| 26 26 | 
             
                  attach_pfunc :GetVolumeInformationW,
         | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 27 | 
            +
                               %i[buffer_in pointer ulong pointer pointer pointer pointer ulong],
         | 
| 28 | 
            +
                               :bool
         | 
| 29 29 |  | 
| 30 | 
            -
                  attach_pfunc :GetVolumeNameForVolumeMountPointW, [ | 
| 31 | 
            -
                  attach_pfunc :QueryDosDeviceA, [ | 
| 32 | 
            -
                  attach_pfunc :SetVolumeMountPointW, [ | 
| 30 | 
            +
                  attach_pfunc :GetVolumeNameForVolumeMountPointW, %i[buffer_in buffer_in ulong], :bool
         | 
| 31 | 
            +
                  attach_pfunc :QueryDosDeviceA, %i[buffer_in buffer_out ulong], :ulong
         | 
| 32 | 
            +
                  attach_pfunc :SetVolumeMountPointW, %i[buffer_in buffer_in], :bool
         | 
| 33 33 |  | 
| 34 34 | 
             
                  ffi_lib :shlwapi
         | 
| 35 35 |  | 
| @@ -2,6 +2,6 @@ class String | |
| 2 2 | 
             
              # Convenience method for converting strings to UTF-16LE for wide character
         | 
| 3 3 | 
             
              # functions that require it.
         | 
| 4 4 | 
             
              def wincode
         | 
| 5 | 
            -
                ( | 
| 5 | 
            +
                (tr(File::SEPARATOR, File::ALT_SEPARATOR) + 0.chr).encode('UTF-16LE')
         | 
| 6 6 | 
             
              end
         | 
| 7 7 | 
             
            end
         | 
| @@ -21,7 +21,7 @@ RSpec.describe Sys::Filesystem, :unix => true do | |
| 21 21 | 
             
              end
         | 
| 22 22 |  | 
| 23 23 | 
             
              example "version number is set to the expected value" do
         | 
| 24 | 
            -
                expect(Sys::Filesystem::VERSION).to eq('1.4. | 
| 24 | 
            +
                expect(Sys::Filesystem::VERSION).to eq('1.4.2')
         | 
| 25 25 | 
             
                expect(Sys::Filesystem::VERSION).to be_frozen
         | 
| 26 26 | 
             
              end
         | 
| 27 27 |  | 
| @@ -359,8 +359,11 @@ RSpec.describe Sys::Filesystem, :unix => true do | |
| 359 359 | 
             
              end
         | 
| 360 360 |  | 
| 361 361 | 
             
              context "FFI" do
         | 
| 362 | 
            -
                 | 
| 363 | 
            -
             | 
| 362 | 
            +
                before(:context) do
         | 
| 363 | 
            +
                  require 'mkmf-lite'
         | 
| 364 | 
            +
                end
         | 
| 365 | 
            +
             | 
| 366 | 
            +
                let(:dummy) { Class.new { extend Mkmf::Lite } }
         | 
| 364 367 |  | 
| 365 368 | 
             
                example "ffi functions are private" do
         | 
| 366 369 | 
             
                  expect(Sys::Filesystem.methods.include?('statvfs')).to be false
         | 
| @@ -369,21 +372,21 @@ RSpec.describe Sys::Filesystem, :unix => true do | |
| 369 372 |  | 
| 370 373 | 
             
                example "statfs struct is expected size" do
         | 
| 371 374 | 
             
                  header = bsd || darwin ? 'sys/mount.h' : 'sys/statfs.h'
         | 
| 372 | 
            -
                  expect(Sys::Filesystem::Structs::Statfs.size).to eq(check_sizeof('struct statfs', header))
         | 
| 375 | 
            +
                  expect(Sys::Filesystem::Structs::Statfs.size).to eq(dummy.check_sizeof('struct statfs', header))
         | 
| 373 376 | 
             
                end
         | 
| 374 377 |  | 
| 375 378 | 
             
                example "statvfs struct is expected size" do
         | 
| 376 | 
            -
                  expect(Sys::Filesystem::Structs::Statvfs.size).to eq(check_sizeof('struct statvfs', 'sys/statvfs.h'))
         | 
| 379 | 
            +
                  expect(Sys::Filesystem::Structs::Statvfs.size).to eq(dummy.check_sizeof('struct statvfs', 'sys/statvfs.h'))
         | 
| 377 380 | 
             
                end
         | 
| 378 381 |  | 
| 379 382 | 
             
                example "mnttab struct is expected size" do
         | 
| 380 383 | 
             
                  skip "mnttab test skipped except on Solaris" unless solaris
         | 
| 381 | 
            -
                  expect(Sys::Filesystem::Structs::Mnttab.size).to eq(check_sizeof('struct mnttab', 'sys/mnttab.h'))
         | 
| 384 | 
            +
                  expect(Sys::Filesystem::Structs::Mnttab.size).to eq(dummy.check_sizeof('struct mnttab', 'sys/mnttab.h'))
         | 
| 382 385 | 
             
                end
         | 
| 383 386 |  | 
| 384 387 | 
             
                example "mntent struct is expected size" do
         | 
| 385 388 | 
             
                  skip "mnttab test skipped except on Linux" unless linux
         | 
| 386 | 
            -
                  expect(Sys::Filesystem::Structs::Mntent.size).to eq(check_sizeof('struct mntent', 'mntent.h'))
         | 
| 389 | 
            +
                  expect(Sys::Filesystem::Structs::Mntent.size).to eq(dummy.check_sizeof('struct mntent', 'mntent.h'))
         | 
| 387 390 | 
             
                end
         | 
| 388 391 | 
             
              end
         | 
| 389 392 | 
             
            end
         | 
| @@ -17,7 +17,7 @@ RSpec.describe Sys::Filesystem, :windows => true do | |
| 17 17 | 
             
              end
         | 
| 18 18 |  | 
| 19 19 | 
             
              example "version number is set to the expected value" do
         | 
| 20 | 
            -
                expect(Sys::Filesystem::VERSION).to eq('1.4. | 
| 20 | 
            +
                expect(Sys::Filesystem::VERSION).to eq('1.4.2')
         | 
| 21 21 | 
             
                expect(Sys::Filesystem::VERSION).to be_frozen
         | 
| 22 22 | 
             
              end
         | 
| 23 23 |  | 
    
        data/sys-filesystem.gemspec
    CHANGED
    
    | @@ -2,7 +2,7 @@ require 'rubygems' | |
| 2 2 |  | 
| 3 3 | 
             
            Gem::Specification.new do |spec|
         | 
| 4 4 | 
             
              spec.name       = 'sys-filesystem'
         | 
| 5 | 
            -
              spec.version    = '1.4. | 
| 5 | 
            +
              spec.version    = '1.4.2'
         | 
| 6 6 | 
             
              spec.author     = 'Daniel J. Berger'
         | 
| 7 7 | 
             
              spec.email      = 'djberg96@gmail.com'
         | 
| 8 8 | 
             
              spec.homepage   = 'https://github.com/djberg96/sys-filesystem'
         | 
| @@ -13,14 +13,14 @@ Gem::Specification.new do |spec| | |
| 13 13 | 
             
              spec.cert_chain = Dir['certs/*']
         | 
| 14 14 |  | 
| 15 15 | 
             
              spec.add_dependency('ffi', '~> 1.1')
         | 
| 16 | 
            -
              spec.add_development_dependency('mkmf-lite', '~> 0. | 
| 16 | 
            +
              spec.add_development_dependency('mkmf-lite', '~> 0.5') unless Gem.win_platform?
         | 
| 17 17 | 
             
              spec.add_development_dependency('rake')
         | 
| 18 18 | 
             
              spec.add_development_dependency('rspec', '~> 3.9')
         | 
| 19 19 |  | 
| 20 20 | 
             
              spec.metadata = {
         | 
| 21 21 | 
             
                'homepage_uri'      => 'https://github.com/djberg96/sys-filesystem',
         | 
| 22 22 | 
             
                'bug_tracker_uri'   => 'https://github.com/djberg96/sys-filesystem/issues',
         | 
| 23 | 
            -
                'changelog_uri'     => 'https://github.com/djberg96/sys-filesystem/blob/ | 
| 23 | 
            +
                'changelog_uri'     => 'https://github.com/djberg96/sys-filesystem/blob/main/CHANGES.md',
         | 
| 24 24 | 
             
                'documentation_uri' => 'https://github.com/djberg96/sys-filesystem/wiki',
         | 
| 25 25 | 
             
                'source_code_uri'   => 'https://github.com/djberg96/sys-filesystem',
         | 
| 26 26 | 
             
                'wiki_uri'          => 'https://github.com/djberg96/sys-filesystem/wiki'
         | 
    
        metadata
    CHANGED
    
    | @@ -1,11 +1,11 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: sys-filesystem
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.4. | 
| 4 | 
            +
              version: 1.4.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Daniel J. Berger
         | 
| 8 | 
            -
            autorequire:
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain:
         | 
| 11 11 | 
             
            - |
         | 
| @@ -35,7 +35,7 @@ cert_chain: | |
| 35 35 | 
             
              ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
         | 
| 36 36 | 
             
              WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
         | 
| 37 37 | 
             
              -----END CERTIFICATE-----
         | 
| 38 | 
            -
            date:  | 
| 38 | 
            +
            date: 2021-07-22 00:00:00.000000000 Z
         | 
| 39 39 | 
             
            dependencies:
         | 
| 40 40 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 41 41 | 
             
              name: ffi
         | 
| @@ -57,14 +57,14 @@ dependencies: | |
| 57 57 | 
             
                requirements:
         | 
| 58 58 | 
             
                - - "~>"
         | 
| 59 59 | 
             
                  - !ruby/object:Gem::Version
         | 
| 60 | 
            -
                    version: '0. | 
| 60 | 
            +
                    version: '0.5'
         | 
| 61 61 | 
             
              type: :development
         | 
| 62 62 | 
             
              prerelease: false
         | 
| 63 63 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 64 64 | 
             
                requirements:
         | 
| 65 65 | 
             
                - - "~>"
         | 
| 66 66 | 
             
                  - !ruby/object:Gem::Version
         | 
| 67 | 
            -
                    version: '0. | 
| 67 | 
            +
                    version: '0.5'
         | 
| 68 68 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 69 69 | 
             
              name: rake
         | 
| 70 70 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -130,11 +130,11 @@ licenses: | |
| 130 130 | 
             
            metadata:
         | 
| 131 131 | 
             
              homepage_uri: https://github.com/djberg96/sys-filesystem
         | 
| 132 132 | 
             
              bug_tracker_uri: https://github.com/djberg96/sys-filesystem/issues
         | 
| 133 | 
            -
              changelog_uri: https://github.com/djberg96/sys-filesystem/blob/ | 
| 133 | 
            +
              changelog_uri: https://github.com/djberg96/sys-filesystem/blob/main/CHANGES.md
         | 
| 134 134 | 
             
              documentation_uri: https://github.com/djberg96/sys-filesystem/wiki
         | 
| 135 135 | 
             
              source_code_uri: https://github.com/djberg96/sys-filesystem
         | 
| 136 136 | 
             
              wiki_uri: https://github.com/djberg96/sys-filesystem/wiki
         | 
| 137 | 
            -
            post_install_message:
         | 
| 137 | 
            +
            post_install_message: 
         | 
| 138 138 | 
             
            rdoc_options: []
         | 
| 139 139 | 
             
            require_paths:
         | 
| 140 140 | 
             
            - lib
         | 
| @@ -149,8 +149,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 149 149 | 
             
                - !ruby/object:Gem::Version
         | 
| 150 150 | 
             
                  version: '0'
         | 
| 151 151 | 
             
            requirements: []
         | 
| 152 | 
            -
            rubygems_version: 3. | 
| 153 | 
            -
            signing_key:
         | 
| 152 | 
            +
            rubygems_version: 3.0.3.1
         | 
| 153 | 
            +
            signing_key: 
         | 
| 154 154 | 
             
            specification_version: 4
         | 
| 155 155 | 
             
            summary: A Ruby interface for getting file system information.
         | 
| 156 156 | 
             
            test_files:
         | 
    
        metadata.gz.sig
    CHANGED
    
    | @@ -1,4 +1,3 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
             | 
| 3 | 
            -
            ������]k2������'Ք��ƍ=R��?6��Z�	E�D��f���E6����&?��X �m�0L�>�'ɓ2�,f8�$�
         | 
| 4 | 
            -
            ��Pp�F��1�#��JXn5��[�O�h�X(ڞ&�3FI��8���E���o�<����"ҧP��c2��B������b�/�}�դ��	
         | 
| 1 | 
            +
            �~)g`؆�'��iI��uԂS)�
         | 
| 2 | 
            +
            L��"5�ފ�rȥ�5�/����E9������,;}̡������h�'Sp|q�IlB2Z�p�L��k�XzyV����\�Ҩnx������b��*r������))`�!��rr_����{hkB=8���
         | 
| 5 | 
            -
            ��� | 
| 3 | 
            +
            �����٤��a�,Q'3"�%�|,YU���j��B�J���RȎ�-��E>�A=i��e�%���b9d\�C~� !%���;�:F��,�u�\��=2.�4ݿ]�@�O�Ϭs,Yi���i��wUt��T=�������
         |