From: Łukasz Stelmach Date: Tue, 19 Sep 2023 15:00:09 +0000 (+0200) Subject: WIP: report an error when an image already exist X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5115b11da4b98c33a4b07c32f6470d16a8d893f1;p=platform%2Fkernel%2Fu-boot.git WIP: report an error when an image already exist Change-Id: I3c4f2d45f42340f265bd2e4747a511ad52b1550f Signed-off-by: Łukasz Stelmach --- diff --git a/scripts/tizen/sd_fusing.py b/scripts/tizen/sd_fusing.py index 687dd240ca..61ebcf4142 100755 --- a/scripts/tizen/sd_fusing.py +++ b/scripts/tizen/sd_fusing.py @@ -181,13 +181,17 @@ def check_device(args): 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