+ case 'r': /* resize */
+ {
+ uint64_t size, max_size, secs;
+ struct fdisk_partition *npa;
+
+ if (fdisk_partition_is_freespace(pa) || !fdisk_partition_has_start(pa))
+ return -EINVAL;
+
+ rc = fdisk_partition_get_max_size(cf->cxt,
+ fdisk_partition_get_partno(pa),
+ &size);
+ if (rc)
+ return rc;
+
+ size *= fdisk_get_sector_size(cf->cxt);
+ max_size = size;
+
+ if (ui_get_size(cf, _("New size: "), &size,
+ fdisk_get_sector_size(cf->cxt),
+ max_size, NULL) == -CFDISK_ERR_ESC)
+ break;
+ secs = size / fdisk_get_sector_size(cf->cxt);
+ npa = fdisk_new_partition();
+ if (!npa)
+ return -ENOMEM;
+
+ fdisk_partition_set_size(npa, secs);
+
+ rc = fdisk_set_partition(cf->cxt, n, npa);
+ fdisk_unref_partition(npa);
+ if (rc == 0) {
+ ref = 1;
+ info = _("Partition %zu resized.");
+ }
+ break;
+ }