From: Danny Al-Gaaf Date: Tue, 2 Apr 2013 15:33:08 +0000 (+0200) Subject: ceph-disk: merge twice defined function is_mounted(dev) X-Git-Tag: v0.62~103^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=eaf31bf9f90ba9709a57a6870dbafa21142dae2c;p=ceph.git ceph-disk: merge twice defined function is_mounted(dev) Signed-off-by: Danny Al-Gaaf --- diff --git a/src/ceph-disk b/src/ceph-disk index d714500b0033e..16a0bb1e4513b 100755 --- a/src/ceph-disk +++ b/src/ceph-disk @@ -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')