[blivet:master 05/17] Tighten up FS.mountable().
mulhern
amulhern at redhat.com
Tue Jan 6 20:38:07 UTC 2015
Only calculate values if needed and omit redundant startswith check.
Add a comment to clarify middle loop's purpose.
Signed-off-by: mulhern <amulhern at redhat.com>
---
blivet/formats/fs.py | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/blivet/formats/fs.py b/blivet/formats/fs.py
index 0c610cb..27a2bc4 100644
--- a/blivet/formats/fs.py
+++ b/blivet/formats/fs.py
@@ -797,14 +797,16 @@ class FS(DeviceFormat):
def mountable(self):
canmount = (self.mountType in kernel_filesystems) or \
(os.access("/sbin/mount.%s" % (self.mountType,), os.X_OK))
- modpath = os.path.realpath(os.path.join("/lib/modules", os.uname()[2]))
- modname = "%s.ko" % self.mountType
-
- if not canmount and os.path.isdir(modpath):
- for _root, _dirs, files in os.walk(modpath):
- have = [x for x in files if x.startswith(modname)]
- if len(have) == 1 and have[0].startswith(modname):
- return True
+
+ # Still consider the filesystem type mountable if there exists
+ # an appropriate filesystem driver in the kernel modules directory.
+ if not canmount:
+ modpath = os.path.realpath(os.path.join("/lib/modules", os.uname()[2]))
+ if os.path.isdir(modpath):
+ modname = "%s.ko" % self.mountType
+ for _root, _dirs, files in os.walk(modpath):
+ if len([x for x in files if x.startswith(modname)]) == 1:
+ return True
return canmount
--
1.9.3
More information about the anaconda-patches
mailing list