-
-
Save alram/33ea3360d5aa6a86e8a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/ceph-disk b/src/ceph-disk | |
index 6c1b370..423c43f 100755 | |
--- a/src/ceph-disk | |
+++ b/src/ceph-disk | |
@@ -159,16 +159,11 @@ def list_partitions(disk): | |
disk = os.path.realpath(disk) | |
assert not is_partition(disk) | |
assert disk.startswith('/dev/') | |
- base = disk[5:] | |
+ base = disk.split('/')[-1] | |
partitions = [] | |
- with file('/proc/partitions', 'rb') as proc_partitions: | |
- for line in proc_partitions.read().split('\n')[2:]: | |
- fields = re.split('\s+', line) | |
- if len(fields) < 5: | |
- continue | |
- name = fields [4] | |
- if name != base and name.startswith(base): | |
- partitions.append('/dev/' + name) | |
+ for name in os.listdir(os.path.join('/sys/block/', base)): | |
+ if name.startswith(base): | |
+ partitions.append('/dev/' + name) | |
return partitions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment