diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2012-06-13 13:36:27 +0100 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2012-06-13 13:49:39 +0100 |
commit | daf0a9be627f77af6a1a0d48fd1a882f9f4992e0 (patch) | |
tree | dd88f4d5cc6314dfedd2e49b740b89bfaad18a53 /morphlib/fsutils.py | |
parent | 4f79aa01679b22eab650ae67c3e08f2fefd5f458 (diff) | |
download | morph-daf0a9be627f77af6a1a0d48fd1a882f9f4992e0.tar.gz |
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.
Diffstat (limited to 'morphlib/fsutils.py')
-rw-r--r-- | morphlib/fsutils.py | 10 |
1 files changed, 3 insertions, 7 deletions
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]) |