Module: LinuxStat::Mounts

Defined in:
lib/linux_stat/mounts.rb

Class Method Summary collapse

Class Method Details

.listObject

Reads /proc/mounts and returns list of devices.

It returns an Array. If the info isn’t available or /proc/mounts is not readable, it will return an empty Array.



8
9
10
# File 'lib/linux_stat/mounts.rb', line 8

def list
	mounts
end

.rootObject

Reads /proc/mounts and returns partition name of the device mounted at /.

It returns a String. But if the info isn’t available or /proc/mounts is not readable, it will return an empty frozen String.



16
17
18
# File 'lib/linux_stat/mounts.rb', line 16

def root
	find_root[0].to_s
end

.root_fsObject

Reads /proc/mounts and returns the file system of the device mounted at /.

It returns a String. But if the info isn’t available or /proc/mounts is not readable, it will return an empty frozen String.



24
25
26
# File 'lib/linux_stat/mounts.rb', line 24

def root_fs
	find_root[2].to_s
end

.root_mount_optionsObject

Reads /proc/mounts and returns the options used for mounting /.

It returns a String. But if the info isn’t available or /proc/mounts is not readable, it will return an empty frozen string.



32
33
34
# File 'lib/linux_stat/mounts.rb', line 32

def root_mount_options
	find_root[3].to_s
end

.tmpfsObject

Reads /proc/mounts and finds all tmpfs.

It returns a Hash But if the info isn’t available or /proc/mounts is not readable, it will return an empty Hash.



40
41
42
43
44
45
46
# File 'lib/linux_stat/mounts.rb', line 40

def tmpfs
	ret = {}
	mounts.each { |x|
		ret.merge!({x.split[1] => x}) if x.start_with?('tmpfs '.freeze)
	}
	ret
end