sys-filesystem 1.5.2 → 1.5.4

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
2
  SHA256:
3
- metadata.gz: 70493df8ed3722f3da6776ef9c1c287f992e9fcec64852e11b6fe04e64a7e73e
4
- data.tar.gz: 0c924d1aca503181261bdbd1b73ed2e20eecc55293cdff2a9c8b54465859e652
3
+ metadata.gz: 43744bef5f8edef84a4b282c900460fd5aefb7f2d9650e5259d5b0f8a8fae97a
4
+ data.tar.gz: 6eddc2f29fb509209addc117e4a9ad4ff80e64f11cb71b9db54672dfefeba4eb
5
5
  SHA512:
6
- metadata.gz: 827b599edce400ecb52221ab8d279269811f03beb9cc4440182334e5231426b75ca8b98addc10bfbdc2d1a45cc3a39ebb3d21a1f71e5f014d1053439845dd5a1
7
- data.tar.gz: d66206e8a76a5be307c71e01a57158a49381e7699dfda4e84364dd0a44e40f8345d7a8e9e33318a6fb20f864cfbb8d86d85972d7433398cdfd510aac3e23b443
6
+ metadata.gz: 59800ffa5e85934f3cc4f360c6cde04168deb1d9b5790750f8584332d2fba5bdf2c8019d1e05261bd3ac71858c3488c8d80a65c2cf4fc4fb2c6db6e032cf2461
7
+ data.tar.gz: 001fb9676236d2916836e4690cfdaa8bfb838328c43e1c31fa07669f3da4bba3e814a35cc55122ca825fd7c22c90e24d8ea385bc3d9c70548363b8cfa4594def
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGES.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 1.5.4 - 7-Sep-2025
2
+ * Added a fallback check for 64-bit Linux in case the config info doesn't
3
+ include "64" anywhere in it. Thanks go to Chris Hofstaedtler for the
4
+ report.
5
+
6
+ ## 1.5.3 - 3-Oct-2024
7
+ * Decided to unroll the changes in 1.5.2 because doing runtime compiler
8
+ checks was making more people unhappy than happy, and I already had
9
+ some misgivings about it.
10
+ * Updated the README.md to note the issues with running 32-bit Ruby with
11
+ 64-bit offsets. At the moment I think this mainly only affects arch Linux.
12
+
1
13
  ## 1.5.2 - 30-Sep-2024
2
14
  * Forgot to switch mkmf-lite from a dev dependency to a runtime dependency.
3
15
  Thanks go to Thomas Langé for the spot and patch.
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 Bugs
58
+ ## Known Issues
59
59
 
60
- None that I'm aware of. Please report bugs on the project page at:
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
- * Add better 64-bit support for Linux and BSD.
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-2024 Daniel J. Berger
84
+ (C) 2003-2025 Daniel J. Berger
82
85
  All Rights Reserved
83
86
 
84
87
  ## Warranty
data/Rakefile CHANGED
@@ -39,7 +39,10 @@ namespace :rubocop do
39
39
  end
40
40
 
41
41
  desc "Run the test suite"
42
- RSpec::Core::RakeTask.new(:spec)
42
+ RSpec::Core::RakeTask.new(:spec) do |t|
43
+ t.verbose = false
44
+ t.rspec_opts = '-f documentation'
45
+ end
43
46
 
44
47
  # Clean up afterwards
45
48
  Rake::Task[:spec].enhance do
@@ -16,7 +16,7 @@ module Sys
16
16
  # return objects of other types. Do not instantiate.
17
17
  class Filesystem
18
18
  # The version of the sys-filesystem library
19
- VERSION = '1.5.2'
19
+ VERSION = '1.5.4'
20
20
 
21
21
  # Stat objects are returned by the Sys::Filesystem.stat method. Here
22
22
  # we're adding universal methods.
@@ -16,7 +16,7 @@ module Sys
16
16
  ENV_JAVA['sun.arch.data.model'].to_i == 64
17
17
  else
18
18
  RbConfig::CONFIG['host_os'] =~ /linux/i &&
19
- (RbConfig::CONFIG['arch'] =~ /64/ || RbConfig::CONFIG['DEFS'] =~ /64/)
19
+ (RbConfig::CONFIG['arch'] =~ /64/ || RbConfig::CONFIG['DEFS'] =~ /64/ || [nil].pack('P').size == 8)
20
20
  end
21
21
  end
22
22
 
@@ -28,7 +28,7 @@ module Sys
28
28
  ENV_JAVA['sun.arch.data.model'].to_i == 64
29
29
  else
30
30
  RbConfig::CONFIG['host_os'] =~ /linux/i &&
31
- (RbConfig::CONFIG['arch'] =~ /64/ || RbConfig::CONFIG['DEFS'] =~ /64/)
31
+ (RbConfig::CONFIG['arch'] =~ /64/ || RbConfig::CONFIG['DEFS'] =~ /64/ || [nil].pack('P').size == 8)
32
32
  end
33
33
  end
34
34
 
@@ -155,7 +155,7 @@ module Sys
155
155
  ENV_JAVA['sun.arch.data.model'].to_i == 64
156
156
  else
157
157
  RbConfig::CONFIG['host_os'] =~ /linux/i &&
158
- (RbConfig::CONFIG['arch'] =~ /64/ || RbConfig::CONFIG['DEFS'] =~ /64/)
158
+ (RbConfig::CONFIG['arch'] =~ /64/ || RbConfig::CONFIG['DEFS'] =~ /64/ || [nil].pack('P').size == 8)
159
159
  end
160
160
  end
161
161
 
@@ -227,9 +227,7 @@ module Sys
227
227
  :f_spare, [:int, 5]
228
228
  )
229
229
  else
230
- require 'mkmf-lite'
231
- extend Mkmf::Lite
232
- layout_array = [
230
+ layout(
233
231
  :f_bsize, :ulong,
234
232
  :f_frsize, :ulong,
235
233
  :f_blocks, :uint64,
@@ -243,16 +241,7 @@ module Sys
243
241
  :f_namemax, :ulong,
244
242
  :f_type, :uint,
245
243
  :f_spare, [:int, 5]
246
- ]
247
-
248
- # Check if we need to add __f_unused
249
- f_unused_bytes = 2 * check_sizeof('int') - check_sizeof('long')
250
- if f_unused_bytes > 0
251
- # For Big Endian, this should be inserted at -9
252
- layout_array.insert(-7, :__f_unused, [:char, f_unused_bytes])
253
- end
254
-
255
- layout(*layout_array)
244
+ )
256
245
  end
257
246
  end
258
247
 
@@ -4,7 +4,7 @@ require 'sys-filesystem'
4
4
 
5
5
  RSpec.shared_examples Sys::Filesystem do
6
6
  example 'version number is set to the expected value' do
7
- expect(Sys::Filesystem::VERSION).to eq('1.5.2')
7
+ expect(Sys::Filesystem::VERSION).to eq('1.5.4')
8
8
  expect(Sys::Filesystem::VERSION).to be_frozen
9
9
  end
10
10
 
@@ -524,4 +524,218 @@ RSpec.describe Sys::Filesystem, :unix do
524
524
  expect(Sys::Filesystem::Functions.attached_functions[:statvfs64]).to be_nil
525
525
  end
526
526
  end
527
+
528
+ describe 'linux64? method' do
529
+ let(:functions_class) { Sys::Filesystem::Functions }
530
+
531
+ # Helper method to test linux64? with mocked config
532
+ def test_linux64_with_config(host_os, pointer_size, ruby_platform = nil, java_arch = nil)
533
+ # Mock RbConfig::CONFIG
534
+ allow(RbConfig::CONFIG).to receive(:[]).and_call_original
535
+ allow(RbConfig::CONFIG).to receive(:[]).with('host_os').and_return(host_os)
536
+
537
+ # When running under JRuby, we need to handle it differently
538
+ if RUBY_PLATFORM == 'java'
539
+ # Under JRuby, always mock ENV_JAVA since that's the path the code will take
540
+ if java_arch
541
+ # This is a JRuby-specific test
542
+ allow(ENV_JAVA).to receive(:[]).with('sun.arch.data.model').and_return(java_arch.to_s)
543
+ else
544
+ # This is meant to test regular Ruby logic, but under JRuby we need to mock ENV_JAVA
545
+ # to make it take the "regular Ruby" path by returning nil/empty
546
+ expected_arch = pointer_size == 8 ? '64' : '32'
547
+ allow(ENV_JAVA).to receive(:[]).with('sun.arch.data.model').and_return(expected_arch)
548
+ end
549
+ else
550
+ # Running under regular Ruby
551
+ # Determine arch and DEFS based on host_os for the new multi-check approach
552
+ if pointer_size == 8
553
+ # For 64-bit systems, make arch contain "64"
554
+ arch_value = host_os.include?('64') ? host_os : host_os + '64'
555
+ defs_value = '-DSOMETHING=1'
556
+ else
557
+ # For 32-bit systems, ensure neither arch nor DEFS contain "64"
558
+ arch_value = host_os.gsub(/64/, '32')
559
+ defs_value = '-DSOMETHING=1'
560
+ end
561
+
562
+ allow(RbConfig::CONFIG).to receive(:[]).with('arch').and_return(arch_value)
563
+ allow(RbConfig::CONFIG).to receive(:[]).with('DEFS').and_return(defs_value)
564
+
565
+ if ruby_platform == 'java'
566
+ # Mock RUBY_PLATFORM for JRuby tests
567
+ stub_const('RUBY_PLATFORM', 'java')
568
+
569
+ # Mock ENV_JAVA for JRuby
570
+ env_java_mock = double('ENV_JAVA')
571
+ allow(env_java_mock).to receive(:[]).with('sun.arch.data.model').and_return(java_arch.to_s)
572
+ stub_const('ENV_JAVA', env_java_mock)
573
+ else
574
+ # Mock the pack method for regular Ruby (last resort check)
575
+ packed_data = 'x' * pointer_size
576
+ allow_any_instance_of(Array).to receive(:pack).with('P').and_return(packed_data)
577
+ end
578
+ end
579
+
580
+ functions_class.send(:linux64?)
581
+ end
582
+
583
+ context 'with different Linux distributions on 64-bit architectures' do
584
+ let(:linux_distros) do
585
+ {
586
+ 'x86_64-linux-gnu' => 'Ubuntu/Debian x86_64',
587
+ 'x86_64-pc-linux-gnu' => 'Generic x86_64 Linux',
588
+ 'aarch64-linux-gnu' => 'ARM64 (Raspberry Pi 4, AWS Graviton)',
589
+ 's390x-linux-gnu' => 'IBM Z mainframe',
590
+ 'powerpc64le-linux-gnu' => 'POWER8/9 little-endian',
591
+ 'powerpc64-linux-gnu' => 'POWER8/9 big-endian',
592
+ 'mips64el-linux-gnuabi64' => 'MIPS64 little-endian',
593
+ 'alpha-linux-gnu' => 'DEC Alpha',
594
+ 'sparc64-linux-gnu' => 'SPARC64',
595
+ 'riscv64-linux-gnu' => 'RISC-V 64-bit'
596
+ }
597
+ end
598
+
599
+ it 'returns true for 64-bit Linux systems' do
600
+ linux_distros.each do |host_os, description|
601
+ result = test_linux64_with_config(host_os, 8)
602
+ expect(result).to be_truthy, "Expected linux64? to return true for #{host_os} (#{description})"
603
+ end
604
+ end
605
+ end
606
+
607
+ context 'with different Linux distributions on 32-bit architectures' do
608
+ let(:linux_32bit_distros) do
609
+ {
610
+ 'i386-linux-gnu' => '32-bit x86',
611
+ 'i486-linux-gnu' => '32-bit x86',
612
+ 'i586-linux-gnu' => '32-bit x86',
613
+ 'i686-linux-gnu' => '32-bit x86',
614
+ 'arm-linux-gnueabihf' => 'ARM 32-bit hard-float',
615
+ 'armv7l-linux-gnueabihf' => 'ARMv7 32-bit',
616
+ 'mips-linux-gnu' => 'MIPS 32-bit',
617
+ 'mipsel-linux-gnu' => 'MIPS 32-bit little-endian',
618
+ 'powerpc-linux-gnu' => 'PowerPC 32-bit',
619
+ 's390-linux-gnu' => 'IBM S/390 32-bit'
620
+ }
621
+ end
622
+
623
+ it 'returns false for 32-bit Linux systems' do
624
+ linux_32bit_distros.each do |host_os, description|
625
+ result = test_linux64_with_config(host_os, 4)
626
+ expect(result).to be_falsey, "Expected linux64? to return false for #{host_os} (#{description})"
627
+ end
628
+ end
629
+ end
630
+
631
+ context 'with non-Linux operating systems' do
632
+ let(:non_linux_os) do
633
+ {
634
+ 'darwin21.6.0' => 'macOS',
635
+ 'freebsd13.1' => 'FreeBSD',
636
+ 'openbsd7.2' => 'OpenBSD',
637
+ 'netbsd9.3' => 'NetBSD',
638
+ 'dragonfly6.4' => 'DragonFlyBSD',
639
+ 'solaris2.11' => 'Solaris',
640
+ 'aix7.2.0.0' => 'AIX',
641
+ 'mingw32' => 'Windows MSYS2',
642
+ 'cygwin' => 'Cygwin'
643
+ }
644
+ end
645
+
646
+ it 'returns false for non-Linux systems regardless of architecture' do
647
+ non_linux_os.each do |host_os, description|
648
+ # Test both 32-bit and 64-bit scenarios
649
+ [4, 8].each do |pointer_size|
650
+ result = test_linux64_with_config(host_os, pointer_size)
651
+ expect(result).to be_falsey,
652
+ "Expected linux64? to return false for #{host_os} (#{description}) with #{pointer_size * 8}-bit pointers"
653
+ end
654
+ end
655
+ end
656
+ end
657
+
658
+ context 'with JRuby on different platforms' do
659
+ it 'returns true for 64-bit Linux on JRuby' do
660
+ result = test_linux64_with_config('x86_64-linux-gnu', nil, 'java', 64)
661
+ expect(result).to be_truthy
662
+ end
663
+
664
+ it 'returns false for 32-bit Linux on JRuby' do
665
+ result = test_linux64_with_config('i386-linux-gnu', nil, 'java', 32)
666
+ expect(result).to be_falsey
667
+ end
668
+
669
+ it 'returns false for non-Linux systems on JRuby' do
670
+ result = test_linux64_with_config('darwin21.6.0', nil, 'java', 64)
671
+ expect(result).to be_falsey
672
+ end
673
+ end
674
+
675
+ context 'edge cases' do
676
+ it 'handles case-insensitive Linux detection' do
677
+ ['LINUX-gnu', 'Linux-gnu', 'linux-GNU'].each do |host_os|
678
+ result = test_linux64_with_config(host_os, 8)
679
+ expect(result).to be_truthy, "Expected linux64? to handle case-insensitive matching for #{host_os}"
680
+ end
681
+ end
682
+
683
+ it 'handles partial Linux matches in host_os string' do
684
+ ['some-linux-variant', 'embedded-linux-system', 'custom-linux-build'].each do |host_os|
685
+ result = test_linux64_with_config(host_os, 8)
686
+ expect(result).to be_truthy, "Expected linux64? to match partial Linux strings for #{host_os}"
687
+ end
688
+ end
689
+ end
690
+
691
+ context 'multi-check priority order', unless: RUBY_PLATFORM == 'java' do
692
+ it 'uses arch check first when arch contains 64' do
693
+ allow(RbConfig::CONFIG).to receive(:[]).and_call_original
694
+ allow(RbConfig::CONFIG).to receive(:[]).with('host_os').and_return('x86_64-linux-gnu')
695
+ allow(RbConfig::CONFIG).to receive(:[]).with('arch').and_return('x86_64-linux')
696
+ allow(RbConfig::CONFIG).to receive(:[]).with('DEFS').and_return('')
697
+
698
+ # Should not need to call pack method since arch check succeeds
699
+ expect_any_instance_of(Array).not_to receive(:pack)
700
+
701
+ expect(functions_class.send(:linux64?)).to be_truthy
702
+ end
703
+
704
+ it 'uses DEFS check when arch does not contain 64 but DEFS does' do
705
+ allow(RbConfig::CONFIG).to receive(:[]).and_call_original
706
+ allow(RbConfig::CONFIG).to receive(:[]).with('host_os').and_return('special-linux-gnu')
707
+ allow(RbConfig::CONFIG).to receive(:[]).with('arch').and_return('special-linux')
708
+ allow(RbConfig::CONFIG).to receive(:[]).with('DEFS').and_return('-D__LP64__=1')
709
+
710
+ # Should not need to call pack method since DEFS check succeeds
711
+ expect_any_instance_of(Array).not_to receive(:pack)
712
+
713
+ expect(functions_class.send(:linux64?)).to be_truthy
714
+ end
715
+
716
+ it 'falls back to pack method when neither arch nor DEFS contain 64' do
717
+ allow(RbConfig::CONFIG).to receive(:[]).and_call_original
718
+ allow(RbConfig::CONFIG).to receive(:[]).with('host_os').and_return('custom-linux-gnu')
719
+ allow(RbConfig::CONFIG).to receive(:[]).with('arch').and_return('custom-linux')
720
+ allow(RbConfig::CONFIG).to receive(:[]).with('DEFS').and_return('-DSOMETHING=1')
721
+
722
+ # Should call pack method as last resort
723
+ allow_any_instance_of(Array).to receive(:pack).with('P').and_return('12345678')
724
+
725
+ expect(functions_class.send(:linux64?)).to be_truthy
726
+ end
727
+
728
+ it 'returns false when all checks fail on 32-bit' do
729
+ allow(RbConfig::CONFIG).to receive(:[]).and_call_original
730
+ allow(RbConfig::CONFIG).to receive(:[]).with('host_os').and_return('custom-linux-gnu')
731
+ allow(RbConfig::CONFIG).to receive(:[]).with('arch').and_return('custom-linux')
732
+ allow(RbConfig::CONFIG).to receive(:[]).with('DEFS').and_return('-DSOMETHING=1')
733
+
734
+ # Pack method returns 4 bytes (32-bit)
735
+ allow_any_instance_of(Array).to receive(:pack).with('P').and_return('1234')
736
+
737
+ expect(functions_class.send(:linux64?)).to be_falsey
738
+ end
739
+ end
740
+ end
527
741
  end
@@ -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.5.2'
5
+ spec.version = '1.5.4'
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,7 +13,7 @@ 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_dependency('mkmf-lite', '~> 0.7') unless Gem.win_platform?
16
+ spec.add_development_dependency('mkmf-lite', '~> 0.7') unless Gem.win_platform?
17
17
  spec.add_development_dependency('rake')
18
18
  spec.add_development_dependency('rspec', '~> 3.9')
19
19
  spec.add_development_dependency('rubocop')
@@ -31,7 +31,8 @@ Gem::Specification.new do |spec|
31
31
  'source_code_uri' => 'https://github.com/djberg96/sys-filesystem',
32
32
  'wiki_uri' => 'https://github.com/djberg96/sys-filesystem/wiki',
33
33
  'rubygems_mfa_required' => 'true',
34
- 'github_repo' => 'https://github.com/djberg96/sys-filesystem'
34
+ 'github_repo' => 'https://github.com/djberg96/sys-filesystem',
35
+ 'funding_uri' => 'https://github.com/sponsors/djberg96'
35
36
  }
36
37
 
37
38
  spec.description = <<-EOF
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,11 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sys-filesystem
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain:
11
10
  - |
@@ -35,7 +34,7 @@ cert_chain:
35
34
  ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
36
35
  WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
37
36
  -----END CERTIFICATE-----
38
- date: 2024-09-30 00:00:00.000000000 Z
37
+ date: 1980-01-02 00:00:00.000000000 Z
39
38
  dependencies:
40
39
  - !ruby/object:Gem::Dependency
41
40
  name: ffi
@@ -58,7 +57,7 @@ dependencies:
58
57
  - - "~>"
59
58
  - !ruby/object:Gem::Version
60
59
  version: '0.7'
61
- type: :runtime
60
+ type: :development
62
61
  prerelease: false
63
62
  version_requirements: !ruby/object:Gem::Requirement
64
63
  requirements:
@@ -165,7 +164,7 @@ metadata:
165
164
  wiki_uri: https://github.com/djberg96/sys-filesystem/wiki
166
165
  rubygems_mfa_required: 'true'
167
166
  github_repo: https://github.com/djberg96/sys-filesystem
168
- post_install_message:
167
+ funding_uri: https://github.com/sponsors/djberg96
169
168
  rdoc_options: []
170
169
  require_paths:
171
170
  - lib
@@ -180,8 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
179
  - !ruby/object:Gem::Version
181
180
  version: '0'
182
181
  requirements: []
183
- rubygems_version: 3.5.16
184
- signing_key:
182
+ rubygems_version: 3.6.9
185
183
  specification_version: 4
186
184
  summary: A Ruby interface for getting file system information.
187
185
  test_files:
metadata.gz.sig CHANGED
Binary file