summaryrefslogtreecommitdiffstats
path: root/libfdisk/src/context.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/context.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/context.c')
-rw-r--r--libfdisk/src/context.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c
index 6ede3e468..f2b0f7871 100644
--- a/libfdisk/src/context.c
+++ b/libfdisk/src/context.c
@@ -106,7 +106,7 @@ static void reset_context(struct fdisk_context *cxt)
{
size_t i;
- DBG(CONTEXT, dbgprint("\n-----\nresetting context %p", cxt));
+ DBG(CONTEXT, dbgprint("*** resetting context %p", cxt));
/* reset drives' private data */
for (i = 0; i < cxt->nlabels; i++)
@@ -123,17 +123,7 @@ static void reset_context(struct fdisk_context *cxt)
cxt->dev_path = NULL;
cxt->firstsector = NULL;
- cxt->io_size = 0;
- cxt->optimal_io_size = 0;
- cxt->min_io_size = 0;
- cxt->phy_sector_size = 0;
- cxt->sector_size = 0;
- cxt->alignment_offset = 0;
- cxt->grain = 0;
- cxt->first_lba = 0;
- cxt->total_sectors = 0;
-
- memset(&cxt->geom, 0, sizeof(struct fdisk_geometry));
+ fdisk_zeroize_device_properties(cxt);
cxt->label = NULL;
}
@@ -179,7 +169,10 @@ int fdisk_context_assign_device(struct fdisk_context *cxt,
/* detect labels and apply labes specific stuff (e.g geomery)
* to the context */
fdisk_probe_labels(cxt);
- fdisk_reset_alignment(cxt);
+
+ /* let's apply user geometry *after* label prober
+ * to make it possible to override in-label setting */
+ fdisk_apply_user_device_properties(cxt);
DBG(CONTEXT, dbgprint("context %p initialized for %s [%s]",
cxt, fname,