----- Original Message -----
From: "David Lehman" dlehman@redhat.com To: anaconda-patches@lists.fedorahosted.org Sent: Friday, December 13, 2013 10:55:34 AM Subject: [PATCH 6/6] Move getActiveMounts from Blivet into DeviceTree.
blivet/__init__.py | 54 +--------------------------------------------------- blivet/devicetree.py | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 53 deletions(-)
diff --git a/blivet/__init__.py b/blivet/__init__.py index bad64ec..d5904e5 100644 --- a/blivet/__init__.py +++ b/blivet/__init__.py @@ -72,7 +72,6 @@ from deviceaction import * from formats import getFormat from formats import get_device_format_class from formats import get_default_filesystem_type -from formats.fs import nodev_filesystems import devicefactory from devicelibs.dm import name_from_dm_node from devicelibs.crypto import generateBackupPassphrase @@ -431,7 +430,7 @@ class Blivet(object): self.dumpState("initial")
if not flags.installer_mode:
self.getActiveMounts()
self.devicetree.getActiveMounts() self.updateBootLoaderDiskList()
@@ -1794,57 +1793,6 @@ class Blivet(object): log.debug("finished Blivet copy") return new
- def getActiveMounts(self):
""" Reflect active mounts in the appropriate devices' formats. """
log.info("collecting information about active mounts")
for line in open("/proc/mounts").readlines():
try:
(devspec, mountpoint, fstype, options, rest) =
line.split(None,
4)
except IndexError:
log.error("failed to parse /proc/mounts line: %s" % line)
continue
if fstype == "btrfs":
# get the subvol name from /proc/self/mountinfo
for line in open("/proc/self/mountinfo").readlines():
fields = line.split()
_subvol = fields[3]
_mountpoint = fields[4]
_devspec = fields[9]
if _mountpoint == mountpoint and _devspec == devspec:
log.debug("subvol %s" % _subvol)
options += ",subvol=%s" % _subvol[1:]
if fstype in nodev_filesystems:
if not flags.include_nodev:
continue
log.info("found nodev %s filesystem mounted at %s"
% (fstype, mountpoint))
# nodev filesystems require some special handling.
# For now, a lot of this is based on the idea that it's a
losing
# battle to require the presence of an FS class for every
type
# of nodev filesystem. Based on that idea, we just
instantiate
# NoDevFS directly and then hack in the fstype as the device
# attribute.
fmt = getFormat("nodev")
fmt.device = fstype
# NoDevice also needs some special works since they don't
have
# per-instance names in the kernel.
device = NoDevice(format=fmt)
n = len([d for d in self.devices if d.format.type ==
fstype])
device._name += ".%d" % n
self.devicetree._addDevice(device)
devspec = device.name
device = self.devicetree.resolveDevice(devspec, options=options)
if device is not None:
device.format.mountpoint = mountpoint # for future mounts
device.format._mountpoint = mountpoint # active mountpoint
device.format.mountopts = options
- def updateKSData(self): """ Update ksdata to reflect the settings of this Blivet instance. """ if not self.ksdata or not self.mountpoints:
diff --git a/blivet/devicetree.py b/blivet/devicetree.py index 927e261..e72ce7c 100644 --- a/blivet/devicetree.py +++ b/blivet/devicetree.py @@ -33,6 +33,7 @@ from devices import * from deviceaction import * from pykickstart.constants import * import formats +from formats.fs import nodev_filesystems import devicelibs.mdraid import devicelibs.dm import devicelibs.lvm @@ -2383,3 +2384,54 @@ class DeviceTree(object): else: log.debug("failed to resolve '%s'" % devspec) return device
- def getActiveMounts(self):
""" Reflect active mounts in the appropriate devices' formats. """
log.info("collecting information about active mounts")
for line in open("/proc/mounts").readlines():
try:
(devspec, mountpoint, fstype, options, rest) =
line.split(None,
4)
except IndexError:
log.error("failed to parse /proc/mounts line: %s" % line)
continue
if fstype == "btrfs":
# get the subvol name from /proc/self/mountinfo
for line in open("/proc/self/mountinfo").readlines():
fields = line.split()
_subvol = fields[3]
_mountpoint = fields[4]
_devspec = fields[9]
if _mountpoint == mountpoint and _devspec == devspec:
log.debug("subvol %s" % _subvol)
options += ",subvol=%s" % _subvol[1:]
if fstype in nodev_filesystems:
if not flags.include_nodev:
continue
log.info("found nodev %s filesystem mounted at %s"
% (fstype, mountpoint))
# nodev filesystems require some special handling.
# For now, a lot of this is based on the idea that it's a
losing
# battle to require the presence of an FS class for every
type
# of nodev filesystem. Based on that idea, we just
instantiate
# NoDevFS directly and then hack in the fstype as the device
# attribute.
fmt = getFormat("nodev")
fmt.device = fstype
# NoDevice also needs some special works since they don't
have
# per-instance names in the kernel.
device = NoDevice(format=fmt)
n = len([d for d in self.devices if d.format.type ==
fstype])
device._name += ".%d" % n
self._addDevice(device)
devspec = device.name
device = self.resolveDevice(devspec, options=options)
if device is not None:
device.format.mountpoint = mountpoint # for future mounts
device.format._mountpoint = mountpoint # active mountpoint
device.format.mountopts = options
-- 1.8.1.4
Looks fine to me.
Probably the commit message should have a comment explaining the reason for the move.
- mulhern
anaconda-patches mailing list anaconda-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches