* changed importance of some log messages

* use "sfdisk -R" instead of "blockdev --rereadpt" in order to avoid an additinal dependency
* removed obsolete sort function for block devices
This commit is contained in:
lars 2009-06-12 01:48:22 +00:00
parent ffb8f841be
commit f389508ed8
3 changed files with 23 additions and 33 deletions

View File

@ -440,7 +440,8 @@ class partition(cryptobox.plugins.base.CryptoBoxPlugin):
(output, error) = proc.communicate() (output, error) = proc.communicate()
fdisk_status = proc.returncode fdisk_status = proc.returncode
if fdisk_status != 0: if fdisk_status != 0:
self.cbox.log.debug("partitioning failed: %s" % error) self.cbox.log.error("partitioning of '%s' failed: %s" % \
(self.blockdevice.get_device(), error))
##Every time we update a partition table, force the kernel ##Every time we update a partition table, force the kernel
##to reread it and update /proc/partitions. This particularly ##to reread it and update /proc/partitions. This particularly
##applies to internal hard disks. ##applies to internal hard disks.
@ -450,16 +451,17 @@ class partition(cryptobox.plugins.base.CryptoBoxPlugin):
stdout = subprocess.PIPE, stdout = subprocess.PIPE,
stderr = subprocess.PIPE, stderr = subprocess.PIPE,
args = [ args = [
self.cbox.prefs["Programs"]["super"], self.cbox.prefs["Programs"]["super"],
self.cbox.prefs["Programs"]["CryptoBoxRootActions"], self.cbox.prefs["Programs"]["CryptoBoxRootActions"],
"plugin", "plugin",
os.path.join(self.plugin_dir, "root_action.py"), os.path.join(self.plugin_dir, "root_action.py"),
"rereadpt", "rereadpt",
self.blockdevice.get_device()]) self.blockdevice.get_device()])
(output, error) = rereadpt_proc.communicate() (output, error) = rereadpt_proc.communicate()
rereadpt_status = rereadpt_proc.returncode rereadpt_status = rereadpt_proc.returncode
if rereadpt_status != 0: if rereadpt_status != 0:
self.cbox.log.info("failed to reread the modified partition table: %s" % error) self.cbox.log.warn("failed to reread the modified partition table "
+ "of '%s': %s" % (self.blockdevice.get_device(), error))
# refresh the device list # refresh the device list
self.cbox.reread_container_list() self.cbox.reread_container_list()
# update the current blockdevice - especially the new partitioned children # update the current blockdevice - especially the new partitioned children

View File

@ -25,7 +25,6 @@ __revision__ = "$Id$"
## necessary: otherwise CryptoBoxRootActions.py will refuse to execute this script ## necessary: otherwise CryptoBoxRootActions.py will refuse to execute this script
PLUGIN_TYPE = "cryptobox" PLUGIN_TYPE = "cryptobox"
BLKDEV_BIN = "/sbin/blockdev"
SFDISK_BIN = "/sbin/sfdisk" SFDISK_BIN = "/sbin/sfdisk"
MKFS_BIN = "/sbin/mkfs" MKFS_BIN = "/sbin/mkfs"
LABEL_BIN = "/sbin/e2label" LABEL_BIN = "/sbin/e2label"
@ -40,6 +39,9 @@ def __partitionDevice(device):
## do not use the "-q" flag, as this spoils the exit code of sfdisk (seems to be a bug) ## do not use the "-q" flag, as this spoils the exit code of sfdisk (seems to be a bug)
proc = subprocess.Popen( proc = subprocess.Popen(
shell = False, shell = False,
stdin = subprocess.PIPE,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE,
args = [ args = [
SFDISK_BIN, SFDISK_BIN,
"-uM", "-uM",
@ -47,16 +49,21 @@ def __partitionDevice(device):
proc.wait() proc.wait()
return proc.returncode == 0 return proc.returncode == 0
def __rereadPartitions(device): def __rereadPartitions(device):
proc = subprocess.Popen( proc = subprocess.Popen(
shell = False, shell = False,
stdin = subprocess.PIPE,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE,
args = [ args = [
BLKDEV_BIN, SFDISK_BIN,
"--rereadpt", "-R",
device]) device])
proc.wait() proc.wait()
return proc.returncode == 0 return proc.returncode == 0
def __formatPartition(device, type): def __formatPartition(device, type):
import time, threading import time, threading
result = True result = True

View File

@ -207,8 +207,8 @@ class Blockdevice:
if os.path.exists(dev): if os.path.exists(dev):
return dev return dev
# none of the device nodes exists # none of the device nodes exists
self.cbox.log.warn("No valid device node found for %s out of %s" % \ LOGGER.warn("No valid device node found for %s out of %s" % \
(self.name, str(self.devnodes))) (self.name, str(self.devnodes)))
return None return None
@ -970,25 +970,6 @@ def find_lvm_pv():
return result[:] return result[:]
def get_sorted_devices(names):
"""return the names of devices in a sorted order
e.g.: "hda1", "hda5", "hda6", ..., "hda10", "hda11"
"""
# TODO: implement this for devicenames like "hda12"
def compare_device_names(x, y):
if x.name < y.name:
return -1
elif x.name == y.name:
return 0
else:
return 1
result = names[:]
result.sort(cmp=compare_device_names)
return result
def _load_preferences(): def _load_preferences():
prefs = cryptobox.core.settings.get_current_settings() prefs = cryptobox.core.settings.get_current_settings()
if not prefs is None: if not prefs is None: