return rc;
}
-static struct fdisk_parttype *ask_partition_type(struct fdisk_context *cxt)
+static struct fdisk_parttype *ask_partition_type(struct fdisk_context *cxt, int *canceled)
{
const char *q;
struct fdisk_label *lb;
if (!lb)
return NULL;
+ *canceled = 0;
q = fdisk_label_has_code_parttypes(lb) ?
_("Hex code (type L to list all codes): ") :
_("Partition type (type L to list all types): ");
char buf[256];
int rc = get_user_reply(q, buf, sizeof(buf));
- if (rc)
+ if (rc) {
+ if (rc == -ECANCELED)
+ *canceled = 1;
break;
+ }
if (buf[1] == '\0' && toupper(*buf) == 'L')
list_partition_types(cxt);
struct fdisk_parttype *t = NULL;
struct fdisk_partition *pa = NULL;
const char *old = NULL;
+ int canceled = 0;
assert(cxt);
old = t ? fdisk_parttype_get_name(t) : _("Unknown");
do {
- t = ask_partition_type(cxt);
+ t = ask_partition_type(cxt, &canceled);
+ if (canceled)
+ break;
} while (!t);
- if (fdisk_set_partition_type(cxt, i, t) == 0)
+ if (canceled == 0 && fdisk_set_partition_type(cxt, i, t) == 0)
fdisk_info(cxt,
_("Changed type of partition '%s' to '%s'."),
old, t ? fdisk_parttype_get_name(t) : _("Unknown"));