aboutsummaryrefslogtreecommitdiffstats
path: root/lib/raw_format.py
diff options
context:
space:
mode:
authorPapoteur <papoteur@mageia.org>2020-10-17 21:28:03 +0200
committerPapoteur <papoteur@mageia.org>2020-10-17 21:28:03 +0200
commit7f2e0a02d85653ddad81cfeb8f7594307ef424fc (patch)
treeb71b077f0bdc9b35d66f4e5564d076e9210c6eed /lib/raw_format.py
parent87b1516092e1ad508c9af51d07e71ffa3f425a1b (diff)
downloadisodumper-7f2e0a02d85653ddad81cfeb8f7594307ef424fc.tar
isodumper-7f2e0a02d85653ddad81cfeb8f7594307ef424fc.tar.gz
isodumper-7f2e0a02d85653ddad81cfeb8f7594307ef424fc.tar.bz2
isodumper-7f2e0a02d85653ddad81cfeb8f7594307ef424fc.tar.xz
isodumper-7f2e0a02d85653ddad81cfeb8f7594307ef424fc.zip
Use udisks to unmount partitions before formatting
Diffstat (limited to 'lib/raw_format.py')
-rwxr-xr-xlib/raw_format.py33
1 files changed, 0 insertions, 33 deletions
diff --git a/lib/raw_format.py b/lib/raw_format.py
index b3bdb42..bf57ba5 100755
--- a/lib/raw_format.py
+++ b/lib/raw_format.py
@@ -29,41 +29,8 @@ from subprocess import call
sys.path.append('/usr/lib/isodumper')
-
-def do_umount(target):
- mounts = get_mounted(target)
- if mounts:
- print('Unmounting all partitions of ' + target + ':')
- for mount in mounts:
- print('Trying to unmount ' + mount[0] + '...')
- try:
- retcode = call('umount ' + mount[0], shell=True)
- if retcode < 0:
- print('Error, umount ' + mount[0] + ' was terminated by signal ' + str(retcode))
- sys.exit(6)
- else:
- if retcode == 0:
- print(mount[0] + ' successfully unmounted')
- else:
- print('Error, umount ' + mount[0] + ' returned ' + str(retcode))
- sys.exit(6)
- except OSError as e:
- print('Execution failed: ' + str(e))
- sys.exit(6)
-
-
-def get_mounted(target):
- try:
- lines = [line.strip("\n").split(" ") for line in open("/etc/mtab", "r").readlines()]
- return [mount for mount in lines if mount[0].startswith(target)]
- except:
- print('Could not read mtab !')
- sys.exit(6)
-
-
def raw_format(device_path, fstype, volume_label, uid, gid):
import parted
- do_umount(device_path)
# First erase MBR and partition table , if any
call(["dd", "if=/dev/zero", "of=%s" % device_path, "bs=512", "count=1"])