summaryrefslogtreecommitdiffstats
path: root/libfdisk/src/bsd.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/bsd.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/bsd.c')
-rw-r--r--libfdisk/src/bsd.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/libfdisk/src/bsd.c b/libfdisk/src/bsd.c
index ad0a54f6f..62e4634b6 100644
--- a/libfdisk/src/bsd.c
+++ b/libfdisk/src/bsd.c
@@ -859,6 +859,9 @@ static int bsd_readlabel(struct fdisk_context *cxt)
cxt->geom.heads = d->d_ntracks;
cxt->geom.cylinders = d->d_ncylinders;
+ if (fdisk_has_user_device_geometry(cxt))
+ fdisk_apply_user_device_properties(cxt);
+
cxt->label->nparts_cur = d->d_npartitions;
cxt->label->nparts_max = BSD_MAXPARTITIONS;
DBG(LABEL, ul_debug("read BSD label"));