Merge pull request #1262 from techhat/master

Update mount.active with better file handle, remove more expensive call
This commit is contained in:
Jeff Schroeder 2012-05-11 07:29:45 -07:00
commit 248b0d326d

View File

@ -19,26 +19,19 @@ def active():
salt '*' mount.active salt '*' mount.active
''' '''
ret = {} ret = {}
for line in __salt__['cmd.run_stdout']('mount').split('\n'): with open('/proc/self/mountinfo') as fh:
comps = line.split() for line in fh:
if not len(comps) == 6: comps = line.split()
# Invalid entry device = comps[2].split(':')
continue ret[comps[4]] = {'mountid': comps[0],
ret[comps[2]] = {'device': comps[0], 'parentid': comps[1],
'fstype': comps[4], 'major': device[0],
'opts': comps[5][1:-1].split(',')} 'minor': device[1],
'root': comps[3],
# Fill in some blanks for extra device reporting 'opts': comps[5].split(','),
for line in open('/proc/self/mountinfo').readlines(): 'fstype': comps[7],
comps = line.split() 'device': comps[8],
device = comps[2].split(':') 'superopts': comps[9].split(',')}
ret[comps[4]]['mountid'] = comps[0]
ret[comps[4]]['parentid'] = comps[1]
ret[comps[4]]['major'] = device[0]
ret[comps[4]]['minor'] = device[1]
ret[comps[4]]['root'] = comps[3]
ret[comps[4]]['source'] = comps[8]
ret[comps[4]]['superopts'] = comps[9].split(',')
return ret return ret