From ed1426e57fcb270483ab4a2d7852a11a65de5109 Mon Sep 17 00:00:00 2001 From: David Cantrell Date: Tue, 14 Apr 2009 13:35:54 -1000 Subject: Don't traceback on invalid filesystem detection (#495156) We may think a partition has a valid filesystem when it really does not. This is easily reproduced with the following steps: 1) Create a partition on some device. 2) Create an NTFS filesystem on that partition. 3) Delete the partition from the device. 4) Divide the device in to two equal sized partitions, but do not create a filesystem on either. Boot the installer and notice that the first partition is assumed to be NTFS, but it's unmountable. In getExistingSize(), we get an FSError traceback when trying to mount the filesyste. The problem is that we haven't zeroed out the new partition or created a new filesystem on top of it. The old filesystem data is still on the disk and is misleading udev and friends. The solution in this patch is to catch the FSError from getExistingSize(). If the mount failed, assume the partition is empty and continue. --- iw/partition_ui_helpers_gui.py | 2 +- storage/devicetree.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/iw/partition_ui_helpers_gui.py b/iw/partition_ui_helpers_gui.py index b7b6b3dbd..1ff2d5f35 100644 --- a/iw/partition_ui_helpers_gui.py +++ b/iw/partition_ui_helpers_gui.py @@ -315,7 +315,7 @@ def createPreExistFSOptionSection(origrequest, maintable, row, mountCombo, else: origfs = origrequest.format - if origfs.formattable: + if origfs.formattable or not origfs.type: formatcb = gtk.CheckButton(label=_("_Format as:")) maintable.attach(formatcb, 0, 1, row, row + 1) formatcb.set_active(origfs.formattable and not origfs.exists) diff --git a/storage/devicetree.py b/storage/devicetree.py index 7540ff2be..12dd7c38e 100644 --- a/storage/devicetree.py +++ b/storage/devicetree.py @@ -1409,13 +1409,11 @@ class DeviceTree(object): label = udev_device_get_label(info) format_type = udev_device_get_format(info) - log.debug("type is '%s'" % format_type) - format = None if (not device) or (not format_type) or device.format.type: # this device has no formatting or it has already been set up # FIXME: this probably needs something special for disklabels - log.debug("bailing") + log.debug("no type or existing type for %s, bailing" % (name,)) return # set up the common arguments for the format constructor @@ -1462,7 +1460,14 @@ class DeviceTree(object): if apple.minSize <= device.size <= apple.maxSize: args[0] = "appleboot" - device.format = formats.getFormat(*args, **kwargs) + try: + log.debug("type detected on '%s' is '%s'" % (name, format_type,)) + device.format = formats.getFormat(*args, **kwargs) + except FSError: + log.debug("type '%s' on '%s' invalid, assuming no format" % + (format_type, name,)) + device.format = formats.DeviceFormat() + return # # now do any special handling required for the device's format -- cgit