sys-filesystem 1.3.4 → 1.4.3
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.rdoc → CHANGES.md} +50 -25
- data/Gemfile +2 -0
- data/{MANIFEST.rdoc → MANIFEST.md} +8 -6
- data/README.md +92 -0
- data/Rakefile +14 -24
- data/examples/example_mount.rb +3 -2
- data/lib/sys/filesystem.rb +1 -1
- data/lib/sys/unix/sys/filesystem/constants.rb +2 -4
- data/lib/sys/unix/sys/filesystem/functions.rb +27 -10
- data/lib/sys/unix/sys/filesystem/structs.rb +58 -14
- data/lib/sys/unix/sys/filesystem.rb +54 -32
- data/lib/sys/windows/sys/filesystem/functions.rb +10 -10
- data/lib/sys/windows/sys/filesystem/helper.rb +1 -1
- data/lib/sys/windows/sys/filesystem.rb +45 -29
- data/spec/spec_helper.rb +6 -0
- data/spec/sys_filesystem_unix_spec.rb +396 -0
- data/spec/sys_filesystem_windows_spec.rb +348 -0
- data/sys-filesystem.gemspec +6 -8
- data.tar.gz.sig +0 -0
- metadata +41 -55
- metadata.gz.sig +0 -0
- data/README.rdoc +0 -77
- data/test/test_sys_filesystem.rb +0 -7
- data/test/test_sys_filesystem_unix.rb +0 -329
- data/test/test_sys_filesystem_windows.rb +0 -303
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b00e624e22bd699630d63b34f90be7758f82630a069f7db2a61e2139cb55888
|
4
|
+
data.tar.gz: 59add440f0203bade0430b2acd410e785b4ab0de416f272755a72db9276aa767
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb24f3c965a15d090fd7fff5800cc4c1829a7ddc7f2cbc4e943bb7e57ae92749a6abfccfecd94e8522287e9700916fc22f57af164afa413459321fa9460ba9a3
|
7
|
+
data.tar.gz: d5d30e84e01f370ac62b77251f2c80c07964a99bebfa0cc30252237bc33830198d3a065c28a546c230327b1b951d45d95bc309f75276d17d7e1e8968ade216f2
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/{CHANGES.rdoc → CHANGES.md}
RENAMED
@@ -1,26 +1,51 @@
|
|
1
|
-
|
1
|
+
## 1.4.3 - 20-Oct-2021
|
2
|
+
* Another fix for 32-bit vs 64-bit Linux since it was realized we cannot always
|
3
|
+
rely on the host architecture information. Handling for JRuby was improved
|
4
|
+
as well. Thanks go to Scott Bradnick for the spot.
|
5
|
+
* The constructor is now explicitly private. This class was never meant to
|
6
|
+
actually be instantiated.
|
7
|
+
* Updated the MANIFEST.md file.
|
8
|
+
|
9
|
+
## 1.4.2 - 22-Jul-2021
|
10
|
+
* Fixed support for 32-bit Linux. Thanks go to ciprianbadescu for the spot.
|
11
|
+
|
12
|
+
## 1.4.1 - 30-Dec-2020
|
13
|
+
* Fix an FFI function declaration bug for Big Sur and later on Mac. Thanks go
|
14
|
+
to Roman Gaufman for the spot and Martins Polakovs for testing.
|
15
|
+
* Fixed the changelog metadata URI.
|
16
|
+
* Added a .gitignore file.
|
17
|
+
|
18
|
+
## 1.4.0 - 6-Sep-2020
|
19
|
+
* The Sys::Filesystem.stat method now accepts a Pathname and Dir object as
|
20
|
+
an argument. On most platforms it will also accept a File object. Thanks
|
21
|
+
go to hirura for the patch.
|
22
|
+
* Fixed the statvfs struct layout on i686 platforms. Thanks go to
|
23
|
+
Filipovici-Andrei for the patch.
|
24
|
+
* Switched from test-unit to rspec, and updated the tests.
|
25
|
+
|
26
|
+
## 1.3.4 - 17-Mar-2020
|
2
27
|
* Properly include a LICENSE file as per the Apache-2.0 license.
|
3
28
|
|
4
|
-
|
29
|
+
## 1.3.3 - 18-Feb-2020
|
5
30
|
* Linux now uses statvfs64 under the hood. This fixes a potential issue with
|
6
31
|
32 bit systems. Thanks go to Tom Smyth for the spot.
|
7
32
|
|
8
|
-
|
33
|
+
## 1.3.2 - 8-Dec-2019
|
9
34
|
* Renamed various text files to include .rdoc extension so that github renders
|
10
35
|
them nicely.
|
11
36
|
|
12
|
-
|
37
|
+
## 1.3.1 - 15-Oct-2019
|
13
38
|
* Fixed a bug where the Statvfs and Statfs structs were not allocated properly
|
14
39
|
on Linux, which could cause issues. Thanks go to Daniele Orlandi for the spot.
|
15
40
|
* Added specs to ensure that the FFI struct size matches the C struct size.
|
16
41
|
This required adding mkmf-lite as a development dependency.
|
17
42
|
* Added a slightly more pessimistic version requirement for test-unit.
|
18
43
|
|
19
|
-
|
44
|
+
## 1.3.0 - 3-Oct-2019
|
20
45
|
* Added the mount and umount singleton methods.
|
21
46
|
* Changed an internal class variable to a frozen constant.
|
22
47
|
|
23
|
-
|
48
|
+
## 1.2.0 - 1-Jan-2019
|
24
49
|
* Changed the license to Apache-2.0.
|
25
50
|
* Added the case_sensitive? and case_insensitive? instance methods to the
|
26
51
|
Filesystem::Stat class.
|
@@ -28,7 +53,7 @@
|
|
28
53
|
* Fixed the deprecation warnings when running the tests on Windows.
|
29
54
|
* Added metadata to the gemspec.
|
30
55
|
|
31
|
-
|
56
|
+
## 1.1.9 - 26-Jan-2018
|
32
57
|
* The bytes_free and bytes_total methods were updated to use the fragment size
|
33
58
|
instead of the block size. This fixes Macs using APFS, as well as Solaris 10.
|
34
59
|
Thanks go to Mikhail Vasin for the spot.
|
@@ -36,39 +61,39 @@
|
|
36
61
|
to address the issue now resolved by the above change.
|
37
62
|
* Updated the cert again.
|
38
63
|
|
39
|
-
|
64
|
+
## 1.1.8 - 2-Sep-2017
|
40
65
|
* The stat and mount_point methods now call to_s on the string argument
|
41
66
|
explicitly so that Pathname objects will now work with String#wincode.
|
42
67
|
* Updated some tests to avoid Fixnum warnings for Ruby 2.4.
|
43
68
|
* Updated the cert.
|
44
69
|
|
45
|
-
|
70
|
+
## 1.1.7 - 1-Aug-2016
|
46
71
|
* Fixed an issue in the stat method for MS Windows where the blocks_avail
|
47
72
|
value was not correct. Thanks go to Maxime Lapointe for the spot.
|
48
73
|
|
49
|
-
|
74
|
+
## 1.1.6 - 17-May-2016
|
50
75
|
* On versions that use setmntent or fopen, explicitly raise an error if
|
51
76
|
either of those calls return a null value.
|
52
77
|
|
53
|
-
|
78
|
+
## 1.1.5 - 5-Dec-2015
|
54
79
|
* This gem is now signed.
|
55
80
|
* The gem related tasks in the Rakefile now assume Rubygems 2.x.
|
56
81
|
* Updates to the gemspec, added cert_chain, removed rubyforge_project.
|
57
82
|
* Internal reorganization, and use of relative_require as appropriate.
|
58
83
|
* Added a sys-filesystem.rb file for convenience.
|
59
84
|
|
60
|
-
|
85
|
+
## 1.1.4 - 15-Mar-2015
|
61
86
|
* The File.mounts method no longer raises an error if a mount point
|
62
87
|
is not accessible. Thanks go to Michael Pope for the patch.
|
63
88
|
* Some internal code reorganization.
|
64
89
|
|
65
|
-
|
90
|
+
## 1.1.3 - 1-Oct-2014
|
66
91
|
* Now ignores EPERM errors when trying to find the mount point for a path.
|
67
92
|
Thanks go to petersen for the patch.
|
68
93
|
* The Filesystem.stat method now defaults to using the root path on Windows
|
69
94
|
for volume information.
|
70
95
|
|
71
|
-
|
96
|
+
## 1.1.2 - 9-May-2014
|
72
97
|
* Added the percent_used, bytes_total, bytes_free and bytes_used methods
|
73
98
|
to the Filesystem::Stat class. Thanks go to xanview for the suggestion.
|
74
99
|
* Changed File.exists? to File.exist? to avoid warnings in Ruby 2.1.x.
|
@@ -77,30 +102,30 @@
|
|
77
102
|
* Added the to_tb method for terabytes.
|
78
103
|
* Minor updates to the gem:create and gem:install Rake tasks.
|
79
104
|
|
80
|
-
|
105
|
+
## 1.1.1 - 3-Oct-2013
|
81
106
|
* Solaris now always uses statvfs64 on Solaris for better 64-bit support.
|
82
107
|
Thanks go to Jeff Shantz for the spot.
|
83
108
|
|
84
|
-
|
109
|
+
## 1.1.0 - 19-Jan-2013
|
85
110
|
* Converted the Windows source code to use FFI. Consequently, there is now
|
86
111
|
a single gem rather than separate gems for Windows and Unix.
|
87
112
|
* Revamped the Windows tests.
|
88
113
|
|
89
|
-
|
114
|
+
## 1.0.0 - 11-Jan-2012
|
90
115
|
* Converted everything from C to FFI for the Unix flavors. The Windows
|
91
116
|
source code remains untouched.
|
92
117
|
|
93
|
-
|
118
|
+
## 0.3.4 - 19-Nov-2010
|
94
119
|
* Fixed a bug where negative block counts were happening on very large
|
95
120
|
hard drives. Thanks go to Jonas Pfenniger for the spot.
|
96
121
|
* Refactored the clean task in the Rakefile.
|
97
122
|
* Some cosmetic source code changes.
|
98
123
|
|
99
|
-
|
124
|
+
## 0.3.3 - 21-May-2010
|
100
125
|
* Added a workaround for the Sys::Filesystem#block_size member to deal with
|
101
126
|
a bug in OS X. Thanks go to Josh Pasqualetto for the spot.
|
102
127
|
|
103
|
-
|
128
|
+
## 0.3.2 - 29-Dec-2009
|
104
129
|
* Source has been moved to github.
|
105
130
|
* Added the 'gem' task and removed build logic from the gemspec.
|
106
131
|
* Updated the install task.
|
@@ -108,23 +133,23 @@
|
|
108
133
|
* Removed some junk build files that were inadvertently included in
|
109
134
|
the last gem.
|
110
135
|
|
111
|
-
|
136
|
+
## 0.3.1 - 5-Aug-2009
|
112
137
|
* Now compatible with Ruby 1.9.x.
|
113
138
|
* Changed license to Artistic 2.0
|
114
139
|
* Updated the gemspec, including the explicit addition of a license and
|
115
140
|
test-unit as a development dependency, as well as an updated description.
|
116
141
|
|
117
|
-
|
142
|
+
## 0.3.0 - 26-Feb-2009
|
118
143
|
* Added support for OS X and FreeBSD thanks to an awesome patch by Nobuyoshi
|
119
144
|
Miyokawa.
|
120
145
|
* Added the Filesystem.mount_point method that takes a file and returns
|
121
146
|
the mount point it's sitting on.
|
122
147
|
|
123
|
-
|
148
|
+
## 0.2.0 - 30-Dec-2008
|
124
149
|
* Added the Filesystem.mounts method for iterating over mount or volume
|
125
150
|
information.
|
126
151
|
|
127
|
-
|
152
|
+
## 0.1.1 - 28-Mar-2007
|
128
153
|
* Bug fix for BSD flavors. Thanks go to Jeremy Kemper and Ole Christian
|
129
154
|
Rynning for the spot.
|
130
155
|
* Bug fix for OS X (along the same lines as the BSD fix). Thanks go to
|
@@ -133,5 +158,5 @@
|
|
133
158
|
* Tweaks to the gemspec.
|
134
159
|
* Added synopsis to the README.
|
135
160
|
|
136
|
-
|
161
|
+
## 0.1.0 - 17-Nov-2006
|
137
162
|
* Initial release. Alpha. Code is stable, but API is not.
|
data/Gemfile
ADDED
@@ -1,10 +1,12 @@
|
|
1
|
-
* CHANGES.
|
1
|
+
* CHANGES.md
|
2
|
+
* Gemfile
|
2
3
|
* LICENSE
|
3
|
-
* MANIFEST.
|
4
|
+
* MANIFEST.md
|
4
5
|
* Rakefile
|
5
|
-
* README.
|
6
|
+
* README.md
|
6
7
|
* sys-fileystem.gemspec
|
7
8
|
* certs/djberg96_pub.pem
|
9
|
+
* examples/example_mount.rb
|
8
10
|
* examples/example_stat.rb
|
9
11
|
* lib/sys-filesystem.rb
|
10
12
|
* lib/sys/filesystem.rb
|
@@ -16,6 +18,6 @@
|
|
16
18
|
* lib/sys/windows/sys/filesystem/constants.rb
|
17
19
|
* lib/sys/windows/sys/filesystem/functions.rb
|
18
20
|
* lib/sys/windows/sys/filesystem/helper.rb
|
19
|
-
*
|
20
|
-
*
|
21
|
-
*
|
21
|
+
* spec/spec_helper.rb
|
22
|
+
* spec/sys_filesystem_unix_spec.rb
|
23
|
+
* spec/sys_filesystem_windows_spec.rb
|
data/README.md
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
[](https://github.com/djberg96/sys-filesystem/actions/workflows/ruby.yml)
|
2
|
+
|
3
|
+
## Description
|
4
|
+
|
5
|
+
A cross platform Ruby interface for getting file system information.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
`gem install sys-filesystem`
|
10
|
+
|
11
|
+
## Adding the trusted cert
|
12
|
+
`gem cert --add <(curl -Ls https://raw.githubusercontent.com/djberg96/sys-filesystem/main/certs/djberg96_pub.pem)`
|
13
|
+
|
14
|
+
## Synopsis
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
require 'sys/filesystem'
|
18
|
+
include Sys
|
19
|
+
|
20
|
+
# Display information about a particular filesystem.
|
21
|
+
p Filesystem.stat('/')
|
22
|
+
|
23
|
+
# Sample output
|
24
|
+
|
25
|
+
#<Sys::Filesystem::Stat:0x517440
|
26
|
+
@base_type = "ufs",
|
27
|
+
@flags = 4,
|
28
|
+
@files_available = 3817457,
|
29
|
+
@block_size = 8192,
|
30
|
+
@blocks_available = 19957633,
|
31
|
+
@blocks = 34349612,
|
32
|
+
@name_max = 255,
|
33
|
+
@path = "/",
|
34
|
+
@filesystem_id = 35651592,
|
35
|
+
@files = 4135040,
|
36
|
+
@fragment_size = 1024,
|
37
|
+
@files_free = 3817457,
|
38
|
+
@blocks_free = 20301129
|
39
|
+
>
|
40
|
+
|
41
|
+
# Describe all mount points on the system
|
42
|
+
Filesystem.mounts{ |mount| p mount }
|
43
|
+
|
44
|
+
# Find the mount point of any particular file
|
45
|
+
puts Filesystem.mount_point('/home/djberge/some_file.txt') => '/home'
|
46
|
+
```
|
47
|
+
|
48
|
+
## Notes
|
49
|
+
|
50
|
+
This is a pure Ruby implementation that uses FFI. This means it should work
|
51
|
+
with JRuby, too.
|
52
|
+
|
53
|
+
## Sample code
|
54
|
+
|
55
|
+
Run 'rake example' if you want to see a basic sample run. The actual code
|
56
|
+
is 'example_stat.rb' in the 'examples' directory. Modify it as you see fit.
|
57
|
+
|
58
|
+
## Known Bugs
|
59
|
+
|
60
|
+
None that I'm aware of. Please report bugs on the project page at:
|
61
|
+
|
62
|
+
https://github.com/djberg96/sys-filesystem
|
63
|
+
|
64
|
+
## Future Plans
|
65
|
+
|
66
|
+
* Add better 64-bit support for Linux and BSD.
|
67
|
+
* Other suggestions welcome.
|
68
|
+
|
69
|
+
## Acknowledgements
|
70
|
+
|
71
|
+
* Mike Hall, for ideas and code that I borrowed from his 'filesystem' library.
|
72
|
+
* Park Heesob, for implementation and API ideas for the MS Windows version.
|
73
|
+
* Nobuyoshi Miyokawa, for adding the original FreeBSD and OS X support.
|
74
|
+
|
75
|
+
## License
|
76
|
+
|
77
|
+
Apache-2.0
|
78
|
+
|
79
|
+
## Copyright
|
80
|
+
|
81
|
+
(C) 2003-2020 Daniel J. Berger
|
82
|
+
All Rights Reserved
|
83
|
+
|
84
|
+
## Warranty
|
85
|
+
|
86
|
+
This library is provided "as is" and without any express or
|
87
|
+
implied warranties, including, without limitation, the implied
|
88
|
+
warranties of merchantability and fitness for a particular purpose.
|
89
|
+
|
90
|
+
## Author
|
91
|
+
|
92
|
+
Daniel J. Berger
|
data/Rakefile
CHANGED
@@ -1,34 +1,16 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'rake/clean'
|
3
|
-
require '
|
3
|
+
require 'rspec/core/rake_task'
|
4
4
|
|
5
|
-
CLEAN.include('**/*.gem', '**/*.rbc', '**/*.rbx')
|
6
|
-
|
7
|
-
desc "Run the test suite"
|
8
|
-
Rake::TestTask.new("test") do |t|
|
9
|
-
if File::ALT_SEPARATOR
|
10
|
-
t.libs << 'lib/windows'
|
11
|
-
else
|
12
|
-
t.libs << 'lib/unix'
|
13
|
-
end
|
14
|
-
|
15
|
-
t.warning = true
|
16
|
-
t.verbose = true
|
17
|
-
t.test_files = FileList['test/test_sys_filesystem.rb']
|
18
|
-
end
|
19
|
-
|
20
|
-
desc "Run the example program"
|
21
|
-
task :example do |t|
|
22
|
-
sh "ruby -Ilib -Ilib/unix -Ilib/windows examples/example_stat.rb"
|
23
|
-
end
|
5
|
+
CLEAN.include('**/*.gem', '**/*.rbc', '**/*.rbx', '**/*.lock')
|
24
6
|
|
25
7
|
namespace :gem do
|
26
8
|
desc "Build the sys-filesystem gem"
|
27
|
-
task :create => [:clean] do
|
9
|
+
task :create => [:clean] do
|
28
10
|
require 'rubygems/package'
|
29
|
-
spec =
|
11
|
+
spec = Gem::Specification.load('sys-filesystem.gemspec')
|
30
12
|
spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
|
31
|
-
Gem::Package.build(spec
|
13
|
+
Gem::Package.build(spec)
|
32
14
|
end
|
33
15
|
|
34
16
|
desc "Install the sys-filesystem gem"
|
@@ -38,4 +20,12 @@ namespace :gem do
|
|
38
20
|
end
|
39
21
|
end
|
40
22
|
|
41
|
-
|
23
|
+
desc "Run the example program"
|
24
|
+
task :example do
|
25
|
+
sh "ruby -Ilib -Ilib/unix -Ilib/windows examples/example_stat.rb"
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "Run the test suite"
|
29
|
+
RSpec::Core::RakeTask.new(:spec)
|
30
|
+
|
31
|
+
task :default => :spec
|
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
@@ -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,27 @@ module Sys
|
|
7
7
|
|
8
8
|
ffi_lib FFI::Library::LIBC
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
def self.linux64?
|
11
|
+
if RUBY_PLATFORM == 'java'
|
12
|
+
ENV_JAVA['sun.arch.data.model'].to_i == 64
|
13
|
+
else
|
14
|
+
RbConfig::CONFIG['host_os'] =~ /linux/i &&
|
15
|
+
(RbConfig::CONFIG['arch'] =~ /64/ || RbConfig::CONFIG['DEFS'] =~ /64/)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private_class_method :linux64?
|
20
|
+
|
21
|
+
if RbConfig::CONFIG['host_os'] =~ /sunos|solaris/i
|
22
|
+
attach_function(:statvfs, :statvfs64, %i[string pointer], :int)
|
23
|
+
elsif linux64?
|
24
|
+
attach_function(:statvfs, :statvfs64, %i[string pointer], :int)
|
12
25
|
else
|
13
|
-
attach_function(:statvfs, [
|
26
|
+
attach_function(:statvfs, %i[string pointer], :int)
|
14
27
|
end
|
15
28
|
|
16
29
|
attach_function(:strerror, [:int], :string)
|
17
|
-
attach_function(:mount_c, :mount, [
|
30
|
+
attach_function(:mount_c, :mount, %i[string string string ulong string], :int)
|
18
31
|
|
19
32
|
begin
|
20
33
|
attach_function(:umount_c, :umount, [:string], :int)
|
@@ -28,22 +41,26 @@ module Sys
|
|
28
41
|
|
29
42
|
begin
|
30
43
|
if RbConfig::CONFIG['host_os'] =~ /sunos|solaris/i
|
31
|
-
attach_function(:fopen, [
|
44
|
+
attach_function(:fopen, %i[string string], :pointer)
|
32
45
|
attach_function(:fclose, [:pointer], :int)
|
33
|
-
attach_function(:getmntent, [
|
46
|
+
attach_function(:getmntent, %i[pointer pointer], :int)
|
34
47
|
private_class_method :fopen, :fclose, :getmntent
|
35
48
|
else
|
36
49
|
attach_function(:getmntent, [:pointer], :pointer)
|
37
|
-
attach_function(:setmntent, [
|
50
|
+
attach_function(:setmntent, %i[string string], :pointer)
|
38
51
|
attach_function(:endmntent, [:pointer], :int)
|
39
|
-
attach_function(:umount2, [
|
52
|
+
attach_function(:umount2, %i[string int], :int)
|
40
53
|
private_class_method :getmntent, :setmntent, :endmntent, :umount2
|
41
54
|
end
|
42
55
|
rescue FFI::NotFoundError
|
43
56
|
if RbConfig::CONFIG['host_os'] =~ /darwin|osx|mach/i
|
44
|
-
|
57
|
+
begin
|
58
|
+
attach_function(:getmntinfo, :getmntinfo64, %i[pointer int], :int)
|
59
|
+
rescue FFI::NotFoundError
|
60
|
+
attach_function(:getmntinfo, %i[pointer int], :int) # Big Sur and later
|
61
|
+
end
|
45
62
|
else
|
46
|
-
attach_function(:getmntinfo, [
|
63
|
+
attach_function(:getmntinfo, %i[pointer int], :int)
|
47
64
|
end
|
48
65
|
private_class_method :getmntinfo
|
49
66
|
end
|
@@ -6,6 +6,17 @@ module Sys
|
|
6
6
|
module Structs
|
7
7
|
class Statfs < FFI::Struct
|
8
8
|
|
9
|
+
def self.linux64?
|
10
|
+
if RUBY_PLATFORM == 'java'
|
11
|
+
ENV_JAVA['sun.arch.data.model'].to_i == 64
|
12
|
+
else
|
13
|
+
RbConfig::CONFIG['host_os'] =~ /linux/i &&
|
14
|
+
(RbConfig::CONFIG['arch'] =~ /64/ || RbConfig::CONFIG['DEFS'] =~ /64/)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private_class_method :linux64?
|
19
|
+
|
9
20
|
# FreeBSD 12.0 MNAMELEN from 88 => 1024.
|
10
21
|
MNAMELEN =
|
11
22
|
if RbConfig::CONFIG['host_os'] =~ /freebsd(.*)/i
|
@@ -40,20 +51,37 @@ module Sys
|
|
40
51
|
:f_mntonname, [:char, MNAMELEN]
|
41
52
|
)
|
42
53
|
elsif RbConfig::CONFIG['host_os'] =~ /linux/i
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
if linux64?
|
55
|
+
layout(
|
56
|
+
:f_type, :ulong,
|
57
|
+
:f_bsize, :ulong,
|
58
|
+
:f_blocks, :uint64,
|
59
|
+
:f_bfree, :uint64,
|
60
|
+
:f_bavail, :uint64,
|
61
|
+
:f_files, :uint64,
|
62
|
+
:f_ffree, :uint64,
|
63
|
+
:f_fsid, [:int, 2],
|
64
|
+
:f_namelen, :ulong,
|
65
|
+
:f_frsize, :ulong,
|
66
|
+
:f_flags, :ulong,
|
67
|
+
:f_spare, [:ulong, 4]
|
68
|
+
)
|
69
|
+
else
|
70
|
+
layout(
|
71
|
+
:f_type, :ulong,
|
72
|
+
:f_bsize, :ulong,
|
73
|
+
:f_blocks, :uint32,
|
74
|
+
:f_bfree, :uint32,
|
75
|
+
:f_bavail, :uint32,
|
76
|
+
:f_files, :uint32,
|
77
|
+
:f_ffree, :uint32,
|
78
|
+
:f_fsid, [:int, 2],
|
79
|
+
:f_namelen, :ulong,
|
80
|
+
:f_frsize, :ulong,
|
81
|
+
:f_flags, :ulong,
|
82
|
+
:f_spare, [:ulong, 4]
|
83
|
+
)
|
84
|
+
end
|
57
85
|
else
|
58
86
|
layout(
|
59
87
|
:f_bsize, :uint32,
|
@@ -123,6 +151,22 @@ module Sys
|
|
123
151
|
:f_fstr, [:char, 32],
|
124
152
|
:f_filler, [:ulong, 16]
|
125
153
|
)
|
154
|
+
elsif RbConfig::CONFIG['host'] =~ /i686/i
|
155
|
+
layout(
|
156
|
+
:f_bsize, :ulong,
|
157
|
+
:f_frsize, :ulong,
|
158
|
+
:f_blocks, :uint,
|
159
|
+
:f_bfree, :uint,
|
160
|
+
:f_bavail, :uint,
|
161
|
+
:f_files, :uint,
|
162
|
+
:f_ffree, :uint,
|
163
|
+
:f_favail, :uint,
|
164
|
+
:f_fsid, :ulong,
|
165
|
+
:f_unused, :int,
|
166
|
+
:f_flag, :ulong,
|
167
|
+
:f_namemax, :ulong,
|
168
|
+
:f_spare, [:int, 6]
|
169
|
+
)
|
126
170
|
else
|
127
171
|
layout(
|
128
172
|
:f_bsize, :ulong,
|