Commit 7706fdd4 authored by Iustin Pop's avatar Iustin Pop
Browse files

lvmstrap: abstract a little the sysfs paths


Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent add478b5
...@@ -430,7 +430,8 @@ def GetDiskList(opts): ...@@ -430,7 +430,8 @@ def GetDiskList(opts):
if not compat.any([name.startswith(pfx) for pfx in SUPPORTED_TYPES]): if not compat.any([name.startswith(pfx) for pfx in SUPPORTED_TYPES]):
continue continue
size = ReadSize("/sys/block/%s" % name) disksysfsname = "/sys/block/%s" % name
size = ReadSize(disksysfsname)
f = open("/sys/block/%s/removable" % name) f = open("/sys/block/%s/removable" % name)
removable = int(f.read().strip()) removable = int(f.read().strip())
...@@ -439,16 +440,17 @@ def GetDiskList(opts): ...@@ -439,16 +440,17 @@ def GetDiskList(opts):
if removable and not opts.removable_ok: if removable and not opts.removable_ok:
continue continue
dev = ReadDev("/sys/block/%s" % name) dev = ReadDev(disksysfsname)
CheckSysDev(name, dev) CheckSysDev(name, dev)
inuse = InUse(name) inuse = InUse(name)
# Enumerate partitions of the block device # Enumerate partitions of the block device
partitions = [] partitions = []
for partname in os.listdir("/sys/block/%s" % name): for partname in os.listdir(disksysfsname):
if not partname.startswith(name): if not partname.startswith(name):
continue continue
partdev = ReadDev("/sys/block/%s/%s" % (name, partname)) partsysfsname = "%s/%s" % (disksysfsname, partname)
partsize = ReadSize("/sys/block/%s/%s" % (name, partname)) partdev = ReadDev(partsysfsname)
partsize = ReadSize(partsysfsname)
if partsize >= PART_MINSIZE: if partsize >= PART_MINSIZE:
CheckSysDev(partname, partdev) CheckSysDev(partname, partdev)
partitions.append((partname, partsize, partdev)) partitions.append((partname, partsize, partdev))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment