Class: FFI::StatVfs

Inherits:
Struct
  • Object
show all
Extended by:
Library
Includes:
Accessors
Defined in:
lib/ffi/stat_vfs.rb

Overview

Represents Statvfs for use with Libfuse::FuseOperations#statfs callback

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Accessors

#ffi_attr_fill, #ffi_attr_reader_member, #ffi_attr_writer_member, #fill, #inspect, #to_h

Methods included from Accessors::ClassMethods

#attr_accessor, #attr_reader, #attr_writer, #ffi_attr_accessor, #ffi_attr_reader, #ffi_attr_reader_method, #ffi_attr_readers, #ffi_attr_writer, #ffi_attr_writer_method, #ffi_attr_writers, #ffi_bitflag_accessor, #ffi_bitflag_reader, #ffi_bitflag_writer, #ffi_public_attr_readers, #ffi_public_attr_writers

Instance Attribute Details

#bavailInteger

Returns Number of free blocks for unprivileged users.

Returns:

  • (Integer)

    Number of free blocks for unprivileged users



# File 'lib/ffi/stat_vfs.rb', line 57

#bfreeInteger

Returns Number of free blocks.

Returns:

  • (Integer)

    Number of free blocks



# File 'lib/ffi/stat_vfs.rb', line 54

#blocksInteger

Returns Size of fs in frsize units.

Returns:

  • (Integer)

    Size of fs in frsize units



# File 'lib/ffi/stat_vfs.rb', line 51

#bsizeInteger

Returns Filesystem block size.

Returns:

  • (Integer)

    Filesystem block size



# File 'lib/ffi/stat_vfs.rb', line 45

#favailInteger

Returns Number of free inodes for unprivileged users.

Returns:

  • (Integer)

    Number of free inodes for unprivileged users



# File 'lib/ffi/stat_vfs.rb', line 66

#ffreeInteger

Returns Number of free inodes.

Returns:

  • (Integer)

    Number of free inodes



# File 'lib/ffi/stat_vfs.rb', line 63

#filesInteger

Returns Number of inodes.

Returns:

  • (Integer)

    Number of inodes



# File 'lib/ffi/stat_vfs.rb', line 60

#flagInteger

Returns Mount flags.

Returns:

  • (Integer)

    Mount flags



# File 'lib/ffi/stat_vfs.rb', line 72

#frsizeInteger

Returns Fragment size.

Returns:

  • (Integer)

    Fragment size



# File 'lib/ffi/stat_vfs.rb', line 48

#fsidInteger

Returns Filesystem ID.

Returns:

  • (Integer)

    Filesystem ID



# File 'lib/ffi/stat_vfs.rb', line 69

#namemaxInteger

Returns Maximum filename length.

Returns:

  • (Integer)

    Maximum filename length



78
# File 'lib/ffi/stat_vfs.rb', line 78

ffi_attr_accessor(**members.grep(/^f_/).to_h { |m| [m[2..].to_sym, m] })

Class Method Details

.from(file) ⇒ StatVfs

Returns:

Raises:

  • (SystemCallError)

See Also:



# File 'lib/ffi/stat_vfs.rb', line 116

.fstatvfs(file) ⇒ StatVfs

Returns:

Raises:

  • (SystemCallError)

See Also:



130
# File 'lib/ffi/stat_vfs.rb', line 130

%i[from statvfs fstatvfs].each { |m| define_method(m) { |file, stat = new, **args| stat.send(m, file, **args) } }

.statvfs(file) ⇒ StatVfs

Returns:

Raises:

  • (SystemCallError)

See Also:



# File 'lib/ffi/stat_vfs.rb', line 121

Instance Method Details

#from(file) ⇒ self

File from native LIBC calls for file

Parameters:

  • file (Integer|:to_s)

    a file descriptor or a file path

Returns:

  • (self)


109
110
111
112
113
# File 'lib/ffi/stat_vfs.rb', line 109

def from(file)
  return fstatvfs(file) if file.is_a?(Integer)

  statvfs(file)
end

#fstatvfs(fileno) ⇒ self

Fill from native fstatvfs for fileno

Parameters:

  • fileno (Integer)

Returns:

  • (self)

Raises:

  • (SystemCallError)


99
100
101
102
103
104
# File 'lib/ffi/stat_vfs.rb', line 99

def fstatvfs(fileno)
  res = self.class.native_fstatvfs(fileno, self)
  raise SystemCallError.new('', FFI::LastError.errno) unless res.zero?

  self
end

#statvfs(path) ⇒ self

Fill from native statvfs for path

Parameters:

  • path (:to_s)

Returns:

  • (self)

Raises:

  • (SystemCallError)


89
90
91
92
93
94
# File 'lib/ffi/stat_vfs.rb', line 89

def statvfs(path)
  res = self.class.native_statvfs(path.to_s, self)
  raise SystemCallError.new('', FFI::LastError.errno) unless res.zero?

  self
end