Perform both important checks before printing info about block devices

This commit is contained in:
Eric Torres 2019-03-08 06:04:52 -08:00
parent 653262d616
commit 188a7fd5da

View File

@ -61,14 +61,11 @@ block_size = args.bs
input_file = args.input_file input_file = args.input_file
block_device = args.output_file block_device = args.output_file
# Ensure that block_device is really a block device
if not pathlib.Path(block_device).is_block_device(): if not pathlib.Path(block_device).is_block_device():
print(f'Error: "{block_device}" is not a block device') print(f'Error: "{block_device}" is not a block device')
exit(1) 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 # Check if block_device is excluded
exclude_patterns = read_exclude_file(EXCLUDE_FILE) exclude_patterns = read_exclude_file(EXCLUDE_FILE)
device_blacklist = expand_globs(*exclude_patterns) 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') print(f'Error: "{block_device}" is blacklisted from running dd')
exit(2) exit(2)
print(f"Input file: {input_file}")
print(f"Block device: {block_device}")
print(f"Block size: {block_size}")
try: try:
subprocess.run( subprocess.run(
[ [