From 188a7fd5da85b92d54ba5143bf24b27063417c6a Mon Sep 17 00:00:00 2001 From: Eric Torres Date: Fri, 8 Mar 2019 06:04:52 -0800 Subject: [PATCH] Perform both important checks before printing info about block devices --- ddusb.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ddusb.py b/ddusb.py index a3b3f30..354513a 100644 --- a/ddusb.py +++ b/ddusb.py @@ -61,14 +61,11 @@ block_size = args.bs input_file = args.input_file block_device = args.output_file +# Ensure that block_device is really a block device if not pathlib.Path(block_device).is_block_device(): print(f'Error: "{block_device}" is not a block device') exit(1) -print(f"Input file: {input_file}") -print(f"Block device: {block_device}") -print(f"Block size: {block_size}") - # Check if block_device is excluded exclude_patterns = read_exclude_file(EXCLUDE_FILE) device_blacklist = expand_globs(*exclude_patterns) @@ -77,6 +74,10 @@ if block_device in device_blacklist: print(f'Error: "{block_device}" is blacklisted from running dd') exit(2) +print(f"Input file: {input_file}") +print(f"Block device: {block_device}") +print(f"Block size: {block_size}") + try: subprocess.run( [