sys-filesystem 1.1.6 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 819b6d21deb2c0e958a38ec3ba23f511e343286b
4
- data.tar.gz: d180ac914f02bde52231efe4cb903f00ca1f3173
2
+ SHA256:
3
+ metadata.gz: 3b00e624e22bd699630d63b34f90be7758f82630a069f7db2a61e2139cb55888
4
+ data.tar.gz: 59add440f0203bade0430b2acd410e785b4ab0de416f272755a72db9276aa767
5
5
  SHA512:
6
- metadata.gz: 85d89bbe808f6ec1259f686a5b762044b9e07a03db5cac98ba269dd1034b97d30d905fb5c709ddad3eb9b0c2122de7553404acc781522726bcfa78acf8c7ed2b
7
- data.tar.gz: 81adece28fb90a500819200c82d1a871f0fa238f1a020394db7defa35e1d8c73bced46da7bc98bc7b979ade3b85dea9960c2e12b03c5dc7ecd7512acd07cbbba
6
+ metadata.gz: eb24f3c965a15d090fd7fff5800cc4c1829a7ddc7f2cbc4e943bb7e57ae92749a6abfccfecd94e8522287e9700916fc22f57af164afa413459321fa9460ba9a3
7
+ data.tar.gz: d5d30e84e01f370ac62b77251f2c80c07964a99bebfa0cc30252237bc33830198d3a065c28a546c230327b1b951d45d95bc309f75276d17d7e1e8968ade216f2
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGES.md ADDED
@@ -0,0 +1,162 @@
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
27
+ * Properly include a LICENSE file as per the Apache-2.0 license.
28
+
29
+ ## 1.3.3 - 18-Feb-2020
30
+ * Linux now uses statvfs64 under the hood. This fixes a potential issue with
31
+ 32 bit systems. Thanks go to Tom Smyth for the spot.
32
+
33
+ ## 1.3.2 - 8-Dec-2019
34
+ * Renamed various text files to include .rdoc extension so that github renders
35
+ them nicely.
36
+
37
+ ## 1.3.1 - 15-Oct-2019
38
+ * Fixed a bug where the Statvfs and Statfs structs were not allocated properly
39
+ on Linux, which could cause issues. Thanks go to Daniele Orlandi for the spot.
40
+ * Added specs to ensure that the FFI struct size matches the C struct size.
41
+ This required adding mkmf-lite as a development dependency.
42
+ * Added a slightly more pessimistic version requirement for test-unit.
43
+
44
+ ## 1.3.0 - 3-Oct-2019
45
+ * Added the mount and umount singleton methods.
46
+ * Changed an internal class variable to a frozen constant.
47
+
48
+ ## 1.2.0 - 1-Jan-2019
49
+ * Changed the license to Apache-2.0.
50
+ * Added the case_sensitive? and case_insensitive? instance methods to the
51
+ Filesystem::Stat class.
52
+ * Refactored the Numeric helper methods into a single location.
53
+ * Fixed the deprecation warnings when running the tests on Windows.
54
+ * Added metadata to the gemspec.
55
+
56
+ ## 1.1.9 - 26-Jan-2018
57
+ * The bytes_free and bytes_total methods were updated to use the fragment size
58
+ instead of the block size. This fixes Macs using APFS, as well as Solaris 10.
59
+ Thanks go to Mikhail Vasin for the spot.
60
+ * Removed the code specific to FreeBSD 10, which was ultimately an attempt
61
+ to address the issue now resolved by the above change.
62
+ * Updated the cert again.
63
+
64
+ ## 1.1.8 - 2-Sep-2017
65
+ * The stat and mount_point methods now call to_s on the string argument
66
+ explicitly so that Pathname objects will now work with String#wincode.
67
+ * Updated some tests to avoid Fixnum warnings for Ruby 2.4.
68
+ * Updated the cert.
69
+
70
+ ## 1.1.7 - 1-Aug-2016
71
+ * Fixed an issue in the stat method for MS Windows where the blocks_avail
72
+ value was not correct. Thanks go to Maxime Lapointe for the spot.
73
+
74
+ ## 1.1.6 - 17-May-2016
75
+ * On versions that use setmntent or fopen, explicitly raise an error if
76
+ either of those calls return a null value.
77
+
78
+ ## 1.1.5 - 5-Dec-2015
79
+ * This gem is now signed.
80
+ * The gem related tasks in the Rakefile now assume Rubygems 2.x.
81
+ * Updates to the gemspec, added cert_chain, removed rubyforge_project.
82
+ * Internal reorganization, and use of relative_require as appropriate.
83
+ * Added a sys-filesystem.rb file for convenience.
84
+
85
+ ## 1.1.4 - 15-Mar-2015
86
+ * The File.mounts method no longer raises an error if a mount point
87
+ is not accessible. Thanks go to Michael Pope for the patch.
88
+ * Some internal code reorganization.
89
+
90
+ ## 1.1.3 - 1-Oct-2014
91
+ * Now ignores EPERM errors when trying to find the mount point for a path.
92
+ Thanks go to petersen for the patch.
93
+ * The Filesystem.stat method now defaults to using the root path on Windows
94
+ for volume information.
95
+
96
+ ## 1.1.2 - 9-May-2014
97
+ * Added the percent_used, bytes_total, bytes_free and bytes_used methods
98
+ to the Filesystem::Stat class. Thanks go to xanview for the suggestion.
99
+ * Changed File.exists? to File.exist? to avoid warnings in Ruby 2.1.x.
100
+ * The convenience methods to_mb, to_gb, etc, are now defined in Numeric
101
+ instead of Fixnum.
102
+ * Added the to_tb method for terabytes.
103
+ * Minor updates to the gem:create and gem:install Rake tasks.
104
+
105
+ ## 1.1.1 - 3-Oct-2013
106
+ * Solaris now always uses statvfs64 on Solaris for better 64-bit support.
107
+ Thanks go to Jeff Shantz for the spot.
108
+
109
+ ## 1.1.0 - 19-Jan-2013
110
+ * Converted the Windows source code to use FFI. Consequently, there is now
111
+ a single gem rather than separate gems for Windows and Unix.
112
+ * Revamped the Windows tests.
113
+
114
+ ## 1.0.0 - 11-Jan-2012
115
+ * Converted everything from C to FFI for the Unix flavors. The Windows
116
+ source code remains untouched.
117
+
118
+ ## 0.3.4 - 19-Nov-2010
119
+ * Fixed a bug where negative block counts were happening on very large
120
+ hard drives. Thanks go to Jonas Pfenniger for the spot.
121
+ * Refactored the clean task in the Rakefile.
122
+ * Some cosmetic source code changes.
123
+
124
+ ## 0.3.3 - 21-May-2010
125
+ * Added a workaround for the Sys::Filesystem#block_size member to deal with
126
+ a bug in OS X. Thanks go to Josh Pasqualetto for the spot.
127
+
128
+ ## 0.3.2 - 29-Dec-2009
129
+ * Source has been moved to github.
130
+ * Added the 'gem' task and removed build logic from the gemspec.
131
+ * Updated the install task.
132
+ * Minor correction to the manifest.
133
+ * Removed some junk build files that were inadvertently included in
134
+ the last gem.
135
+
136
+ ## 0.3.1 - 5-Aug-2009
137
+ * Now compatible with Ruby 1.9.x.
138
+ * Changed license to Artistic 2.0
139
+ * Updated the gemspec, including the explicit addition of a license and
140
+ test-unit as a development dependency, as well as an updated description.
141
+
142
+ ## 0.3.0 - 26-Feb-2009
143
+ * Added support for OS X and FreeBSD thanks to an awesome patch by Nobuyoshi
144
+ Miyokawa.
145
+ * Added the Filesystem.mount_point method that takes a file and returns
146
+ the mount point it's sitting on.
147
+
148
+ ## 0.2.0 - 30-Dec-2008
149
+ * Added the Filesystem.mounts method for iterating over mount or volume
150
+ information.
151
+
152
+ ## 0.1.1 - 28-Mar-2007
153
+ * Bug fix for BSD flavors. Thanks go to Jeremy Kemper and Ole Christian
154
+ Rynning for the spot.
155
+ * Bug fix for OS X (along the same lines as the BSD fix). Thanks go to
156
+ Aurelian Dehay for the spot.
157
+ * Some Rdoc improvements for the C extension.
158
+ * Tweaks to the gemspec.
159
+ * Added synopsis to the README.
160
+
161
+ ## 0.1.0 - 17-Nov-2006
162
+ * Initial release. Alpha. Code is stable, but API is not.
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
@@ -1,9 +1,12 @@
1
- * MANIFEST
2
- * CHANGES
1
+ * CHANGES.md
2
+ * Gemfile
3
+ * LICENSE
4
+ * MANIFEST.md
3
5
  * Rakefile
4
- * README
6
+ * README.md
5
7
  * sys-fileystem.gemspec
6
8
  * certs/djberg96_pub.pem
9
+ * examples/example_mount.rb
7
10
  * examples/example_stat.rb
8
11
  * lib/sys-filesystem.rb
9
12
  * lib/sys/filesystem.rb
@@ -15,6 +18,6 @@
15
18
  * lib/sys/windows/sys/filesystem/constants.rb
16
19
  * lib/sys/windows/sys/filesystem/functions.rb
17
20
  * lib/sys/windows/sys/filesystem/helper.rb
18
- * test/test_sys_filesystem.rb
19
- * test/test_sys_filesystem_unix
20
- * test/test_sys_filesystem_windows
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
+ [![Ruby](https://github.com/djberg96/sys-filesystem/actions/workflows/ruby.yml/badge.svg)](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 'rake/testtask'
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 |t|
9
+ task :create => [:clean] do
28
10
  require 'rubygems/package'
29
- spec = eval(IO.read('sys-filesystem.gemspec'))
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, true)
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
- task :default => :test
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
@@ -1,21 +1,26 @@
1
1
  -----BEGIN CERTIFICATE-----
2
- MIIDcDCCAligAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MREwDwYDVQQDDAhkamJl
2
+ MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MREwDwYDVQQDDAhkamJl
3
3
  cmc5NjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
4
- MB4XDTE1MDkwMjIwNDkxOFoXDTE2MDkwMTIwNDkxOFowPzERMA8GA1UEAwwIZGpi
4
+ MB4XDTE4MDMxODE1MjIwN1oXDTI4MDMxNTE1MjIwN1owPzERMA8GA1UEAwwIZGpi
5
5
  ZXJnOTYxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
6
- bTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMyTkvXqRp6hLs9eoJOS
7
- Hmi8kRYbq9Vkf15/hMxJpotYMgJVHHWrmDcC5Dye2PbnXjTkKf266Zw0PtT9h+lI
8
- S3ts9HO+vaCFSMwFFZmnWJSpQ3CNw2RcHxjWkk9yF7imEM8Kz9ojhiDXzBetdV6M
9
- gr0lV/alUr7TNVBDngbXEfTWscyXh1qd7xZ4EcOdsDktCe5G45N/o3662tPQvJsi
10
- FOF0CM/KuBsa/HL1/eoEmF4B3EKIRfTHrQ3hu20Kv3RJ88QM4ec2+0dd97uX693O
11
- zv6981fyEg+aXLkxrkViM/tz2qR2ZE0jPhHTREPYeMEgptRkTmWSKAuLVWrJEfgl
12
- DtkCAwEAAaN3MHUwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFEwe
13
- nn6bfJADmuIDiMSOzedOrL+xMB0GA1UdEQQWMBSBEmRqYmVyZzk2QGdtYWlsLmNv
14
- bTAdBgNVHRIEFjAUgRJkamJlcmc5NkBnbWFpbC5jb20wDQYJKoZIhvcNAQEFBQAD
15
- ggEBAHmNOCWoDVD75zHFueY0viwGDVP1BNGFC+yXcb7u2GlK+nEMCORqzURbYPf7
16
- tL+/hzmePIRz7i30UM//64GI1NLv9jl7nIwjhPpXpf7/lu2I9hOTsvwSumb5UiKC
17
- /sqBxI3sfj9pr79Wpv4MuikX1XPik7Ncb7NPsJPw06Lvyc3Hkg5X2XpPtLtS+Gr2
18
- wKJnmzb5rIPS1cmsqv0M9LPWflzfwoZ/SpnmhagP+g05p8bRNKjZSA2iImM/GyYZ
19
- EJYzxdPOrx2n6NYR3Hk+vHP0U7UBSveI6+qx+ndQYaeyCn+GRX2PKS9h66YF/Q1V
20
- tGSHgAmcLlkdGgan182qsE/4kKM=
6
+ bTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBALgfaroVM6CI06cxr0/h
7
+ A+j+pc8fgpRgBVmHFaFunq28GPC3IvW7Nvc3Y8SnAW7pP1EQIbhlwRIaQzJ93/yj
8
+ u95KpkP7tA9erypnV7dpzBkzNlX14ACaFD/6pHoXoe2ltBxk3CCyyzx70mTqJpph
9
+ 75IB03ni9a8yqn8pmse+s83bFJOAqddSj009sGPcQO+QOWiNxqYv1n5EHcvj2ebO
10
+ 6hN7YTmhx7aSia4qL/quc4DlIaGMWoAhvML7u1fmo53CYxkKskfN8MOecq2vfEmL
11
+ iLu+SsVVEAufMDDFMXMJlvDsviolUSGMSNRTujkyCcJoXKYYxZSNtIiyd9etI0X3
12
+ ctu0uhrFyrMZXCedutvXNjUolD5r9KGBFSWH1R9u2I3n3SAyFF2yzv/7idQHLJJq
13
+ 74BMnx0FIq6fCpu5slAipvxZ3ZkZpEXZFr3cIBtO1gFvQWW7E/Y3ijliWJS1GQFq
14
+ 058qERadHGu1yu1dojmFRo6W2KZvY9al2yIlbkpDrD5MYQIDAQABo3cwdTAJBgNV
15
+ HRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUFZsMapgzJimzsbaBG2Tm8j5e
16
+ AzgwHQYDVR0RBBYwFIESZGpiZXJnOTZAZ21haWwuY29tMB0GA1UdEgQWMBSBEmRq
17
+ YmVyZzk2QGdtYWlsLmNvbTANBgkqhkiG9w0BAQsFAAOCAYEAW2tnYixXQtKxgGXq
18
+ /3iSWG2bLwvxS4go3srO+aRXZHrFUMlJ5W0mCxl03aazxxKTsVVpZD8QZxvK91OQ
19
+ h9zr9JBYqCLcCVbr8SkmYCi/laxIZxsNE5YI8cC8vvlLI7AMgSfPSnn/Epq1GjGY
20
+ 6L1iRcEDtanGCIvjqlCXO9+BmsnCfEVehqZkQHeYczA03tpOWb6pon2wzvMKSsKH
21
+ ks0ApVdstSLz1kzzAqem/uHdG9FyXdbTAwH1G4ZPv69sQAFAOCgAqYmdnzedsQtE
22
+ 1LQfaQrx0twO+CZJPcRLEESjq8ScQxWRRkfuh2VeR7cEU7L7KqT10mtUwrvw7APf
23
+ DYoeCY9KyjIBjQXfbj2ke5u1hZj94Fsq9FfbEQg8ygCgwThnmkTrrKEiMSs3alYR
24
+ ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
25
+ WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
21
26
  -----END CERTIFICATE-----
@@ -0,0 +1,73 @@
1
+ ######################################################################
2
+ # example_mount.rb
3
+ #
4
+ # Example program that demonstrates the Filesystem.mount method.
5
+ # Simulates the `mount` command in ruby
6
+ ######################################################################
7
+ require 'optparse'
8
+
9
+ options = {:mount_options => []}
10
+
11
+ OptionParser.new do |opts|
12
+ opts.banner = "Usage: #$0 [-o options] [-t external_type] special node"
13
+
14
+ opts.on("-o=OPTIONS", "Set one or many mount options (comma delimited)") do |cli_opts|
15
+ options[:mount_options] += cli_opts.split(',')
16
+ end
17
+
18
+ opts.on("-r", "Set readonly flag") do
19
+ options[:read_only] = true
20
+ end
21
+
22
+ opts.on("-t=EXTERNAL_TYPE", "Set the filesystem type") do |type|
23
+ options[:type] = type
24
+ end
25
+
26
+ opts.on("-v", "--version", "Display version") do
27
+ options[:version] = true
28
+ end
29
+
30
+ opts.separator ""
31
+ opts.separator "Examples:"
32
+ opts.separator ""
33
+ opts.separator " NFS: ruby #$0 -t nfs 192.168.0.10:/var/nfs /mnt/nfs"
34
+ opts.separator ""
35
+ opts.separator " SMB: ruby #$0 -t cifs //192.168.0.10/share /mnt/smb/ -o username=user,password=pass,domain=example.com"
36
+ opts.separator ""
37
+ end.parse!
38
+
39
+ require 'sys/filesystem'
40
+ include Sys
41
+
42
+ if options[:version]
43
+ puts "Sys::Filesystem::VERSION: #{Filesystem::VERSION}"
44
+ exit
45
+ end
46
+
47
+ def die msg
48
+ warn msg
49
+ exit 1
50
+ end
51
+
52
+ mount_flags = options[:read_only] ? Filesystem::MNT_RDONLY : 0
53
+ mnt_path, mnt_point = ARGV[0,2]
54
+
55
+ case options[:type]
56
+ when "cifs"
57
+ # keep mnt_path as is
58
+ when "nfs"
59
+ host, path, err = mnt_path.split(":")
60
+
61
+ die "ERROR: mount_pount '#{mnt_path}' should only contain 1 ':'" if err
62
+
63
+ mnt_path = ":#{path}"
64
+ options[:mount_options] << "addr=#{host}"
65
+ else
66
+ die "ERROR: unknown mount type!"
67
+ end
68
+
69
+ Filesystem.mount mnt_path,
70
+ mnt_point,
71
+ options[:type],
72
+ mount_flags,
73
+ options[:mount_options].join(',')
@@ -15,6 +15,8 @@ puts "Block size: " + stat.block_size.to_s
15
15
  puts "Fragment size: " + stat.fragment_size.to_s
16
16
  puts "Blocks free: " + stat.blocks_free.to_s
17
17
  puts "Blocks available: " + stat.blocks_available.to_s
18
+ puts "Bytes free: " + stat.bytes_free.to_s
19
+ puts "Bytes available: " + stat.bytes_available.to_s
18
20
  puts "Files/Inodes: " + stat.files.to_s
19
21
  puts "Files/Inodes free: " + stat.files_free.to_s
20
22
  puts "Files/Inodes available: " + stat.files_available.to_s