X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=fish%2Fprep.c;h=718662272df75e5b5e9354977c367a9f4f024c3c;hp=ab5b4bc4748ec494bc5f87de7bfc4a7d3f8c245f;hb=48a216a06d6fdab3c8292c383a37cd990c0bf939;hpb=4a9b979a3199dfef64a342f05d666da540203a7c diff --git a/fish/prep.c b/fish/prep.c index ab5b4bc..7186622 100644 --- a/fish/prep.c +++ b/fish/prep.c @@ -104,6 +104,8 @@ static const struct prep preps[] = { }, }; +#define nr_preps (sizeof preps / sizeof preps[0]) + void list_prepared_drives (void) { @@ -111,7 +113,7 @@ list_prepared_drives (void) printf (_("List of available prepared disk images:\n\n")); - for (i = 0; i < sizeof preps / sizeof preps[0]; ++i) { + for (i = 0; i < nr_preps; ++i) { printf (_("\ guestfish -N %-16s %s\n\ \n\ @@ -156,12 +158,6 @@ struct prep_data { prep_data * create_prepared_file (const char *type_string, const char *filename) { - if (access (filename, F_OK) == 0) { - fprintf (stderr, _("guestfish: file '%s' exists and the '-N' option will not overwrite it\n"), - filename); - exit (EXIT_FAILURE); - } - prep_data *data = parse_type_string (type_string); if (data->prep->prelaunch) data->prep->prelaunch (filename, data); @@ -175,11 +171,11 @@ parse_type_string (const char *type_string) /* Match on the type part (without parameters). */ size_t len = strcspn (type_string, ":"); - for (i = 0; i < sizeof preps / sizeof preps[0]; ++i) + for (i = 0; i < nr_preps; ++i) if (STRCASEEQLEN (type_string, preps[i].name, len)) break; - if (preps[i].name == NULL) { + if (i == nr_preps) { fprintf (stderr, _("\ guestfish: -N parameter '%s': no such prepared disk image known.\n\ Use 'guestfish -N list' to list possible values for the -N parameter.\n"), @@ -272,7 +268,7 @@ prelaunch_part (const char *filename, prep_data *data) static void postlaunch_part (const char *filename, prep_data *data, const char *device) { - if (guestfs_part_disk (g, device, data->params[2]) == -1) + if (guestfs_part_disk (g, device, data->params[1]) == -1) prep_error (data, filename, _("failed to partition disk: %s"), guestfs_last_error (g)); }