[anaconda][rhel7-branch/master/f23-branch][PATCH] Ignore zram block devices in the list-harddrives script output (#1253184)
Martin Kolman
mkolman at redhat.com
Thu Aug 13 14:26:21 UTC 2015
Also make sure that what we only return block devices.
Resolves: rhbz#1253184
Signed-off-by: Martin Kolman <mkolman at redhat.com>
---
data/command-stubs/list-harddrives-stub | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/data/command-stubs/list-harddrives-stub b/data/command-stubs/list-harddrives-stub
index ae5e6b9..a6f59ac 100755
--- a/data/command-stubs/list-harddrives-stub
+++ b/data/command-stubs/list-harddrives-stub
@@ -19,12 +19,32 @@
#
import sys
+import os
+import stat
import parted
+def check_device(device):
+ if stat.S_ISBLK(os.stat(device.path)):
+ # exclude device mapper devices
+ if device.type == parted.DEVICE_DM:
+ return False
+ # exclude block devices for CD/DVD disks
+ elif device.path.startswith("/dev/sr"):
+ return False
+ # exclude zram bloc devices
+ elif device.path.startswith("/dev/zram"):
+ return False
+ # the remaining block devices should be fine
+ else:
+ return True
+ else:
+ # ignore everything that is not a block device
+ return False
+
def main(argv):
lst = set()
- for dev in filter(lambda d: d.type != parted.DEVICE_DM and not d.path.startswith("/dev/sr"), parted.getAllDevices()):
+ for dev in filter(lambda d: check_device(d), parted.getAllDevices()):
if dev.path.startswith("/dev/"):
path = dev.path[5:]
else:
--
2.4.3
More information about the anaconda-patches
mailing list