[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [PATCH] Handle fstab entries whose filesystem we don't recognize.(#498120)



On 05/04/2009 01:48 PM, David Lehman wrote:
If the line contains a filesystem we do not recognize or a device that
we are unable to resolve we will just write it back out as-is if/when
we write out a new fstab.
---
  storage/__init__.py |   18 +++++++++++++++++-
  1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/storage/__init__.py b/storage/__init__.py
index 01ed14e..f3fa60e 100644
--- a/storage/__init__.py
+++ b/storage/__init__.py
@@ -1231,6 +1231,7 @@ class FSSet(object):
          self._sysfs = None
          self._proc = None
          self._devshm = None
+        self.preserveLines = []     # lines we just ignore and preserve

      @property
      def sysfs(self):
@@ -1342,7 +1343,12 @@ class FSSet(object):
          if device is None:
              log.error("failed to resolve %s (%s) from fstab" % (devspec,
                                                                  fstype))
-            return None
+            raise UnrecognizedFSTabEntryError()
+
+        if device.format.type is None:
+            log.info("Unrecognized filesystem type for %s (%s)"
+                     % (device.name, fstype))
+            raise UnrecognizedFSTabEntryError()

          # make sure, if we're using a device from the tree, that
          # the device's format we found matches what's in the fstab
@@ -1428,6 +1434,10 @@ class FSSet(object):

                  try:
                      device = self._parseOneLine((devspec, mountpoint, fstype, options, dump, passno))
+                except UnrecognizedFSTabEntryError:
+                    # just write the line back out as-is after upgrade
+                    self.preserveLines.append(line)
+                    continue
                  except Exception as e:
                      raise Exception("fstab entry %s is malformed: %s" % (devspec, e))

@@ -1831,4 +1841,10 @@ class FSSet(object):
              fstab = fstab + device.fstabComment
              fstab = fstab + format % (devspec, mountpoint, fstype,
                                        options, dump, passno)
+
+        # now, write out any lines we were unable to process because of
+        # unrecognized filesystems or unresolveable device specifications
+        for line in self.preserveLines:
+            fstab += line
+
          return fstab

Looks good.

--
David Cantrell <dcantrell redhat com>
Red Hat / Honolulu, HI


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]