Skip to content

Commit ad53f78

Browse files
authored
Merge pull request #67 from djberg96/statvs64_alias
Handle possibility that statvfs64 doesn't exist on 64-bit platforms
2 parents c8e4a14 + 5edf579 commit ad53f78

File tree

6 files changed

+17
-4
lines changed

6 files changed

+17
-4
lines changed

CHANGES.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.4.5 - 22-May-2024
2+
* Handle the possibility that a statvs64 alias may not exist on some Linux
3+
platforms. Thanks go to Antoine Martin for the report.
4+
15
## 1.4.4 - 12-Sep-2023
26
* Yet another fix for 32-bit vs 64-bit linux, specifically for the Statvfs
37
struct. Thanks go to Josh Cooper for the spot and the patch.

lib/sys/filesystem.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module Sys
1616
# return objects of other types. Do not instantiate.
1717
class Filesystem
1818
# The version of the sys-filesystem library
19-
VERSION = '1.4.4'
19+
VERSION = '1.4.5'
2020

2121
# Stat objects are returned by the Sys::Filesystem.stat method. Here
2222
# we're adding universal methods.

lib/sys/unix/sys/filesystem/functions.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ def self.solaris?
2727
private_class_method :linux64?
2828

2929
if linux64? || solaris?
30-
attach_function(:statvfs, :statvfs64, %i[string pointer], :int)
30+
begin
31+
attach_function(:statvfs, :statvfs64, %i[string pointer], :int)
32+
rescue FFI::NotFoundError # Not every Linux distro has an alias
33+
attach_function(:statvfs, %i[string pointer], :int)
34+
end
3135
else
3236
attach_function(:statvfs, %i[string pointer], :int)
3337
end

spec/sys_filesystem_shared.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
RSpec.shared_examples Sys::Filesystem do
66
example 'version number is set to the expected value' do
7-
expect(Sys::Filesystem::VERSION).to eq('1.4.4')
7+
expect(Sys::Filesystem::VERSION).to eq('1.4.5')
88
expect(Sys::Filesystem::VERSION).to be_frozen
99
end
1010

spec/sys_filesystem_unix_spec.rb

+5
Original file line numberDiff line numberDiff line change
@@ -503,5 +503,10 @@
503503
msg = 'statvfs() function failed: No such file or directory'
504504
expect{ described_class.stat('/whatever') }.to raise_error(Sys::Filesystem::Error, msg)
505505
end
506+
507+
example 'statvfs alias is used for statvfs64' do
508+
expect(Sys::Filesystem::Functions.attached_functions[:statvfs]).to be_a(FFI::Function)
509+
expect(Sys::Filesystem::Functions.attached_functions[:statvfs64]).to be_nil
510+
end
506511
end
507512
end

sys-filesystem.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ require 'rubygems'
22

33
Gem::Specification.new do |spec|
44
spec.name = 'sys-filesystem'
5-
spec.version = '1.4.4'
5+
spec.version = '1.4.5'
66
spec.author = 'Daniel J. Berger'
77
spec.email = '[email protected]'
88
spec.homepage = 'https://github.com/djberg96/sys-filesystem'

0 commit comments

Comments
 (0)