From daf0a9be627f77af6a1a0d48fd1a882f9f4992e0 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Wed, 13 Jun 2012 13:36:27 +0100 Subject: morphlib.fsutils: setup_device_mapping simplify losetup has a --show option that will print the loop device the file was mapped to, this is better than parsing the output of losetup -j. --- morphlib/fsutils.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'morphlib/fsutils.py') diff --git a/morphlib/fsutils.py b/morphlib/fsutils.py index 1a833599..770cafa8 100644 --- a/morphlib/fsutils.py +++ b/morphlib/fsutils.py @@ -44,13 +44,9 @@ def setup_device_mapping(runcmd, image_name): start = int(match.group(1)) * 512 if start != 0: break - - runcmd(['losetup', '-o', str(start), '-f', image_name]) - - out = runcmd(['losetup', '-j', image_name]) - line = out.strip() - i = line.find(':') - return line[:i] + + device = runcmd(['losetup', '--show', '-o', str(start), '-f', image_name]) + return device.strip() def create_fs(runcmd, partition): runcmd(['mkfs.btrfs', '-L', 'baserock', partition]) -- cgit v1.2.1