summaryrefslogtreecommitdiffstats
path: root/libfdisk/src/label.c
diff options
context:
space:
mode:
authorKarel Zak2013-05-24 11:48:58 +0200
committerKarel Zak2013-09-16 16:46:57 +0200
commit1653f0b0c2e825f53f0ad067967a6cd696b95227 (patch)
treea68899b2d725e096f90733de0c9890c8650b20aa /libfdisk/src/label.c
parentfdisk: (sgi) remove printf from code (diff)
downloadkernel-qcow2-util-linux-1653f0b0c2e825f53f0ad067967a6cd696b95227.tar.gz
kernel-qcow2-util-linux-1653f0b0c2e825f53f0ad067967a6cd696b95227.tar.xz
kernel-qcow2-util-linux-1653f0b0c2e825f53f0ad067967a6cd696b95227.zip
libfdisk: make it possible to reset device properties
- remember user C/H/S and sector size - reset all device properties before create a new label (maybe the old setting has been affected by previous on-disk label) - always apply user setting after the reset - improve topology/geometry debug messages Note that for fdisk "user C/H/S and sector size" means on command line specified values. If you override the setting by c/h/s commands in expert menu then the setting is applied to the current disk label only. If you create a new disk label (e.g change MBR to GPT) then fdisk will use the original setting. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/label.c')
-rw-r--r--libfdisk/src/label.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libfdisk/src/label.c b/libfdisk/src/label.c
index d518d876d..cabf3d751 100644
--- a/libfdisk/src/label.c
+++ b/libfdisk/src/label.c
@@ -182,6 +182,8 @@ int fdisk_delete_partition(struct fdisk_context *cxt, size_t partnum)
*/
int fdisk_create_disklabel(struct fdisk_context *cxt, const char *name)
{
+ int haslabel = 0;
+
if (!cxt)
return -EINVAL;
@@ -193,8 +195,10 @@ int fdisk_create_disklabel(struct fdisk_context *cxt, const char *name)
#endif
}
- if (cxt->label)
+ if (cxt->label) {
fdisk_deinit_label(cxt->label);
+ haslabel = 1;
+ }
cxt->label = fdisk_context_get_label(cxt, name);
if (!cxt->label)
@@ -204,7 +208,8 @@ int fdisk_create_disklabel(struct fdisk_context *cxt, const char *name)
if (!cxt->label->op->create)
return -ENOSYS;
- fdisk_reset_alignment(cxt);
+ if (haslabel)
+ fdisk_reset_device_properties(cxt);
return cxt->label->op->create(cxt);
}