]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk: merge twice defined function is_mounted(dev)
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Tue, 2 Apr 2013 15:33:08 +0000 (17:33 +0200)
committerSage Weil <sage@inktank.com>
Fri, 26 Apr 2013 20:40:07 +0000 (13:40 -0700)
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
(cherry picked from commit eaf31bf9f90ba9709a57a6870dbafa21142dae2c)

src/ceph-disk

index e0e51a91aa7a15fc844922ae8b02784a7f6f2fb7..468dcba13138873290c8148551c2ecadd80dadfd 100755 (executable)
@@ -201,14 +201,18 @@ def is_mounted(dev):
     Check if the given device is mounted.
     """
     dev = os.path.realpath(dev)
-    with file('/proc/mounts') as f:
-        for line in f.read().split('\n'):
-            d = line.split(' ')[0]
-            if os.path.exists(d):
+    with file('/proc/mounts', 'rb') as proc_mounts:
+        for line in proc_mounts:
+            fields = line.split()
+            if len(fields) < 3:
+                continue
+            d = fields[0]
+            path = fields[1]
+            if d.startswith('/') and os.path.exists(d):
                 d = os.path.realpath(d)
-                if dev == d:
-                    return True
-    return False
+                if d == dev:
+                    return path
+    return None
 
 
 def is_held(dev):
@@ -1645,20 +1649,6 @@ def get_partition_uuid(dev):
             return m.group(1).lower()
     return None
 
-def is_mounted(dev):
-    with file('/proc/mounts', 'rb') as proc_mounts:
-        for line in proc_mounts:
-            fields = line.split()
-            if len(fields) < 3:
-                continue
-            d = fields[0]
-            path = fields[1]
-            if d.startswith('/') and os.path.exists(d):
-                d = os.path.realpath(d)
-                if d == dev:
-                    return path
-    return None
-
 def more_osd_info(path, uuid_map):
     desc = []
     ceph_fsid = get_oneliner(path, 'ceph_fsid')