[Thincrust-devel] [PATCH 3/3] Ensure loop device symlinks have not been left behind, from untidy termination before assigning them.
Marc Savy
msavy at redhat.com
Fri Aug 3 14:25:57 UTC 2012
It is possible in certain termination situations for the program to be
unable to tidy up the symlinks it has created, causing collisions on the
next run. This patch is an attempt to resolve that.
From bd3f1609a36670cdc2936e9ecd7440d6ab21014f Mon Sep 17 00:00:00 2001
From: Marc Savy <msavy at redhat.com>
Date: Wed, 18 Jul 2012 14:13:09 +0100
Subject: [PATCH 3/3] Ensure loop device symlinks have not been left behind
from untidy termination before assigning them.
To: thincrust-devel at redhat.com
---
appcreate/partitionedfs.py | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/appcreate/partitionedfs.py b/appcreate/partitionedfs.py
index 4982a69..37df485 100644
--- a/appcreate/partitionedfs.py
+++ b/appcreate/partitionedfs.py
@@ -152,11 +152,21 @@ class PartitionedMount(Mount):
self.partitions[pnum]['device'] = loopdev
self.partitions[pnum]['devicemapper'] = mapperdev
- # grub's install wants partitions to be named
- # to match their parent device + partition num
- # kpartx doesn't work like this, so we add compat
- # symlinks to point to /dev/mapper
- os.symlink(mapperdev, loopdev)
+ # Loop devices are sometimes still left hanging around
from untidily
+ # terminated processes.
+ logging.debug('Creating symlink from %s to %s',
loopdev, mapperdev)
+ try:
+ # grub's install wants partitions to be named
+ # to match their parent device + partition num
+ # kpartx doesn't work like this, so we add compat
+ # symlinks to point to /dev/mapper
+ os.symlink(mapperdev, loopdev)
+ except OSError as e:
+ if e.errno == errno.EEXIST:
+ os.unlink(loopdev)
+ os.symlink(mapperdev, loopdev)
+ else:
+ raise
logging.debug("Adding partx mapping for %s" %
d['disk'].device)
rc = subprocess.call(["/sbin/kpartx", "-a", "-s",
d['disk'].device])
--
1.7.11.2
-------------- next part --------------
From bd3f1609a36670cdc2936e9ecd7440d6ab21014f Mon Sep 17 00:00:00 2001
From: Marc Savy <msavy at redhat.com>
Date: Wed, 18 Jul 2012 14:13:09 +0100
Subject: [PATCH 3/3] Ensure loop device symlinks have not been left behind
from untidy termination before assigning them.
To: thincrust-devel at redhat.com
---
appcreate/partitionedfs.py | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/appcreate/partitionedfs.py b/appcreate/partitionedfs.py
index 4982a69..37df485 100644
--- a/appcreate/partitionedfs.py
+++ b/appcreate/partitionedfs.py
@@ -152,11 +152,21 @@ class PartitionedMount(Mount):
self.partitions[pnum]['device'] = loopdev
self.partitions[pnum]['devicemapper'] = mapperdev
- # grub's install wants partitions to be named
- # to match their parent device + partition num
- # kpartx doesn't work like this, so we add compat
- # symlinks to point to /dev/mapper
- os.symlink(mapperdev, loopdev)
+ # Loop devices are sometimes still left hanging around from untidily
+ # terminated processes.
+ logging.debug('Creating symlink from %s to %s', loopdev, mapperdev)
+ try:
+ # grub's install wants partitions to be named
+ # to match their parent device + partition num
+ # kpartx doesn't work like this, so we add compat
+ # symlinks to point to /dev/mapper
+ os.symlink(mapperdev, loopdev)
+ except OSError as e:
+ if e.errno == errno.EEXIST:
+ os.unlink(loopdev)
+ os.symlink(mapperdev, loopdev)
+ else:
+ raise
logging.debug("Adding partx mapping for %s" % d['disk'].device)
rc = subprocess.call(["/sbin/kpartx", "-a", "-s", d['disk'].device])
--
1.7.11.2
More information about the Thincrust-devel
mailing list