Fix getting filesystem mounts
This commit is contained in:
parent
7ee49db51e
commit
5ab16295e5
@ -27,12 +27,17 @@ class Volumes
|
|||||||
def get_mounts path=nil
|
def get_mounts path=nil
|
||||||
vols = []
|
vols = []
|
||||||
# get the volume of path, if path is nil returns all volumes
|
# get the volume of path, if path is nil returns all volumes
|
||||||
raw_df = Utils.popen_read("/bin/df", "-P", path, &:read)
|
|
||||||
raw_df.split("\n").each do |line|
|
args = %w[/bin/df -P]
|
||||||
case line
|
args << path if path
|
||||||
# regex matches: /dev/disk0s2 489562928 440803616 48247312 91% /
|
|
||||||
when /^(.*)\s+([0-9]+)\s+([0-9]+)\s+([0-9]+)\s+([0-9]{1,3}\%)\s+(.*)/
|
Utils.popen_read(*args) do |io|
|
||||||
vols << $6
|
io.each_line do |line|
|
||||||
|
case line.chomp
|
||||||
|
# regex matches: /dev/disk0s2 489562928 440803616 48247312 91% /
|
||||||
|
when /^(.*)\s+([0-9]+)\s+([0-9]+)\s+([0-9]+)\s+([0-9]{1,3}\%)\s+(.*)/
|
||||||
|
vols << $6
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return vols
|
return vols
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user