global Device
Device = args.device
- if not os.path.exists(Device) and args.create:
- logging.debug(f"dd if=/dev/zero of={Device} conv=sparse bs=1M count={args.size}")
- rc = subprocess.run(["dd", "if=/dev/zero", f"of={Device}",
- "conv=sparse", "bs=1M", f"count={args.size}"])
- if rc.returncode != 0:
- logging.error("Failed to create the backing file")
+ if args.create:
+ if os.path.exists(Device):
+ logging.error(f"Failed to create '{Device}', the file alread exists")
sys.exit(1)
+ else:
+ logging.debug(f"dd if=/dev/zero of={Device} conv=sparse bs=1M count={args.size}")
+ rc = subprocess.run(["dd", "if=/dev/zero", f"of={Device}",
+ "conv=sparse", "bs=1M", f"count={args.size}"])
+ if rc.returncode != 0:
+ logging.error("Failed to create the backing file")
+ sys.exit(1)
if os.path.isfile(Device):
global File