Sha256: fbab511962333be283c07f9e3e95e59902e831807a5cbab87d1a562609a22c64

Contents?: true

Size: 2 KB

Versions: 3

Compression:

Stored size: 2 KB

Contents

# frozen_string_literal: true

require 'ffi'
require_relative('accessors')

module FFI
  # Represents Statvfs for use with {Libfuse::FuseOperations#statfs} callback
  class StatVfs < Struct
    include Accessors

    case Platform::NAME
    when /darwin/
      layout(
        f_bsize: :ulong,
        f_frsize: :ulong,
        f_blocks: :uint,
        f_bfree: :uint,
        f_bavail: :uint,
        f_files: :uint,
        f_ffree: :uint,
        f_favail: :uint,
        f_fsid: :ulong,
        f_flag: :ulong,
        f_namemax: :ulong
      )
    when /linux/
      layout(
        :f_bsize, :ulong,
        :f_frsize, :ulong,
        :f_blocks, :uint64,
        :f_bfree, :uint64,
        :f_bavail, :uint64,
        :f_files, :uint64,
        :f_ffree, :uint64,
        :f_favail, :uint64,
        :f_fsid, :ulong,
        :f_flag, :ulong,
        :f_namemax, :ulong,
        :f_spare, [:int, 6]
      )
    else
      raise NotImplementedError, "FFI::StatVfs not implemented for FFI::Platform #{Platform::NAME}"
    end

    # @!attribute [rw] bsize
    #  @return [Integer] Filesystem block size

    # @!attribute [rw] frsize
    #  @return [Integer] Fragment size

    # @!attribute [rw] blocks
    #  @return [Integer] Size of fs in frsize units

    # @!attribute [rw] bfree
    #  @return [Integer] Number of free blocks

    # @!attribute [rw] bavail
    #  @return [Integer] Number of free blocks for unprivileged users

    # @!attribute [rw] files
    #  @return [Integer] Number of inodes

    # @!attribute [rw] ffree
    #  @return [Integer] Number of free inodes

    # @!attribute [rw] favail
    #  @return [Integer] Number of free inodes for unprivileged users

    # @!attribute [rw] fsid
    #  @return [Integer] Filesystem ID

    # @!attribute [rw] flag
    #  @return [Integer] Mount flags

    # @!attribute [rw] namemax
    #  @return [Integer] Maximum filename length

    int_members = members.select { |m| m =~ /^f_/ }.map { |m| m[2..].to_sym }
    ffi_attr_accessor(*int_members, format: 'f_%s')
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ffi-libfuse-0.0.1.rctest12 lib/ffi/stat_vfs.rb
ffi-libfuse-0.0.1.rctest11 lib/ffi/stat_vfs.rb
ffi-libfuse-0.0.1.pre lib/ffi/stat_vfs.rb