Also rename loop.get_device_path to loop.get_backing_file. --- pyanaconda/storage/devicelibs/loop.py | 16 +++++----------- pyanaconda/storage/devicetree.py | 4 ++-- scripts/anaconda-cleanup | 3 +-- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/pyanaconda/storage/devicelibs/loop.py b/pyanaconda/storage/devicelibs/loop.py index 4ed52e4..132d4c3 100644 --- a/pyanaconda/storage/devicelibs/loop.py +++ b/pyanaconda/storage/devicelibs/loop.py @@ -50,17 +50,12 @@ def losetup(args, capture=False): return ret -def get_device_path(name): - args = ["/dev/" + name] - buf = losetup(args, capture=True) - try: - start = buf.index("(") + 1 - end = buf.rindex(")") - path = buf[start:end] - except (IndexError, ValueError): - path = "" +def get_backing_file(name): + path = "" + sys_path = "/sys/class/block/%s/loop/backing_file" % name + if os.access(sys_path, os.R_OK): + path = open(sys_path).read().strip() - log.debug("get_device_path(%s) got '%s'" % (name, path)) return path def get_loop_name(path): @@ -71,7 +66,6 @@ def get_loop_name(path): raise LoopError("multiple loops associated with %s" % path) name = os.path.basename(buf.split(":")[0]) - log.debug("get_loop_name(%s) got '%s'" % (path, name)) return name def loop_setup(path): diff --git a/pyanaconda/storage/devicetree.py b/pyanaconda/storage/devicetree.py index 8cc61b9..6e2bed5 100644 --- a/pyanaconda/storage/devicetree.py +++ b/pyanaconda/storage/devicetree.py @@ -575,8 +575,8 @@ class DeviceTree(object): if name.startswith("loop"): # ignore loop devices unless they're backed by a disk image file - backing_device = devicelibs.loop.get_device_path(name) - return (backing_device not in self.diskImages.values()) + backing_file = devicelibs.loop.get_backing_file(name) + return (backing_file not in self.diskImages.values()) # FIXME: check for virtual devices whose slaves are on the ignore list diff --git a/scripts/anaconda-cleanup b/scripts/anaconda-cleanup index 5107bfc..9b228ad 100755 --- a/scripts/anaconda-cleanup +++ b/scripts/anaconda-cleanup @@ -58,8 +58,7 @@ for dev in os.listdir(sys_class_block): continue loop = os.listdir("%s/%s/slaves" % (sys_class_block, dev))[0].strip() - path = devicelibs.loop.get_device_path(loop) - storage_config.diskImages[name] = path + storage_config.diskImages[name] = devicelibs.loop.get_backing_file(loop) if not image_install and not live_install: print >> sys.stderr, "not a live install or an image install -- exiting" -- 1.7.3.3 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list