in xar/deprecated/mount_xar.py [0:0]
def linux_mounts():
# On some systems, /etc/mtab is a symlink to /proc/mounts (which
# is symlink ot /proc/self/mounts). Avoid duplicates via
# realpath.
mounts = []
mounts_files = set(os.path.realpath(s) for s in ["/proc/mounts", "/etc/mtab"])
for filename in mounts_files:
fh = open(filename)
try:
for line in fh:
parts = line.rstrip().split()
devname, mountpath, fstype = parts[:3]
# mtab can be escaped; fix it up before calling
# umount. Details:
# https://gnu.org/software/libc/manual/html_node/mtab.html
# Note backslashes are just '\134' and not '\0134'
# - special case.
mountpath = mountpath.replace("\\134", "\\")
for ch in " \t\r\n":
mountpath = mountpath.replace("\\" + oct(ord(ch)), ch)
mounts.append((devname, mountpath, fstype))
finally:
fh.close()
return mounts