* changed definition of storage device: only "valid" devices are available now

This commit is contained in:
lars 2009-06-13 12:22:53 +00:00
parent b5c4eabc26
commit 4f24c813cd
1 changed files with 21 additions and 22 deletions

View File

@ -254,32 +254,31 @@ class Blockdevice:
cached = CACHE.get(cache_link) cached = CACHE.get(cache_link)
if not cached is None: if not cached is None:
return cached return cached
result = True
if self.range > 1: # always check the current state of "result" to skip useless checks
if result and (self.range > 1):
## partitionable blockdevice ## partitionable blockdevice
CACHE.set(cache_link, False) result = False
return False if result and not self.is_valid():
if self.size < MINIMUM_STORAGE_SIZE: result = False
if result and (self.size < MINIMUM_STORAGE_SIZE):
## extended partition, unused loop device ## extended partition, unused loop device
CACHE.set(cache_link, False) result = False
return False
## are we the device mapper of a luks device? ## are we the device mapper of a luks device?
for slave in self.slaves: if result:
if get_blockdevice(slave, self.sysblock_dir, for slave in self.slaves:
self.devnode_dir).is_luks(): if get_blockdevice(slave, self.sysblock_dir,
CACHE.set(cache_link, False) self.devnode_dir).is_luks():
return False result = False
## if we are a luks device with exactly one child, then if result and self.children:
## we are a storage ## if we are a luks device with exactly one child, then
if (len(self.children) == 1) and self.is_luks(): ## we are a storage
CACHE.set(cache_link, True) if not ((len(self.children) == 1) and self.is_luks()):
return True ## a parent blockdevice
if self.children: result = False
## a parent blockdevice CACHE.set(cache_link, result)
CACHE.set(cache_link, False) return result
return False
CACHE.set(cache_link, True)
return True
def is_partitionable(self): def is_partitionable(self):