int ploop_delete_top_delta(struct ploop_disk_images_data *di) { int output = SYSEXIT_PLOOPFMT; if (NULL != di->top_guid) { /* NB. ploop_lock_di inside ploop_delete_snapshot * resets the di content thus the second argument * becomes invalid. backup it and pass that backup * value. * */ output = ploop_delete_snapshot(di, strdupa(di->top_guid)); } return output; }
static int plooptool_snapshot_delete(int argc, char **argv) { int i, ret; char *uuid = NULL; struct ploop_disk_images_data *di = NULL; while ((i = getopt(argc, argv, "u:")) != EOF) { switch (i) { case 'u': uuid = parse_uuid(optarg); if (!uuid) return SYSEXIT_PARAM; break; default: usage_snapshot_delete(); return SYSEXIT_PARAM; } } argc -= optind; argv += optind; if (argc != 1 || !is_xml_fname(argv[0]) || uuid == NULL) { usage_snapshot_delete(); return SYSEXIT_PARAM; } ret = ploop_open_dd(&di, argv[0]); if (ret) return ret; ret = ploop_delete_snapshot(di, uuid); ploop_close_dd(di); return ret; }