3 # This cannot rely on bup-python because it runs during clean, and so
4 # it also needs to be compatible with Python 2 and 3.
6 import os.path, re, subprocess, sys
8 def mntent_unescape(x):
16 return unescapes.get(m.group(0))
17 return re.sub(r'(\\\\|\\011|\\012|\\040)', replacement, x)
19 targets = sys.argv[1:]
21 for target in targets:
22 if not os.path.isdir(target):
23 print >> sys.stderr, target, 'is not a directory'
26 top = os.path.realpath(target)
27 proc_mounts = open('/proc/mounts', 'r')
28 for line in proc_mounts:
29 _, point, fstype, _ = line.split(' ', 3)
30 point = mntent_unescape(point)
31 if top == point or os.path.commonprefix((top + '/', point)) == top + '/':
32 if fstype.startswith('fuse'):
33 if subprocess.call(['fusermount', '-uz', point]) != 0:
36 if subprocess.call(['umount', '-l', point]) != 0: