Perform both important checks before printing info about block devices
This commit is contained in:
parent
653262d616
commit
188a7fd5da
9
ddusb.py
9
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(
|
||||
[
|
||||
|
Loading…
x
Reference in New Issue
Block a user