aboutsummaryrefslogtreecommitdiffstats
path: root/lib
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
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')
-rwxr-xr-xlib/isodumper.py2
-rwxr-xr-xlib/raw_format.py33
2 files changed, 2 insertions, 33 deletions
diff --git a/lib/isodumper.py b/lib/isodumper.py
index d8b4a8f..9b67c2f 100755
--- a/lib/isodumper.py
+++ b/lib/isodumper.py
@@ -275,6 +275,8 @@ class IsoDumper(object):
self.dialog.pollEvent()
def raw_format(self, usb_path, fstype, label):
+ self.u.do_unmount(usb_path)
+ self.udev_wait(_("unmounting"))
self.operation = True
if os.geteuid() > 0:
launcher = 'pkexec'
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"])