From: Artem Bityutskiy Date: Tue, 17 Sep 2013 06:44:22 +0000 (+0300) Subject: bmaptool: do not fail when copying a bmap file X-Git-Tag: v3.0~32 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f67fa0800d26868903c849b9f025a58872698958;p=tools%2Fbmap-tools.git bmaptool: do not fail when copying a bmap file It is possible that the user copies the bmapfile itself using 'bmaptool copy'. Most probably this is just by a mistake. In this case bmaptool just fails, since it discovers the bmap file, and it does not match the "image" (where the image is the same bmap file). This patch teaches bmaptool to handle this case by dropping the discoverd bmap file if its path is the same as the image path. Change-Id: Ib48842ed6157ba364173fcd7771e1b2ba3eea9e5 Signed-off-by: Artem Bityutskiy --- diff --git a/bmaptool b/bmaptool index 6236810..95380e8 100755 --- a/bmaptool +++ b/bmaptool @@ -181,6 +181,15 @@ def copy_command_open_all(args, log): # was not specified. (bmap_obj, bmap_path) = find_and_open_bmap(args, log) + if bmap_path == args.image: + # Most probably the specified the bmap file instead of the image file + # by mistake. + log.warning("image has the same path as the bmap file, dropping bmap") + bmap_obj.close() + bmap_obj = None + bmap_path = None + args.nobmap = True + # Try to open the destination file. If it does not exist, a new regular # file will be created. If it exists and it is a regular file - it'll be # truncated. If this is a block device, it'll just be opened.