Module: Cloudscopes::StatFs

Defined in:
lib/cloudscopes/filesystem.rb

Defined Under Namespace

Modules: Lib Classes: Result

Class Method Summary collapse

Class Method Details

.statfs(path) ⇒ Object

Drives the interface to the C library, returns a StatFs::Result object to show filesystem information for the given path.



21
22
23
24
25
26
27
28
29
30
# File 'lib/cloudscopes/filesystem.rb', line 21

def self.statfs(path)
  output = FFI::MemoryPointer.new(128)
  begin
    error_code = Lib::statfs64(path, output)
    raise "statfs raised error #{error_code}" if error_code != 0
    return Result.new(*output[0].read_array_of_long(7))
  ensure
    output.free
  end
end