sys-filesystem 1.4.3 → 1.5.5
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/CHANGES.md +44 -0
- data/README.md +8 -5
- data/Rakefile +22 -1
- data/lib/sys/filesystem.rb +17 -16
- data/lib/sys/unix/sys/filesystem/constants.rb +4 -0
- data/lib/sys/unix/sys/filesystem/functions.rb +20 -24
- data/lib/sys/unix/sys/filesystem/structs.rb +143 -94
- data/lib/sys/unix/sys/filesystem.rb +66 -54
- data/lib/sys/windows/sys/filesystem/functions.rb +1 -0
- data/lib/sys/windows/sys/filesystem/helper.rb +3 -0
- data/lib/sys/windows/sys/filesystem.rb +25 -23
- data/lib/sys-filesystem.rb +2 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/sys_filesystem_shared.rb +14 -0
- data/spec/sys_filesystem_unix_spec.rb +481 -136
- data/spec/sys_filesystem_windows_spec.rb +264 -152
- data/sys-filesystem.gemspec +17 -8
- data.tar.gz.sig +0 -0
- metadata +37 -8
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bff196a377aeaf2d5983fd6e15877a990c73e3fea18b6b94d7bc6a751d331419
|
|
4
|
+
data.tar.gz: 743b5452bd13840a977045a29a338b9240cfaa9eb0878385dcab66e9384c7335
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 77443aaa680057b9e055a2c570a3fcbd8025f32ebc266d3b6628d775a5a4d5b9cc3dbaadf99d4ba584f8f5badb9ae8665ca9e557403c05efc28dd4358be94f18
|
|
7
|
+
data.tar.gz: b11463a784178cca2068211aa342de4b2e3c65acac6830bdea67b6793214f0f2b9ba0c5dda53a274837d7822201d2d90c89ba92d69dab6d7bf003d6c7fb2a15e
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/CHANGES.md
CHANGED
|
@@ -1,3 +1,47 @@
|
|
|
1
|
+
## 1.5.5 - 6-Dec-2025
|
|
2
|
+
* Replaced string concatenation operators with addition assignment operators
|
|
3
|
+
since the current code generates a frozen string warning with Ruby 3.4 and
|
|
4
|
+
later.
|
|
5
|
+
* Updated Rakefile to run specs with warnings enabled.
|
|
6
|
+
|
|
7
|
+
## 1.5.4 - 7-Sep-2025
|
|
8
|
+
* Added a fallback check for 64-bit Linux in case the config info doesn't
|
|
9
|
+
include "64" anywhere in it. Thanks go to Chris Hofstaedtler for the
|
|
10
|
+
report.
|
|
11
|
+
|
|
12
|
+
## 1.5.3 - 3-Oct-2024
|
|
13
|
+
* Decided to unroll the changes in 1.5.2 because doing runtime compiler
|
|
14
|
+
checks was making more people unhappy than happy, and I already had
|
|
15
|
+
some misgivings about it.
|
|
16
|
+
* Updated the README.md to note the issues with running 32-bit Ruby with
|
|
17
|
+
64-bit offsets. At the moment I think this mainly only affects arch Linux.
|
|
18
|
+
|
|
19
|
+
## 1.5.2 - 30-Sep-2024
|
|
20
|
+
* Forgot to switch mkmf-lite from a dev dependency to a runtime dependency.
|
|
21
|
+
Thanks go to Thomas Langé for the spot and patch.
|
|
22
|
+
|
|
23
|
+
## 1.5.1 - 29-Sep-2024
|
|
24
|
+
* Add the f_type struct member to the Statvfs struct for Linux. This was added
|
|
25
|
+
at some point in the Linux lifecycle, though may still be blank depending on
|
|
26
|
+
your platform. Thanks go to Tasos Sahanidis for the patch.
|
|
27
|
+
* Added padding on 32-bit Statvfs struct with 64-bit offsets for Linux. Thanks
|
|
28
|
+
go Tasos Sahanidis again for this update.
|
|
29
|
+
* Bumped mkmf-lite dependency since the changes were needed to support the above.
|
|
30
|
+
|
|
31
|
+
## 1.5.0 - 8-Jun-2024
|
|
32
|
+
* Add support for DragonFlyBSD.
|
|
33
|
+
* Remove Solaris support. It's dead, Jim.
|
|
34
|
+
* Now assumes umount2 function is present on Linux systems, and some
|
|
35
|
+
corresponding refactoring of the umount method.
|
|
36
|
+
|
|
37
|
+
## 1.4.5 - 22-May-2024
|
|
38
|
+
* Handle the possibility that a statvs64 alias may not exist on some Linux
|
|
39
|
+
platforms. Thanks go to Antoine Martin for the report.
|
|
40
|
+
|
|
41
|
+
## 1.4.4 - 12-Sep-2023
|
|
42
|
+
* Yet another fix for 32-bit vs 64-bit linux, specifically for the Statvfs
|
|
43
|
+
struct. Thanks go to Josh Cooper for the spot and the patch.
|
|
44
|
+
|
|
1
45
|
## 1.4.3 - 20-Oct-2021
|
|
2
46
|
* Another fix for 32-bit vs 64-bit Linux since it was realized we cannot always
|
|
3
47
|
rely on the host architecture information. Handling for JRuby was improved
|
data/README.md
CHANGED
|
@@ -55,16 +55,19 @@ with JRuby, too.
|
|
|
55
55
|
Run 'rake example' if you want to see a basic sample run. The actual code
|
|
56
56
|
is 'example_stat.rb' in the 'examples' directory. Modify it as you see fit.
|
|
57
57
|
|
|
58
|
-
## Known
|
|
58
|
+
## Known Issues
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
Currently this may not work if you're running a 32-bit system with 64-bit offsets:
|
|
61
|
+
|
|
62
|
+
https://github.com/djberg96/sys-filesystem/issues/71
|
|
63
|
+
|
|
64
|
+
Please report any other issues on the project home page at:
|
|
61
65
|
|
|
62
66
|
https://github.com/djberg96/sys-filesystem
|
|
63
67
|
|
|
64
68
|
## Future Plans
|
|
65
69
|
|
|
66
|
-
*
|
|
67
|
-
* Other suggestions welcome.
|
|
70
|
+
* Suggestions welcome.
|
|
68
71
|
|
|
69
72
|
## Acknowledgements
|
|
70
73
|
|
|
@@ -78,7 +81,7 @@ Apache-2.0
|
|
|
78
81
|
|
|
79
82
|
## Copyright
|
|
80
83
|
|
|
81
|
-
(C) 2003-
|
|
84
|
+
(C) 2003-2025 Daniel J. Berger
|
|
82
85
|
All Rights Reserved
|
|
83
86
|
|
|
84
87
|
## Warranty
|
data/Rakefile
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
require 'rake'
|
|
2
2
|
require 'rake/clean'
|
|
3
3
|
require 'rspec/core/rake_task'
|
|
4
|
+
require 'rubocop/rake_task'
|
|
4
5
|
|
|
5
6
|
CLEAN.include('**/*.gem', '**/*.rbc', '**/*.rbx', '**/*.lock')
|
|
6
7
|
|
|
@@ -25,7 +26,27 @@ task :example do
|
|
|
25
26
|
sh "ruby -Ilib -Ilib/unix -Ilib/windows examples/example_stat.rb"
|
|
26
27
|
end
|
|
27
28
|
|
|
29
|
+
RuboCop::RakeTask.new
|
|
30
|
+
|
|
31
|
+
namespace :rubocop do
|
|
32
|
+
RuboCop::RakeTask.new(:unix) do |task|
|
|
33
|
+
task.patterns = ['lib/sys/unix/sys/**/*.rb', 'spec/*unix*']
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
RuboCop::RakeTask.new(:windows) do |task|
|
|
37
|
+
task.patterns = ['lib/sys/windows/sys/**/*.rb', 'spec/*windows*']
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
28
41
|
desc "Run the test suite"
|
|
29
|
-
RSpec::Core::RakeTask.new(:spec)
|
|
42
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
|
43
|
+
t.verbose = false
|
|
44
|
+
t.rspec_opts = '-f documentation -w'
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Clean up afterwards
|
|
48
|
+
Rake::Task[:spec].enhance do
|
|
49
|
+
Rake::Task[:clean].invoke
|
|
50
|
+
end
|
|
30
51
|
|
|
31
52
|
task :default => :spec
|
data/lib/sys/filesystem.rb
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
class Filesystem
|
|
3
|
-
# The version of the sys-filesystem library
|
|
4
|
-
VERSION = '1.4.3'.freeze
|
|
5
|
-
end
|
|
6
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
7
2
|
|
|
8
3
|
require 'rbconfig'
|
|
9
4
|
|
|
@@ -13,10 +8,18 @@ else
|
|
|
13
8
|
require_relative 'unix/sys/filesystem'
|
|
14
9
|
end
|
|
15
10
|
|
|
16
|
-
# Methods universal to all platforms
|
|
11
|
+
# Methods and properties universal to all platforms
|
|
17
12
|
|
|
13
|
+
# The Sys module serves as a namespace only.
|
|
18
14
|
module Sys
|
|
15
|
+
# The Filesystem class serves as an abstract base class. Its methods
|
|
16
|
+
# return objects of other types. Do not instantiate.
|
|
19
17
|
class Filesystem
|
|
18
|
+
# The version of the sys-filesystem library
|
|
19
|
+
VERSION = '1.5.5'
|
|
20
|
+
|
|
21
|
+
# Stat objects are returned by the Sys::Filesystem.stat method. Here
|
|
22
|
+
# we're adding universal methods.
|
|
20
23
|
class Stat
|
|
21
24
|
# Returns true if the filesystem is case sensitive for the current path.
|
|
22
25
|
# Typically this will be any path on MS Windows or Macs using HFS.
|
|
@@ -26,14 +29,12 @@ module Sys
|
|
|
26
29
|
# general rule, I do not recommend using this method for a root path.
|
|
27
30
|
#
|
|
28
31
|
def case_insensitive?
|
|
29
|
-
if path
|
|
30
|
-
if RbConfig::CONFIG['host_os'] =~ /darwin|mac|windows|mswin|mingw/i
|
|
31
|
-
true # Assumes HFS
|
|
32
|
-
else
|
|
33
|
-
false
|
|
34
|
-
end
|
|
35
|
-
else
|
|
32
|
+
if path =~ /\w+/
|
|
36
33
|
File.identical?(path, path.swapcase)
|
|
34
|
+
elsif RbConfig::CONFIG['host_os'] =~ /darwin|mac|windows|mswin|mingw/i
|
|
35
|
+
true # Assumes HFS/APFS on Mac
|
|
36
|
+
else
|
|
37
|
+
false
|
|
37
38
|
end
|
|
38
39
|
end
|
|
39
40
|
|
|
@@ -46,8 +47,8 @@ module Sys
|
|
|
46
47
|
end
|
|
47
48
|
end
|
|
48
49
|
|
|
49
|
-
#
|
|
50
|
-
#
|
|
50
|
+
# Reopen the Numeric class and add some convenient methods
|
|
51
|
+
# for converting bytes to kb, mb, and gb.
|
|
51
52
|
class Numeric
|
|
52
53
|
# call-seq:
|
|
53
54
|
# <tt>num</tt>.to_kb
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Sys
|
|
2
4
|
class Filesystem
|
|
3
5
|
module Constants
|
|
@@ -23,6 +25,8 @@ module Sys
|
|
|
23
25
|
MNT_DEFWRITE = 0x02000000 # filesystem should defer writes
|
|
24
26
|
MNT_MULTILABEL = 0x04000000 # MAC support for individual labels
|
|
25
27
|
MNT_NOATIME = 0x10000000 # disable update of file access time
|
|
28
|
+
MNT_NOCLUSTERR = 0x40000000 # disable cluster read
|
|
29
|
+
MNT_NOCLUSTERW = 0x80000000 # disable cluster write
|
|
26
30
|
|
|
27
31
|
MNT_VISFLAGMASK = (
|
|
28
32
|
MNT_RDONLY | MNT_SYNCHRONOUS | MNT_NOEXEC |
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'ffi'
|
|
2
4
|
|
|
3
5
|
module Sys
|
|
4
6
|
class Filesystem
|
|
7
|
+
# A scoped module for internal FFI functions to be used by the main code.
|
|
5
8
|
module Functions
|
|
6
9
|
extend FFI::Library
|
|
7
10
|
|
|
@@ -9,19 +12,22 @@ module Sys
|
|
|
9
12
|
|
|
10
13
|
def self.linux64?
|
|
11
14
|
if RUBY_PLATFORM == 'java'
|
|
12
|
-
|
|
15
|
+
RbConfig::CONFIG['host_os'] =~ /linux/i &&
|
|
16
|
+
ENV_JAVA['sun.arch.data.model'].to_i == 64
|
|
13
17
|
else
|
|
14
18
|
RbConfig::CONFIG['host_os'] =~ /linux/i &&
|
|
15
|
-
(RbConfig::CONFIG['arch'] =~ /64/ || RbConfig::CONFIG['DEFS'] =~ /64/)
|
|
19
|
+
(RbConfig::CONFIG['arch'] =~ /64/ || RbConfig::CONFIG['DEFS'] =~ /64/ || [nil].pack('P').size == 8)
|
|
16
20
|
end
|
|
17
21
|
end
|
|
18
22
|
|
|
19
23
|
private_class_method :linux64?
|
|
20
24
|
|
|
21
|
-
if
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
if linux64?
|
|
26
|
+
begin
|
|
27
|
+
attach_function(:statvfs, :statvfs64, %i[string pointer], :int)
|
|
28
|
+
rescue FFI::NotFoundError # Not every Linux distro has an alias
|
|
29
|
+
attach_function(:statvfs, %i[string pointer], :int)
|
|
30
|
+
end
|
|
25
31
|
else
|
|
26
32
|
attach_function(:statvfs, %i[string pointer], :int)
|
|
27
33
|
end
|
|
@@ -29,29 +35,19 @@ module Sys
|
|
|
29
35
|
attach_function(:strerror, [:int], :string)
|
|
30
36
|
attach_function(:mount_c, :mount, %i[string string string ulong string], :int)
|
|
31
37
|
|
|
32
|
-
|
|
33
|
-
attach_function(:umount_c, :
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
attach_function(:umount_c, :unmount, [:string], :int)
|
|
37
|
-
end
|
|
38
|
+
if RbConfig::CONFIG['host_os'] =~ /darwin|osx|mach|bsd|dragonfly/i
|
|
39
|
+
attach_function(:umount_c, :unmount, %i[string int], :int)
|
|
40
|
+
else
|
|
41
|
+
attach_function(:umount_c, :umount2, %i[string int], :int)
|
|
38
42
|
end
|
|
39
43
|
|
|
40
44
|
private_class_method :statvfs, :strerror, :mount_c, :umount_c
|
|
41
45
|
|
|
42
46
|
begin
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
private_class_method :fopen, :fclose, :getmntent
|
|
48
|
-
else
|
|
49
|
-
attach_function(:getmntent, [:pointer], :pointer)
|
|
50
|
-
attach_function(:setmntent, %i[string string], :pointer)
|
|
51
|
-
attach_function(:endmntent, [:pointer], :int)
|
|
52
|
-
attach_function(:umount2, %i[string int], :int)
|
|
53
|
-
private_class_method :getmntent, :setmntent, :endmntent, :umount2
|
|
54
|
-
end
|
|
47
|
+
attach_function(:getmntent, [:pointer], :pointer)
|
|
48
|
+
attach_function(:setmntent, %i[string string], :pointer)
|
|
49
|
+
attach_function(:endmntent, [:pointer], :int)
|
|
50
|
+
private_class_method :getmntent, :setmntent, :endmntent
|
|
55
51
|
rescue FFI::NotFoundError
|
|
56
52
|
if RbConfig::CONFIG['host_os'] =~ /darwin|osx|mach/i
|
|
57
53
|
begin
|
|
@@ -1,17 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'ffi'
|
|
2
4
|
require 'rbconfig'
|
|
3
5
|
|
|
4
6
|
module Sys
|
|
5
7
|
class Filesystem
|
|
6
8
|
module Structs
|
|
7
|
-
|
|
9
|
+
# Used by DragonFlyBSD
|
|
10
|
+
class UUID < FFI::Struct
|
|
11
|
+
UUID_NODE_LEN = 6
|
|
8
12
|
|
|
13
|
+
layout(
|
|
14
|
+
:time_low, :uint32,
|
|
15
|
+
:time_mid, :uint16,
|
|
16
|
+
:time_hi_and_version, :uint16,
|
|
17
|
+
:clock_seq_hi_and_reserved, :uint8,
|
|
18
|
+
:clock_seq_low, :uint8,
|
|
19
|
+
:node, [:uint8, UUID_NODE_LEN]
|
|
20
|
+
)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# The Statfs struct is a subclass of FFI::Struct that corresponds to a struct statfs.
|
|
24
|
+
class Statfs < FFI::Struct
|
|
25
|
+
# Private method that will determine the layout of the struct on Linux.
|
|
9
26
|
def self.linux64?
|
|
10
27
|
if RUBY_PLATFORM == 'java'
|
|
11
28
|
ENV_JAVA['sun.arch.data.model'].to_i == 64
|
|
12
29
|
else
|
|
13
30
|
RbConfig::CONFIG['host_os'] =~ /linux/i &&
|
|
14
|
-
(RbConfig::CONFIG['arch'] =~ /64/ || RbConfig::CONFIG['DEFS'] =~ /64/)
|
|
31
|
+
(RbConfig::CONFIG['arch'] =~ /64/ || RbConfig::CONFIG['DEFS'] =~ /64/ || [nil].pack('P').size == 8)
|
|
15
32
|
end
|
|
16
33
|
end
|
|
17
34
|
|
|
@@ -20,92 +37,128 @@ module Sys
|
|
|
20
37
|
# FreeBSD 12.0 MNAMELEN from 88 => 1024.
|
|
21
38
|
MNAMELEN =
|
|
22
39
|
if RbConfig::CONFIG['host_os'] =~ /freebsd(.*)/i
|
|
23
|
-
|
|
40
|
+
Regexp.last_match(1).to_f < 12.0 ? 88 : 1024
|
|
24
41
|
else
|
|
25
42
|
88
|
|
26
43
|
end
|
|
27
44
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
:f_version, :uint32,
|
|
31
|
-
:f_type, :uint32,
|
|
32
|
-
:f_flags, :uint64,
|
|
33
|
-
:f_bsize, :uint64,
|
|
34
|
-
:f_iosize, :int64,
|
|
35
|
-
:f_blocks, :uint64,
|
|
36
|
-
:f_bfree, :uint64,
|
|
37
|
-
:f_bavail, :int64,
|
|
38
|
-
:f_files, :uint64,
|
|
39
|
-
:f_ffree, :uint64,
|
|
40
|
-
:f_syncwrites, :uint64,
|
|
41
|
-
:f_asyncwrites, :uint64,
|
|
42
|
-
:f_syncreads, :uint64,
|
|
43
|
-
:f_asyncreads, :uint64,
|
|
44
|
-
:f_spare, [:uint64, 10],
|
|
45
|
-
:f_namemax, :uint32,
|
|
46
|
-
:f_owner, :int32,
|
|
47
|
-
:f_fsid, [:int32, 2],
|
|
48
|
-
:f_charspare, [:char, 80],
|
|
49
|
-
:f_fstypename, [:char, 16],
|
|
50
|
-
:f_mntfromname, [:char, MNAMELEN],
|
|
51
|
-
:f_mntonname, [:char, MNAMELEN]
|
|
52
|
-
)
|
|
53
|
-
elsif RbConfig::CONFIG['host_os'] =~ /linux/i
|
|
54
|
-
if linux64?
|
|
45
|
+
case RbConfig::CONFIG['host_os']
|
|
46
|
+
when /bsd/i
|
|
55
47
|
layout(
|
|
56
|
-
:
|
|
57
|
-
:
|
|
48
|
+
:f_version, :uint32,
|
|
49
|
+
:f_type, :uint32,
|
|
50
|
+
:f_flags, :uint64,
|
|
51
|
+
:f_bsize, :uint64,
|
|
52
|
+
:f_iosize, :int64,
|
|
58
53
|
:f_blocks, :uint64,
|
|
59
54
|
:f_bfree, :uint64,
|
|
60
|
-
:f_bavail, :
|
|
55
|
+
:f_bavail, :int64,
|
|
61
56
|
:f_files, :uint64,
|
|
62
57
|
:f_ffree, :uint64,
|
|
63
|
-
:
|
|
64
|
-
:
|
|
65
|
-
:
|
|
66
|
-
:
|
|
67
|
-
:f_spare, [:
|
|
58
|
+
:f_syncwrites, :uint64,
|
|
59
|
+
:f_asyncwrites, :uint64,
|
|
60
|
+
:f_syncreads, :uint64,
|
|
61
|
+
:f_asyncreads, :uint64,
|
|
62
|
+
:f_spare, [:uint64, 10],
|
|
63
|
+
:f_namemax, :uint32,
|
|
64
|
+
:f_owner, :int32,
|
|
65
|
+
:f_fsid, [:int32, 2],
|
|
66
|
+
:f_charspare, [:char, 80],
|
|
67
|
+
:f_fstypename, [:char, 16],
|
|
68
|
+
:f_mntfromname, [:char, MNAMELEN],
|
|
69
|
+
:f_mntonname, [:char, MNAMELEN]
|
|
70
|
+
)
|
|
71
|
+
when /linux/i
|
|
72
|
+
if linux64?
|
|
73
|
+
layout(
|
|
74
|
+
:f_type, :ulong,
|
|
75
|
+
:f_bsize, :ulong,
|
|
76
|
+
:f_blocks, :uint64,
|
|
77
|
+
:f_bfree, :uint64,
|
|
78
|
+
:f_bavail, :uint64,
|
|
79
|
+
:f_files, :uint64,
|
|
80
|
+
:f_ffree, :uint64,
|
|
81
|
+
:f_fsid, [:int, 2],
|
|
82
|
+
:f_namelen, :ulong,
|
|
83
|
+
:f_frsize, :ulong,
|
|
84
|
+
:f_flags, :ulong,
|
|
85
|
+
:f_spare, [:ulong, 4]
|
|
86
|
+
)
|
|
87
|
+
else
|
|
88
|
+
layout(
|
|
89
|
+
:f_type, :ulong,
|
|
90
|
+
:f_bsize, :ulong,
|
|
91
|
+
:f_blocks, :uint32,
|
|
92
|
+
:f_bfree, :uint32,
|
|
93
|
+
:f_bavail, :uint32,
|
|
94
|
+
:f_files, :uint32,
|
|
95
|
+
:f_ffree, :uint32,
|
|
96
|
+
:f_fsid, [:int, 2],
|
|
97
|
+
:f_namelen, :ulong,
|
|
98
|
+
:f_frsize, :ulong,
|
|
99
|
+
:f_flags, :ulong,
|
|
100
|
+
:f_spare, [:ulong, 4]
|
|
101
|
+
)
|
|
102
|
+
end
|
|
103
|
+
when /dragonfly/i
|
|
104
|
+
layout(
|
|
105
|
+
:f_spare2, :long,
|
|
106
|
+
:f_bsize, :long,
|
|
107
|
+
:f_iosize, :long,
|
|
108
|
+
:f_blocks, :long,
|
|
109
|
+
:f_bfree, :long,
|
|
110
|
+
:f_bavail, :long,
|
|
111
|
+
:f_files, :long,
|
|
112
|
+
:f_ffree, :long,
|
|
113
|
+
:f_fsid, [:int32_t, 2],
|
|
114
|
+
:f_owner, :uid_t,
|
|
115
|
+
:f_type, :int,
|
|
116
|
+
:f_flags, :int,
|
|
117
|
+
:f_syncwrites, :long,
|
|
118
|
+
:f_asyncwrites, :long,
|
|
119
|
+
:f_fstypename, [:char, 16],
|
|
120
|
+
:f_mntonname, [:char, 80],
|
|
121
|
+
:f_syncreads, :long,
|
|
122
|
+
:f_asyncreads, :long,
|
|
123
|
+
:f_spares1, :short,
|
|
124
|
+
:f_mntfromname, [:char, 80],
|
|
125
|
+
:f_spares2, :short,
|
|
126
|
+
:f_spare, [:long, 2]
|
|
68
127
|
)
|
|
69
128
|
else
|
|
70
129
|
layout(
|
|
71
|
-
:
|
|
72
|
-
:
|
|
73
|
-
:f_blocks, :
|
|
74
|
-
:f_bfree, :
|
|
75
|
-
:f_bavail, :
|
|
76
|
-
:f_files, :
|
|
77
|
-
:f_ffree, :
|
|
78
|
-
:f_fsid, [:
|
|
79
|
-
:
|
|
80
|
-
:
|
|
81
|
-
:f_flags, :
|
|
82
|
-
:
|
|
130
|
+
:f_bsize, :uint32,
|
|
131
|
+
:f_iosize, :int32,
|
|
132
|
+
:f_blocks, :uint64,
|
|
133
|
+
:f_bfree, :uint64,
|
|
134
|
+
:f_bavail, :uint64,
|
|
135
|
+
:f_files, :uint64,
|
|
136
|
+
:f_ffree, :uint64,
|
|
137
|
+
:f_fsid, [:int32, 2],
|
|
138
|
+
:f_owner, :int32,
|
|
139
|
+
:f_type, :uint32,
|
|
140
|
+
:f_flags, :uint32,
|
|
141
|
+
:f_fssubtype, :uint32,
|
|
142
|
+
:f_fstypename, [:char, 16],
|
|
143
|
+
:f_mntonname, [:char, 1024],
|
|
144
|
+
:f_mntfromname, [:char, 1024],
|
|
145
|
+
:f_reserved, [:uint32, 8]
|
|
83
146
|
)
|
|
84
|
-
end
|
|
85
|
-
else
|
|
86
|
-
layout(
|
|
87
|
-
:f_bsize, :uint32,
|
|
88
|
-
:f_iosize, :int32,
|
|
89
|
-
:f_blocks, :uint64,
|
|
90
|
-
:f_bfree, :uint64,
|
|
91
|
-
:f_bavail, :uint64,
|
|
92
|
-
:f_files, :uint64,
|
|
93
|
-
:f_ffree, :uint64,
|
|
94
|
-
:f_fsid, [:int32, 2],
|
|
95
|
-
:f_owner, :int32,
|
|
96
|
-
:f_type, :uint32,
|
|
97
|
-
:f_flags, :uint32,
|
|
98
|
-
:f_fssubtype, :uint32,
|
|
99
|
-
:f_fstypename, [:char, 16],
|
|
100
|
-
:f_mntonname, [:char, 1024],
|
|
101
|
-
:f_mntfromname, [:char, 1024],
|
|
102
|
-
:f_reserved, [:uint32, 8]
|
|
103
|
-
)
|
|
104
147
|
end
|
|
105
148
|
end
|
|
106
149
|
|
|
107
150
|
# The Statvfs struct represents struct statvfs from sys/statvfs.h.
|
|
108
151
|
class Statvfs < FFI::Struct
|
|
152
|
+
# Private method that will determine the layout of the struct on Linux.
|
|
153
|
+
def self.linux64?
|
|
154
|
+
if RUBY_PLATFORM == 'java'
|
|
155
|
+
ENV_JAVA['sun.arch.data.model'].to_i == 64
|
|
156
|
+
else
|
|
157
|
+
RbConfig::CONFIG['host_os'] =~ /linux/i &&
|
|
158
|
+
(RbConfig::CONFIG['arch'] =~ /64/ || RbConfig::CONFIG['DEFS'] =~ /64/ || [nil].pack('P').size == 8)
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
109
162
|
if RbConfig::CONFIG['host_os'] =~ /darwin|osx|mach/i
|
|
110
163
|
layout(
|
|
111
164
|
:f_bsize, :ulong,
|
|
@@ -134,24 +187,29 @@ module Sys
|
|
|
134
187
|
:f_fsid, :ulong,
|
|
135
188
|
:f_namemax, :ulong
|
|
136
189
|
)
|
|
137
|
-
elsif RbConfig::CONFIG['host'] =~ /
|
|
190
|
+
elsif RbConfig::CONFIG['host'] =~ /dragonfly/i
|
|
138
191
|
layout(
|
|
139
192
|
:f_bsize, :ulong,
|
|
140
193
|
:f_frsize, :ulong,
|
|
141
|
-
:f_blocks, :
|
|
142
|
-
:f_bfree, :
|
|
143
|
-
:f_bavail, :
|
|
144
|
-
:f_files, :
|
|
145
|
-
:f_ffree, :
|
|
146
|
-
:f_favail, :
|
|
194
|
+
:f_blocks, :uint64,
|
|
195
|
+
:f_bfree, :uint64,
|
|
196
|
+
:f_bavail, :uint64,
|
|
197
|
+
:f_files, :uint64,
|
|
198
|
+
:f_ffree, :uint64,
|
|
199
|
+
:f_favail, :uint64,
|
|
147
200
|
:f_fsid, :ulong,
|
|
148
|
-
:f_basetype, [:char, 16],
|
|
149
201
|
:f_flag, :ulong,
|
|
150
202
|
:f_namemax, :ulong,
|
|
151
|
-
:
|
|
152
|
-
:
|
|
203
|
+
:f_owner, :uid_t,
|
|
204
|
+
:f_type, :uint,
|
|
205
|
+
:f_syncreads, :uint64,
|
|
206
|
+
:f_syncwrites, :uint64,
|
|
207
|
+
:f_asyncreads, :uint64,
|
|
208
|
+
:f_asyncwrites, :uint64,
|
|
209
|
+
:f_fsid_uuid, UUID,
|
|
210
|
+
:f_uid_uuid, UUID
|
|
153
211
|
)
|
|
154
|
-
elsif
|
|
212
|
+
elsif !linux64?
|
|
155
213
|
layout(
|
|
156
214
|
:f_bsize, :ulong,
|
|
157
215
|
:f_frsize, :ulong,
|
|
@@ -165,7 +223,8 @@ module Sys
|
|
|
165
223
|
:f_unused, :int,
|
|
166
224
|
:f_flag, :ulong,
|
|
167
225
|
:f_namemax, :ulong,
|
|
168
|
-
:
|
|
226
|
+
:f_type, :uint,
|
|
227
|
+
:f_spare, [:int, 5]
|
|
169
228
|
)
|
|
170
229
|
else
|
|
171
230
|
layout(
|
|
@@ -180,22 +239,12 @@ module Sys
|
|
|
180
239
|
:f_fsid, :ulong,
|
|
181
240
|
:f_flag, :ulong,
|
|
182
241
|
:f_namemax, :ulong,
|
|
183
|
-
:
|
|
242
|
+
:f_type, :uint,
|
|
243
|
+
:f_spare, [:int, 5]
|
|
184
244
|
)
|
|
185
245
|
end
|
|
186
246
|
end
|
|
187
247
|
|
|
188
|
-
# The Mnttab struct represents struct mnnttab from sys/mnttab.h on Solaris.
|
|
189
|
-
class Mnttab < FFI::Struct
|
|
190
|
-
layout(
|
|
191
|
-
:mnt_special, :string,
|
|
192
|
-
:mnt_mountp, :string,
|
|
193
|
-
:mnt_fstype, :string,
|
|
194
|
-
:mnt_mntopts, :string,
|
|
195
|
-
:mnt_time, :string
|
|
196
|
-
)
|
|
197
|
-
end
|
|
198
|
-
|
|
199
248
|
# The Mntent struct represents struct mntent from sys/mount.h on Unix.
|
|
200
249
|
class Mntent < FFI::Struct
|
|
201
250
|
layout(
|