diff options
author | Danny Al-Gaaf <danny.al-gaaf@bisect.de> | 2013-04-02 17:33:08 +0200 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-04-26 13:40:07 -0700 |
commit | 0e47d312dcec2deb26a960e6097708d8742d85cb (patch) | |
tree | 0f865fe7e7e0f3eaf9a56c4c6fbee6a20e295547 | |
parent | 7326ea6397160607d78914444f7f0598a6ba346f (diff) | |
download | ceph-0e47d312dcec2deb26a960e6097708d8742d85cb.tar.gz |
ceph-disk: merge twice defined function is_mounted(dev)
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
(cherry picked from commit eaf31bf9f90ba9709a57a6870dbafa21142dae2c)
-rwxr-xr-x | src/ceph-disk | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/src/ceph-disk b/src/ceph-disk index e0e51a91aa7..468dcba1313 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') |