diff --git a/src/cli.cpp b/src/cli.cpp index 9f98fe87..7b0689c6 100644 --- a/src/cli.cpp +++ b/src/cli.cpp @@ -103,7 +103,7 @@ void cli_tool_t::help() "%s snap-create [-p|--pool ] @\n" " Create a snapshot of image . May be used live if only a single writer is active.\n" "\n" - "%s modify [--rename ] [-s|--size ] [--readonly | --readwrite] [-f|--force]\n" + "%s modify [--rename ] [--resize ] [--readonly | --readwrite] [-f|--force]\n" " Rename, resize image or change its readonly status. Images with children can't be made read-write.\n" " If the new size is smaller than the old size, extra data will be purged.\n" " You should resize file system in the image, if present, before shrinking it.\n" diff --git a/src/cli_modify.cpp b/src/cli_modify.cpp index 59d58da8..0b6ff265 100644 --- a/src/cli_modify.cpp +++ b/src/cli_modify.cpp @@ -63,6 +63,15 @@ struct image_changer_t break; } } + if ((!set_readwrite || !cfg.readonly) && + (!set_readonly || cfg.readonly) && + (!new_size || cfg.size == new_size) && + (new_name == "" || new_name == image_name)) + { + printf("No change\n"); + state = 100; + return; + } if (new_size != 0) { if (cfg.size >= new_size) @@ -201,11 +210,7 @@ std::function cli_tool_t::start_modify(json11::Json cfg) exit(1); } changer->new_name = cfg["rename"].string_value(); - if (changer->new_name == changer->image_name) - { - changer->new_name = ""; - } - changer->new_size = cfg["size"].uint64_value(); + changer->new_size = parse_size(cfg["resize"].string_value()); if (changer->new_size != 0 && (changer->new_size % 4096)) { fprintf(stderr, "Image size should be a multiple of 4096\n");