struct cfdisk {
struct fdisk_context *cxt; /* libfdisk context */
struct fdisk_table *table; /* partition table */
+ struct fdisk_table *original_layout; /* original on-disk PT */
struct cfdisk_menu *menu; /* the current menu */
#endif
unsigned int wrong_order :1, /* PT not in right order */
zero_start :1, /* ignore existing partition table */
+ device_is_used : 1, /* don't use re-read ioctl */
show_extra :1; /* show extra partinfo */
};
if (rc)
warn = _("Failed to write disklabel.");
else {
- fdisk_reread_partition_table(cf->cxt);
+ if (cf->device_is_used)
+ fdisk_reread_changes(cf->cxt, cf->original_layout);
+ else
+ fdisk_reread_partition_table(cf->cxt);
info = _("The partition table has been altered.");
}
cf->nwrites++;
if (rc != 0)
err(EXIT_FAILURE, _("cannot open %s"), diskpath);
+ if (!fdisk_is_readonly(cf->cxt)) {
+ cf->device_is_used = fdisk_device_is_used(cf->cxt);
+ fdisk_get_partitions(cf->cxt, &cf->original_layout);
+ }
+
/* Don't use err(), warn() from this point */
ui_init(cf);
ui_run(cf);