summaryrefslogtreecommitdiffstats
path: root/libfdisk/src/context.c
diff options
context:
space:
mode:
authorKarel Zak2017-01-13 12:44:35 +0100
committerKarel Zak2017-01-13 12:56:10 +0100
commit502dd53c864c26124146eb42eb9bbf5bb7b587b9 (patch)
tree74d3da7f6b363094c2b2755e62d57929aab01565 /libfdisk/src/context.c
parentlibfdisk: recount size when apply user device properties (diff)
downloadkernel-qcow2-util-linux-502dd53c864c26124146eb42eb9bbf5bb7b587b9.tar.gz
kernel-qcow2-util-linux-502dd53c864c26124146eb42eb9bbf5bb7b587b9.tar.xz
kernel-qcow2-util-linux-502dd53c864c26124146eb42eb9bbf5bb7b587b9.zip
libfdisk: change the way how apply user device properties
The current code calls fdisk_apply_user_device_properties() after label probing, because we want to overwrite label geometry by user settings (e.g. -C -H -S fdisk options). Unfortunately, this way does not work if we need to use a different sector size, because label probing depends on sector size... So, the right way is to apply user setting to the fdisk context before we start to read from device, and overwrite geometry again after label is already read. Fortunately, this shit is necessary only rarely and for SUN and SGI disk labels. Addresses: https://github.com/karelzak/util-linux/issues/396 Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/context.c')
-rw-r--r--libfdisk/src/context.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c
index 947f104fa..25220f064 100644
--- a/libfdisk/src/context.c
+++ b/libfdisk/src/context.c
@@ -614,17 +614,13 @@ int fdisk_assign_device(struct fdisk_context *cxt,
fdisk_discover_topology(cxt);
fdisk_discover_geometry(cxt);
+ fdisk_apply_user_device_properties(cxt);
+
if (fdisk_read_firstsector(cxt) < 0)
goto fail;
- /* detect labels and apply labels specific stuff (e.g geometry)
- * to the context */
fdisk_probe_labels(cxt);
- /* let's apply user geometry *after* label prober
- * to make it possible to override in-label setting */
- fdisk_apply_user_device_properties(cxt);
-
/* warn about obsolete stuff on the device if we aren't in
* list-only mode and there is not PT yet */
if (!fdisk_is_listonly(cxt) && !fdisk_has_label(cxt) && check_collisions(cxt) < 0)