summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Lehman <dlehman@redhat.com>2009-04-21 17:50:36 -0500
committerDavid Lehman <dlehman@redhat.com>2009-04-24 12:27:16 -0500
commitcb8ba145b39a23c7bf43ba4b6fba3baa6993b1f7 (patch)
tree86c127c590f991734f4362259c76c3c3ffc90d5c
parent24db63f0eca7db8aa03774cd096dcd82537a3d8e (diff)
downloadanaconda-cb8ba145b39a23c7bf43ba4b6fba3baa6993b1f7.tar.gz
anaconda-cb8ba145b39a23c7bf43ba4b6fba3baa6993b1f7.tar.xz
anaconda-cb8ba145b39a23c7bf43ba4b6fba3baa6993b1f7.zip
Fix handling of bind mounts. (#496406)
When we're parsing /etc/fstab the directories that serve as the devices in bind mounts are not going to be present, so we will have a hell of a time figuring out what devices contain them. However, in FSSet.mountFilesystems we should have those dirs set up already, making it possible to sort out.
-rw-r--r--storage/__init__.py35
1 files changed, 32 insertions, 3 deletions
diff --git a/storage/__init__.py b/storage/__init__.py
index 8ef305c49..081e5435f 100644
--- a/storage/__init__.py
+++ b/storage/__init__.py
@@ -43,6 +43,7 @@ from formats import getFormat
from formats import get_device_format_class
from formats import get_default_filesystem_type
from devicelibs.lvm import safeLvmName
+from devicelibs.dm import name_from_dm_node
from udev import *
import iscsi
import zfcp
@@ -1186,6 +1187,10 @@ def get_containing_device(path, devicetree):
except Exception:
return None
+ if device_name.startswith("dm-"):
+ # have I told you lately that I love you, device-mapper?
+ device_name = name_from_dm_node(device_name)
+
return devicetree.getDeviceByName(device_name)
@@ -1288,9 +1293,13 @@ class FSSet(object):
# bind mount... set fstype so later comparison won't
# turn up false positives
fstype = "bind"
- device = FileDevice(devspec,
- parents=get_containing_device(devspec, self.devicetree),
- exists=True)
+
+ # This is probably not going to do anything useful, so we'll
+ # make sure to try again from FSSet.mountFilesystems. The bind
+ # mount targets should be accessible by the time we try to do
+ # the bind mount from there.
+ parents = get_containing_device(devspec, self.devicetree)
+ device = DirectoryDevice(devspec, parents=parents, exists=True)
device.format = getFormat("bind",
device=device.path,
exists=True)
@@ -1498,6 +1507,11 @@ class FSSet(object):
devices = self.mountpoints.values() + self.swapDevices
devices.extend([self.dev, self.devshm, self.devpts, self.sysfs, self.proc])
devices.sort(key=lambda d: getattr(d.format, "mountpoint", None))
+ for device in devices[:]:
+ # make sure all the bind mounts are at the end of the list
+ if device.format.type == "bind":
+ devices.remove(device)
+ devices.append(device)
for device in devices:
if not device.format.mountable or not device.format.mountpoint:
@@ -1510,6 +1524,21 @@ class FSSet(object):
if "noauto" in options.split(","):
continue
+ if device.format.type == "bind":
+ # set up the DirectoryDevice's parents now that they are
+ # accessible
+ #
+ # -- bind formats' device and mountpoint are always both
+ # under the chroot. no exceptions. none, damn it.
+ targetDir = "%s/%s" % (anaconda.rootPath, device.path)
+ parent = get_containing_device(targetDir, self.devicetree)
+ if not parent:
+ log.error("cannot determine which device contains "
+ "directory %s" % device.path)
+ device.parents = []
+ else:
+ device.parents = [parent]
+
try:
device.setup()
except Exception as msg: