class Sys::Filesystem::Stat

Stat objects are returned by the Sys::Filesystem.stat method.

Constants

NOSUID

Filesystem does not support suid or sgid semantics.

NOTRUNC

Filesystem does not truncate file names longer than name_max.

RDONLY

Read-only filesystem

Attributes

base_type[RW]

The filesystem type, e.g. UFS.

block_size[RW]

The preferred system block size.

blocks[RW]

The total number of fragment_size blocks in the filesystem.

blocks_available[RW]

The number of free blocks available to unprivileged processes.

blocks_free[RW]

The total number of free blocks in the filesystem.

files[RW]

The total number of files/inodes that can be created.

files_available[RW]

The number of free files/inodes available to unprivileged processes.

files_free[RW]

The total number of files/inodes on the filesystem.

filesystem_id[RW]

The filesystem identifier.

flags[RW]

A bit mask of flags.

fragment_size[RW]

The fragment size, i.e. fundamental filesystem block size.

inodes[RW]

The total number of files/inodes that can be created.

inodes_available[RW]

The number of free files/inodes available to unprivileged processes.

inodes_free[RW]

The total number of files/inodes on the filesystem.

name_max[RW]

The maximum length of a file name permitted on the filesystem.

path[RW]

The path of the filesystem.

Public Class Methods

new() click to toggle source

Creates a new Sys::Filesystem::Stat object. This is meant for internal use only. Do not instantiate directly.

# File lib/sys/unix/sys/filesystem.rb, line 111
def initialize
  @path             = nil
  @block_size       = nil
  @fragment_size    = nil
  @blocks           = nil
  @blocks_free      = nil
  @blocks_available = nil
  @files            = nil
  @files_free       = nil
  @files_available  = nil
  @filesystem_id    = nil
  @flags            = nil
  @name_max         = nil
  @base_type        = nil
end

Public Instance Methods

bytes_free() click to toggle source

Returns the total amount of free space on the partition.

# File lib/sys/unix/sys/filesystem.rb, line 133
def bytes_free
  blocks_available * block_size
end
bytes_total() click to toggle source

Returns the total space on the partition.

# File lib/sys/unix/sys/filesystem.rb, line 128
def bytes_total
  blocks * block_size
end
bytes_used() click to toggle source

Returns the total amount of used space on the partition.

# File lib/sys/unix/sys/filesystem.rb, line 138
def bytes_used
  bytes_total - bytes_free
end
percent_used() click to toggle source

Returns the percentage of the partition that has been used.

# File lib/sys/unix/sys/filesystem.rb, line 143
def percent_used
  100 - (100.0 * bytes_free.to_f / bytes_total.to_f)
end