3 # This command is used by "make clean", so don't rely on ./configure
14 if command -v "$python"; then
15 exec "$python" "$0" "$@"
18 echo "error: unable to find suitable python executable; please report" 1>&2
22 from __future__ import absolute_import, print_function
23 from sys import stderr
24 import os.path, re, subprocess, sys
26 def mntent_unescape(x):
34 return unescapes.get(m.group(0))
35 return re.sub(r'(\\\\|\\011|\\012|\\040)', replacement, x)
37 targets = sys.argv[1:]
39 if not os.path.exists('/proc/mounts'):
40 print('No /proc/mounts; skipping mount cleanup in', repr(targets),
45 for target in targets:
46 if not os.path.isdir(target):
47 print(repr(target), 'is not a directory', file=stderr)
50 top = os.path.realpath(target)
51 proc_mounts = open('/proc/mounts', 'r')
52 for line in proc_mounts:
53 _, point, fstype, _ = line.split(' ', 3)
54 point = mntent_unescape(point)
55 if top == point or os.path.commonprefix((top + '/', point)) == top + '/':
56 if fstype.startswith('fuse'):
57 if subprocess.call(['fusermount', '-uz', point]) != 0:
60 if subprocess.call(['umount', '-l', point]) != 0: