aboutsummaryrefslogtreecommitdiff
blob: 00c37ea5734d947da788aeeb65c02e5559bcea42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python
# vim: set sw=4 sts=4 et :
# Copyright: 2008 Gentoo Foundation
# Author(s): Nirbheek Chauhan <nirbheek.chauhan@gmail.com>
# License: GPL-2
#
# Immortal lh!
#

import re, subprocess
from autotua import const

def clean_mounts():
    # /proc/mounts is more reliable than mtab (which is what `mount` uses)
    mounts = open('/proc/mounts', 'r').read()
    regex = re.compile(r'%s/[^ ]+' % const.TMPDIR.replace(' ', r'\\040'))
    for mount in regex.findall(mounts):
        mount = mount.replace(r'\040(deleted)', '').replace(r'\040', ' ')
        subprocess.check_call('umount "%s"' % mount, shell=True)

print "ZOMG!@~: WE DIED. Cleaning up stuff..."
clean_mounts()