23 from builtins
import object
40 if input
and isinstance(input, str):
57 stat_res = os.statvfs(
'%s' % self.
mnt_pnt)
77 return "%s %s %s %s %s %s %s %s %s %s %s" % \
85 def get_mtab(mtab="/proc/mounts", vfstype=None):
86 global mtab_mtime, mtab_map
88 mtab_stat = os.stat(mtab)
89 if mtab_stat.st_mtime != mtab_mtime:
91 mtab_mtime = mtab_stat.st_mtime
96 return [ent
for ent
in mtab_map
if ent.mnt_type == vfstype]
108 mtab = [
MntEntObj(line)
for line
in f.read().split(
'\n')
if len(line) > 0]
114 '''What this function attempts to do is take a file and return:
115 - the device the file is on
116 - the path of the file relative to the device.
118 /boot/vmlinuz -> (/dev/sda3, /vmlinuz)
119 /boot/efi/efi/redhat/elilo.conf -> (/dev/cciss0, /elilo.conf)
120 /etc/fstab -> (/dev/sda4, /etc/fstab)
124 fname = os.path.realpath(fname)
129 mtab_dict[ent.mnt_dir] = ent.mnt_fsname
132 fdir = os.path.dirname(fname)
133 match = fdir
in mtab_dict
135 fdir = os.path.realpath(os.path.join(fdir, os.path.pardir))
136 match = fdir
in mtab_dict
139 if fdir != os.path.sep:
140 fname = fname[len(fdir):]
142 return (mtab_dict[fdir], fname)