[PATCH 1/3] Add a method to determine if device is mounted

Jesse Keating jkeating at redhat.com
Mon Aug 27 23:57:38 UTC 2012


This will return a list of places a particular device might be mounted.
---
 pyanaconda/packaging/__init__.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/pyanaconda/packaging/__init__.py b/pyanaconda/packaging/__init__.py
index 7c9b6a1..d693bbc 100644
--- a/pyanaconda/packaging/__init__.py
+++ b/pyanaconda/packaging/__init__.py
@@ -93,6 +93,21 @@ class DependencyError(PayloadError):
 class PayloadInstallError(PayloadError):
     pass
 
+def get_mount_paths(dev):
+    mounts = open("/proc/mounts").readlines()
+    mount_paths = []
+    for mount in mounts:
+        try:
+            (device, path, rest) = mount.split(None, 2)
+        except ValueError:
+            continue
+
+        if dev == device:
+            mount_paths.append(path)
+
+    if mount_paths:
+        log.debug("%s is mounted on %s" % (dev, ', '.join(mount_paths)))
+    return mount_paths
 
 def get_mount_device(mountpoint):
     import re
-- 
1.7.11.2



More information about the anaconda-patches mailing list