Merge lp:~xnox/usb-creator/wipeout into lp:usb-creator

Proposed by Dimitri John Ledkov on 2012-05-21
Status: Rejected
Rejected by: Dimitri John Ledkov on 2012-05-21
Proposed branch: lp:~xnox/usb-creator/wipeout
Merge into: lp:usb-creator
Diff against target: 57 lines (+20/-13)
2 files modified
bin/usb-creator-helper (+20/-9)
usbcreator/backends/udisks/backend.py (+0/-4)
To merge this branch: bzr merge lp:~xnox/usb-creator/wipeout
Reviewer Review Type Date Requested Status
usb-creator hackers 2012-05-21 Pending
Evan 2012-05-21 Pending
Review via email: mp+106592@code.launchpad.net

This proposal supersedes a proposal from 2012-05-21.

Description of the change

Merge a (modified) patch from bug #484252. This changes the format button to erase selected partition, instead of wiping the whole drive (potential data loss).

To post a comment you must log in.
Dimitri John Ledkov (xnox) wrote : Posted in a previous version of this proposal

* tested formatting with multi partition usb-stick
* tested booting created bootable usb using multi partitioned usb-stick

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/usb-creator-helper'
2--- bin/usb-creator-helper 2012-05-04 10:43:38 +0000
3+++ bin/usb-creator-helper 2012-05-21 08:57:17 +0000
4@@ -214,18 +214,29 @@
5 '/org/freedesktop/UDisks')
6 device = udisks.FindDeviceByDeviceFile(device, dbus_interface=DISKS_IFACE)
7 dev = bus.get_object(DISKS_IFACE, device)
8- # Use the disk if asked to format a partition.
9- if dev.Get(device, 'device-is-partition', dbus_interface=PROPS_IFACE):
10- device = dev.Get(device, 'partition-slave', dbus_interface=PROPS_IFACE)
11- dev = bus.get_object(DISKS_IFACE, device)
12- dev_file = dev.Get(device, 'device-file', dbus_interface=PROPS_IFACE)
13+
14 # TODO LOCK
15 unmount_all(device)
16- size = dev.Get(device, 'device-size', dbus_interface=PROPS_IFACE)
17- dev.PartitionTableCreate('mbr', [], dbus_interface=DEVICE_IFACE, timeout=600)
18- dev.PartitionCreate(0, size, '0x0c', '', ['boot'], [], 'vfat', [],
19- dbus_interface=DEVICE_IFACE)
20+ # Do NOT use the disk if asked to format a partition.
21+ # We still need to obtain the disk device name to zero out the MBR
22+ if dev.Get(device, 'device-is-partition', dbus_interface=PROPS_IFACE):
23+ # Create the partition
24+ dev.PartitionModify('0x0c', '', ['boot'], dbus_interface=DEVICE_IFACE)
25+ dev.FilesystemCreate('vfat', [], dbus_interface=DEVICE_IFACE)
26+
27+ # Get the master device
28+ device = dev.Get(device, 'partition-slave', dbus_interface=PROPS_IFACE)
29+ dev = bus.get_object(DISKS_IFACE, device)
30+ else:
31+ # Create a new partition table and a FAT partition.
32+ size = dev.Get(device, 'device-size', dbus_interface=PROPS_IFACE)
33+ dev.PartitionTableCreate('mbr', [], dbus_interface=DEVICE_IFACE,
34+ timeout=600)
35+ dev.PartitionCreate(0, size, '0x0c', '', ['boot'], [], 'vfat', [],
36+ dbus_interface=DEVICE_IFACE)
37+
38 # Zero out the MBR. Will require fancy privileges.
39+ dev_file = dev.Get(device, 'device-file', dbus_interface=PROPS_IFACE)
40 popen(['dd', 'if=/dev/zero', 'of=%s' % dev_file, 'bs=446', 'count=1'])
41 # TODO UNLOCK
42
43
44=== modified file 'usbcreator/backends/udisks/backend.py'
45--- usbcreator/backends/udisks/backend.py 2012-05-04 10:33:25 +0000
46+++ usbcreator/backends/udisks/backend.py 2012-05-21 08:57:17 +0000
47@@ -284,10 +284,6 @@
48 try:
49 dk = self.bus.get_object(DISKS_IFACE, device)
50 dev = dk.Get(device, 'device-file', dbus_interface=PROPS_IFACE)
51- if dk.Get(dev, 'device-is-partition', dbus_interface=PROPS_IFACE):
52- dev = dk.Get(dev, 'partition-slave', dbus_interface=PROPS_IFACE)
53- dk = self.bus.get_object(DISKS_IFACE, dev)
54- dev = dk.Get(device, 'device-file', dbus_interface=PROPS_IFACE)
55 p = self.targets[device]['parent']
56 if p and p in self.targets:
57 self.formatting.append(p)

Subscribers

People subscribed via source and target branches