{ 'q', N_("Quit"), N_("Quit program without writing partition table") },
{ 't', N_("Type"), N_("Change the partition type") },
{ 'h', N_("Help"), N_("Print help screen") },
+ { 's', N_("Sort"), N_("Fix partitions order") },
{ 'W', N_("Write"), N_("Write partition table to disk (this might destroy data)") },
{ 0, NULL, NULL }
};
size_t nlines; /* number of lines */
size_t lines_idx; /* current line <0..N>, exclude header */
size_t page_sz;
+
+ unsigned int wrong_order :1; /* PT not in right order */
};
/* Initialize output columns -- we follow libcfdisk columns (usually specific
cf->linesbufsz = strlen(cf->linesbuf);
cf->nlines = fdisk_table_get_nents(cf->table) + 1; /* 1 for header line */
cf->page_sz = 0;
+ cf->wrong_order = fdisk_table_wrong_order(cf->table) ? 1 : 0;
if (MENU_START_LINE - TABLE_START_LINE < cf->nlines)
cf->page_sz = MENU_START_LINE - TABLE_START_LINE - 1;
N_(" n Create new partition from free space"),
N_(" q Quit program without writing partition table"),
N_(" t Change the partition type"),
+ N_(" s Fix partitions order"),
N_(" W Write partition table to disk (must enter upper case W)"),
N_(" Since this might destroy data on the disk, you must"),
N_(" either confirm or deny the write by entering `yes' or"),
ignore[i++] = 'b';
}
-
+ if (!cf->wrong_order)
+ ignore[i++] = 's';
if (fdisk_context_is_readonly(cf->cxt))
ignore[i++] = 'W';
return i;
static int main_menu_action(struct cfdisk *cf, int key)
{
size_t n;
- int ref = 0, rc;
+ int ref = 0, rc, org_order = cf->wrong_order;
const char *info = NULL, *warn = NULL;
struct fdisk_partition *pa;
info = _("Type of the partition %zu is unchanged.");
break;
}
+ case 's': /* fix order */
+ if (cf->wrong_order) {
+ fdisk_reorder_partitions(cf->cxt);
+ ref = 1;
+ }
+ break;
case 'W': /* Write */
{
char buf[64] = { 0 };
ui_warnx(warn, n + 1);
else if (info)
ui_info(info, n + 1);
+ else if (key == 'n' && cf->wrong_order && org_order == 0)
+ ui_info(_("Note that partition table entries are not in disk order now."));
return 0;
}