diff options
author | Karel Zak | 2017-01-13 12:44:35 +0100 |
---|---|---|
committer | Karel Zak | 2017-01-13 12:56:10 +0100 |
commit | 502dd53c864c26124146eb42eb9bbf5bb7b587b9 (patch) | |
tree | 74d3da7f6b363094c2b2755e62d57929aab01565 /libfdisk/src/alignment.c | |
parent | libfdisk: recount size when apply user device properties (diff) | |
download | kernel-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/alignment.c')
-rw-r--r-- | libfdisk/src/alignment.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libfdisk/src/alignment.c b/libfdisk/src/alignment.c index c4496fe9f..15d6140ed 100644 --- a/libfdisk/src/alignment.c +++ b/libfdisk/src/alignment.c @@ -321,11 +321,13 @@ int fdisk_save_user_sector_size(struct fdisk_context *cxt, */ int fdisk_has_user_device_properties(struct fdisk_context *cxt) { - return (cxt->user_pyh_sector - || cxt->user_log_sector - || cxt->user_geom.heads - || cxt->user_geom.sectors - || cxt->user_geom.cylinders); + return (cxt->user_pyh_sector || cxt->user_log_sector || + fdisk_has_user_device_geometry(cxt)); +} + +int fdisk_has_user_device_geometry(struct fdisk_context *cxt) +{ + return (cxt->user_geom.heads || cxt->user_geom.sectors || cxt->user_geom.cylinders); } int fdisk_apply_user_device_properties(struct fdisk_context *cxt) |