fdisk: use fdisk_reread_changes()
Let's make fdisk usable for disks where some partitions are mounted. Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
1dd63a3b05
commit
fadd8e0877
|
@ -582,6 +582,10 @@ static int generic_menu_cb(struct fdisk_context **cxt0,
|
|||
if (fdisk_get_parent(cxt))
|
||||
break; /* nested PT, don't leave */
|
||||
fdisk_info(cxt, _("The partition table has been altered."));
|
||||
|
||||
if (device_is_used)
|
||||
rc = fdisk_reread_changes(cxt, original_layout);
|
||||
else
|
||||
rc = fdisk_reread_partition_table(cxt);
|
||||
if (!rc)
|
||||
rc = fdisk_deassign_device(cxt, 0);
|
||||
|
|
|
@ -52,6 +52,9 @@
|
|||
#endif
|
||||
|
||||
int pwipemode = WIPEMODE_AUTO;
|
||||
int device_is_used;
|
||||
struct fdisk_table *original_layout;
|
||||
|
||||
static int wipemode = WIPEMODE_AUTO;
|
||||
|
||||
/*
|
||||
|
@ -1036,6 +1039,11 @@ int main(int argc, char **argv)
|
|||
|
||||
init_fields(cxt, outarg, NULL); /* -o <columns> */
|
||||
|
||||
if (!fdisk_is_readonly(cxt)) {
|
||||
fdisk_get_partitions(cxt, &original_layout);
|
||||
device_is_used = fdisk_device_is_used(cxt);
|
||||
}
|
||||
|
||||
while (1)
|
||||
process_fdisk_menu(&cxt);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#define FDISKPROG_DEBUG_ALL 0xFFFF
|
||||
|
||||
extern int pwipemode;
|
||||
extern struct fdisk_table *original_layout;
|
||||
extern int device_is_used;
|
||||
|
||||
UL_DEBUG_DECLARE_MASK(fdisk);
|
||||
#define DBG(m, x) __UL_DBG(fdisk, FDISKPROG_DEBUG_, m, x)
|
||||
|
|
Loading…
Reference in New Issue