]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: fix fdisk_get_optimal_iosize() and update tests
authorKarel Zak <kzak@redhat.com>
Wed, 20 Aug 2014 09:43:02 +0000 (11:43 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 20 Aug 2014 09:43:02 +0000 (11:43 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/fdisk.c
libfdisk/src/context.c
tests/expected/fdisk/bsd
tests/expected/fdisk/gpt
tests/expected/fdisk/mbr-dos-mode
tests/expected/fdisk/mbr-nondos-mode
tests/expected/fdisk/oddinput
tests/expected/fdisk/sunlabel

index b3d1ac311e18e0206f68dd83b57c58dc6ae4bd1d..cd70dc99b12f070e65796c8e4dac77dc07932a84 100644 (file)
@@ -528,7 +528,7 @@ void list_disk_geometry(struct fdisk_context *cxt)
                        bytes, (uintmax_t) fdisk_get_nsectors(cxt));
        free(strsz);
 
-       if (fdisk_label_require_geometry(lb) || fdisk_use_cylinders(cxt))
+       if (lb && (fdisk_label_require_geometry(lb) || fdisk_use_cylinders(cxt)))
                fdisk_info(cxt, _("Geometry: %d heads, %llu sectors/track, %llu cylinders"),
                               fdisk_get_geom_heads(cxt),
                               fdisk_get_geom_sectors(cxt),
index 8aaa4972634a37f98fde31c81bc137f451ce0869..4232448175c4e09d110f99c31c7fb38db192cf0a 100644 (file)
@@ -645,12 +645,16 @@ unsigned int fdisk_get_units_per_sector(struct fdisk_context *cxt)
  * fdisk_get_optimal_iosize:
  * @cxt: context
  *
+ * The optimal I/O is optional and does not have to be provided by device,
+ * anyway libfdisk never returns zero. If the optimal I/O size is not provided
+ * then libfdisk returns minimal I/O size or sector size.
+ *
  * Returns: optimal I/O size
  */
 unsigned long fdisk_get_optimal_iosize(struct fdisk_context *cxt)
 {
        assert(cxt);
-       return cxt->optimal_io_size;
+       return cxt->optimal_io_size ? cxt->optimal_io_size : cxt->io_size;
 }
 
 /**
index 3965a73a6dad4a331168283c95e070631d34a219..679731efa3b07b3222c027b5d7f626c77cefd9fa 100644 (file)
@@ -10,8 +10,6 @@ Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disklabel type: dos
 Disk identifier: <removed>
-
-
 -------------------
 
 Create 1st primary partition
index 2ca66ab842d3d83802fe65a7fbc2669725558b96..b5c29b6d815ccc05cabb38030359d486796b7ba7 100644 (file)
@@ -8,8 +8,6 @@ Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disklabel type: gpt
 Disk identifier: <removed>
-
-
 -------------------
 
 Create partitions
index 62c454a989e8436c72bd4953d5c8db2fd6022673..1b54d0939d9e56c9f57539914b5c802a128e5ef2 100644 (file)
@@ -11,8 +11,6 @@ Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disklabel type: dos
 Disk identifier: <removed>
-
-
 -------------------
 
 Create primary partition
@@ -194,7 +192,5 @@ Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disklabel type: dos
 Disk identifier: <removed>
-
-
 -------------------
 
index 89396af46f884c5ee0fc45f814fdb4ea8143e074..d24691cd49331dc24e9138044d5dab0a927c9a85 100644 (file)
@@ -10,8 +10,6 @@ Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disklabel type: dos
 Disk identifier: <removed>
-
-
 -------------------
 
 Create 1st primary partition
@@ -208,7 +206,5 @@ Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disklabel type: dos
 Disk identifier: <removed>
-
-
 -------------------
 
index 7a91f8d2fe3fbd6c8f3cce968a9cb705f5eb85bd..0ba07c6691478c71e5a71ea06cb96fd3ce2a8088 100644 (file)
@@ -3,7 +3,6 @@ f1c9645dbc14efddc7d8a322685f26eb oddinput.img
 Empty image listing
 
 Disk testimage: 10 MiB, 10485760 bytes, 20480 sectors
-Geometry: 255 heads, 63 sectors/track, 1 cylinders
 Units: cylinders of 16065 * 512 = 8225280 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
index 2ee79436fe9512908e602bc84b0df9c703b8e200..7045b61a789b60a5d3ccf12742c68107a569b618 100644 (file)
@@ -9,8 +9,6 @@ Units: cylinders of 63 * 512 = 32256 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disklabel type: sun
-
-
 Create first partition
 e730c7ec8208601f41963f0485147248 sunlabel.img