]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fdisk: always print warning for mis-aligned partitions
authorKarel Zak <kzak@redhat.com>
Fri, 8 Aug 2014 09:33:28 +0000 (11:33 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 8 Aug 2014 09:33:28 +0000 (11:33 +0200)
This patch restores the original fdisk behavior and always prints
information about misaligned partitions in 'p'print output.

Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/fdisk.c
libfdisk/src/alignment.c

index 46e632aa3c09dfacf06aabb6ddabd937970c201e..0eeeda116064b4d84627bc6b7a6514cc955220e2 100644 (file)
@@ -538,6 +538,9 @@ void list_disk_geometry(struct fdisk_context *cxt)
 void list_disklabel(struct fdisk_context *cxt)
 {
        struct fdisk_table *tb = NULL;
+       struct fdisk_partition *pa = NULL;
+       struct fdisk_iter *itr;
+
        char *str;
 
        /* print label specific stuff by libfdisk FDISK_ASK_INFO API */
@@ -564,12 +567,20 @@ void list_disklabel(struct fdisk_context *cxt)
                }
        }
 
+       itr = fdisk_new_iter(FDISK_ITER_FORWARD);
+
+       fputc('\n', stdout);
+
+       while (itr && fdisk_table_next_partition(tb, itr, &pa) == 0)
+               fdisk_warn_alignment(cxt, fdisk_partition_get_start(pa),
+                                         fdisk_partition_get_partno(pa) + 1);
+
        if (fdisk_table_wrong_order(tb)) {
-               fputc('\n', stdout);
                fdisk_info(cxt, _("Partition table entries are not in disk order."));
        }
 
        fdisk_unref_table(tb);
+       fdisk_free_iter(itr);
 }
 
 static size_t skip_empty(const unsigned char *buf, size_t i, size_t sz)
index 65b2c4a23f5057fe945c2315d1b85ed73623a404..5c13027c2d08774818bbfa9068e07faee3aa4488 100644 (file)
@@ -105,7 +105,7 @@ sector_t fdisk_align_lba_in_range(struct fdisk_context *cxt,
 void fdisk_warn_alignment(struct fdisk_context *cxt, sector_t lba, int partition)
 {
        if (!lba_is_phy_aligned(cxt, lba))
-               printf(_("Partition %i does not start on physical sector boundary.\n"),
+               fdisk_warnx(cxt, _("Partition %i does not start on physical sector boundary.\n"),
                        partition + 1);
 }