summaryrefslogtreecommitdiffstats
path: root/fdisk/fdisk.c
diff options
context:
space:
mode:
authorKarel Zak2010-03-19 15:56:27 +0100
committerKarel Zak2010-03-19 15:56:27 +0100
commit7f152745c33567f49807019fd4f5f72eadfd4fd4 (patch)
tree3ce1170267b974feae48c4f64c1ad150fae920a0 /fdisk/fdisk.c
parentdocs: update TODO file (diff)
downloadkernel-qcow2-util-linux-7f152745c33567f49807019fd4f5f72eadfd4fd4.tar.gz
kernel-qcow2-util-linux-7f152745c33567f49807019fd4f5f72eadfd4fd4.tar.xz
kernel-qcow2-util-linux-7f152745c33567f49807019fd4f5f72eadfd4fd4.zip
fdisk: fix -b <sectorsize>
The old fdisk (<2.17) does not differentiate between logical and physical sector size, it uses the <sectorsize> for everything. Now, we have logical and physical sectors size, but the -b option changes the logical size only. The second bug is that "fdisk -b <sz>" does not read topology information (it means that all I/O limits and physical sector size are 512 (default). The backwardly compatible bug fix is to override both sizes, logical and physical if "-b" is used. In future we can add a special option for physical size only. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'fdisk/fdisk.c')
-rw-r--r--fdisk/fdisk.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
index 2a6d419f3..f5c67904c 100644
--- a/fdisk/fdisk.c
+++ b/fdisk/fdisk.c
@@ -976,8 +976,6 @@ get_topology(int fd) {
#ifdef HAVE_LIBBLKID_INTERNAL
blkid_probe pr;
- if (user_set_sector_size)
- return;
pr = blkid_new_probe();
if (pr && blkid_probe_set_device(pr, fd, 0, 0) == 0) {
blkid_topology tp = blkid_probe_get_topology(pr);
@@ -1006,12 +1004,20 @@ get_topology(int fd) {
#endif
if (user_set_sector_size)
- ;
- else if (blkdev_get_sector_size(fd, &arg) == 0)
+ /* fdisk since 2.17 differentiate between logical and physical
+ * sectors size. For backward compatibility the
+ * fdisk -b <sectorsize>
+ * changes both, logical and physical sector size.
+ */
+ phy_sector_size = sector_size;
+
+ else if (blkdev_get_sector_size(fd, &arg) == 0) {
sector_size = arg;
- if (!phy_sector_size)
- phy_sector_size = sector_size;
+ if (!phy_sector_size)
+ phy_sector_size = sector_size;
+ }
+
if (!min_io_size)
min_io_size = phy_sector_size;
if (!io_size)