Method: LinuxStat::Filesystem.available
- Defined in:
- lib/linux_stat/filesystem.rb
.available(fs = ?..freeze) ⇒ Object
available(fs = ‘.’)
Where fs is the directory of the file system (like / or /tmp/ or /run/media/thumbdrive).
It returns the total free space in a disk in bytes.
It is to be noted that free is not same as available.
Available returns the size of free blocks for unpriviledged users.
If the stat can’t be acquired, this method will return an empty Hash.
94 95 96 97 98 99 |
# File 'lib/linux_stat/filesystem.rb', line 94 def available(fs = ?..freeze) s = stat_raw(fs) return nil if s.empty? s.default = 0 s[:block_size] * s[:block_avail_unpriv] end |