diff options
author | Karel Zak | 2017-01-13 12:16:06 +0100 |
---|---|---|
committer | Karel Zak | 2017-01-13 12:16:06 +0100 |
commit | e86c73164fccf600802612bc033128bcef305341 (patch) | |
tree | 0763e9df0d175966d4dde9344636c408e8a5a894 /libfdisk | |
parent | libfdisk: don't use blkdev ioctls for regular files (diff) | |
download | kernel-qcow2-util-linux-e86c73164fccf600802612bc033128bcef305341.tar.gz kernel-qcow2-util-linux-e86c73164fccf600802612bc033128bcef305341.tar.xz kernel-qcow2-util-linux-e86c73164fccf600802612bc033128bcef305341.zip |
libfdisk: recount size when apply user device properties
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk')
-rw-r--r-- | libfdisk/src/alignment.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libfdisk/src/alignment.c b/libfdisk/src/alignment.c index b874a48f8..c4496fe9f 100644 --- a/libfdisk/src/alignment.c +++ b/libfdisk/src/alignment.c @@ -337,10 +337,19 @@ int fdisk_apply_user_device_properties(struct fdisk_context *cxt) if (cxt->user_pyh_sector) cxt->phy_sector_size = cxt->user_pyh_sector; - if (cxt->user_log_sector) + if (cxt->user_log_sector) { + uint64_t old_total = cxt->total_sectors; + uint64_t old_secsz = cxt->sector_size; + cxt->sector_size = cxt->min_io_size = cxt->io_size = cxt->user_log_sector; + if (cxt->sector_size != old_secsz) { + cxt->total_sectors = (old_total * (old_secsz/512)) / (cxt->sector_size >> 9); + DBG(CXT, ul_debugobj(cxt, "new total sectors: %ju", cxt->total_sectors)); + } + } + if (cxt->user_geom.heads) cxt->geom.heads = cxt->user_geom.heads; if (cxt->user_geom.sectors) |