Browse Source

* 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
master
lars 13 years ago
parent
commit
f389508ed8
  1. 18
      plugins/partition/partition.py
  2. 15
      plugins/partition/root_action.py
  3. 23
      src/cryptobox/core/blockdevice.py

18
plugins/partition/partition.py

@ -440,7 +440,8 @@ class partition(cryptobox.plugins.base.CryptoBoxPlugin):
(output, error) = proc.communicate()
fdisk_status = proc.returncode
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
##to reread it and update /proc/partitions. This particularly
##applies to internal hard disks.
@ -450,16 +451,17 @@ class partition(cryptobox.plugins.base.CryptoBoxPlugin):
stdout = subprocess.PIPE,
stderr = subprocess.PIPE,
args = [
self.cbox.prefs["Programs"]["super"],
self.cbox.prefs["Programs"]["CryptoBoxRootActions"],
"plugin",
os.path.join(self.plugin_dir, "root_action.py"),
"rereadpt",
self.blockdevice.get_device()])
self.cbox.prefs["Programs"]["super"],
self.cbox.prefs["Programs"]["CryptoBoxRootActions"],
"plugin",
os.path.join(self.plugin_dir, "root_action.py"),
"rereadpt",
self.blockdevice.get_device()])
(output, error) = rereadpt_proc.communicate()
rereadpt_status = rereadpt_proc.returncode
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
self.cbox.reread_container_list()
# update the current blockdevice - especially the new partitioned children

15
plugins/partition/root_action.py

@ -25,7 +25,6 @@ __revision__ = "$Id$"
## necessary: otherwise CryptoBoxRootActions.py will refuse to execute this script
PLUGIN_TYPE = "cryptobox"
BLKDEV_BIN = "/sbin/blockdev"
SFDISK_BIN = "/sbin/sfdisk"
MKFS_BIN = "/sbin/mkfs"
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)
proc = subprocess.Popen(
shell = False,
stdin = subprocess.PIPE,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE,
args = [
SFDISK_BIN,
"-uM",
@ -47,16 +49,21 @@ def __partitionDevice(device):
proc.wait()
return proc.returncode == 0
def __rereadPartitions(device):
proc = subprocess.Popen(
shell = False,
stdin = subprocess.PIPE,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE,
args = [
BLKDEV_BIN,
"--rereadpt",
device])
SFDISK_BIN,
"-R",
device])
proc.wait()
return proc.returncode == 0
def __formatPartition(device, type):
import time, threading
result = True

23
src/cryptobox/core/blockdevice.py

@ -207,8 +207,8 @@ class Blockdevice:
if os.path.exists(dev):
return dev
# none of the device nodes exists
self.cbox.log.warn("No valid device node found for %s out of %s" % \
(self.name, str(self.devnodes)))
LOGGER.warn("No valid device node found for %s out of %s" % \
(self.name, str(self.devnodes)))
return None
@ -970,25 +970,6 @@ def find_lvm_pv():
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():
prefs = cryptobox.core.settings.get_current_settings()
if not prefs is None:

Loading…
Cancel
Save