Class: CzSystemInfo::Filesystem::Stat

Inherits:
Object
  • Object
show all
Defined in:
lib/cz_system_info/filesystem.rb

Overview

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

Constant Summary collapse

RDONLY =

Read-only filesystem

1
NOSUID =

Filesystem does not support suid or sgid semantics.

2
NOTRUNC =

Filesystem does not truncate file names longer than name_max.

3

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStat

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



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/cz_system_info/filesystem.rb', line 115

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

Instance Attribute Details

#base_typeObject

The filesystem type, e.g. UFS.



106
107
108
# File 'lib/cz_system_info/filesystem.rb', line 106

def base_type
  @base_type
end

#block_sizeObject

The preferred system block size.



73
74
75
# File 'lib/cz_system_info/filesystem.rb', line 73

def block_size
  @block_size
end

#blocksObject

The total number of fragment_size blocks in the filesystem.



79
80
81
# File 'lib/cz_system_info/filesystem.rb', line 79

def blocks
  @blocks
end

#blocks_availableObject

The number of free blocks available to unprivileged processes.



85
86
87
# File 'lib/cz_system_info/filesystem.rb', line 85

def blocks_available
  @blocks_available
end

#blocks_freeObject

The total number of free blocks in the filesystem.



82
83
84
# File 'lib/cz_system_info/filesystem.rb', line 82

def blocks_free
  @blocks_free
end

#filesObject Also known as: inodes

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



88
89
90
# File 'lib/cz_system_info/filesystem.rb', line 88

def files
  @files
end

#files_availableObject Also known as: inodes_available

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



94
95
96
# File 'lib/cz_system_info/filesystem.rb', line 94

def files_available
  @files_available
end

#files_freeObject Also known as: inodes_free

The total number of files/inodes on the filesystem.



91
92
93
# File 'lib/cz_system_info/filesystem.rb', line 91

def files_free
  @files_free
end

#filesystem_idObject

The filesystem identifier.



97
98
99
# File 'lib/cz_system_info/filesystem.rb', line 97

def filesystem_id
  @filesystem_id
end

#flagsObject

A bit mask of flags.



100
101
102
# File 'lib/cz_system_info/filesystem.rb', line 100

def flags
  @flags
end

#fragment_sizeObject

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



76
77
78
# File 'lib/cz_system_info/filesystem.rb', line 76

def fragment_size
  @fragment_size
end

#name_maxObject

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



103
104
105
# File 'lib/cz_system_info/filesystem.rb', line 103

def name_max
  @name_max
end

#pathObject

The path of the filesystem.



70
71
72
# File 'lib/cz_system_info/filesystem.rb', line 70

def path
  @path
end

Instance Method Details

#bytes_availableObject

Returns the amount of free space available to unprivileged processes.



142
143
144
# File 'lib/cz_system_info/filesystem.rb', line 142

def bytes_available
  blocks_available * fragment_size
end

#bytes_freeObject

Returns the total amount of free space on the partition.



137
138
139
# File 'lib/cz_system_info/filesystem.rb', line 137

def bytes_free
  blocks_free * fragment_size
end

#bytes_totalObject

Returns the total space on the partition.



132
133
134
# File 'lib/cz_system_info/filesystem.rb', line 132

def bytes_total
  blocks * fragment_size
end

#bytes_usedObject

Returns the total amount of used space on the partition.



147
148
149
# File 'lib/cz_system_info/filesystem.rb', line 147

def bytes_used
  bytes_total - bytes_free
end

#percent_usedObject

Returns the percentage of the partition that has been used.



152
153
154
# File 'lib/cz_system_info/filesystem.rb', line 152

def percent_used
  100 - (100.0 * bytes_free.to_f / bytes_total.to_f)
end