]> err.no Git - util-linux/commitdiff
fdisk: check for partition boundary
authorKarel Zak <kzak@redhat.com>
Tue, 3 Nov 2009 11:09:36 +0000 (12:09 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 18 Nov 2009 10:25:10 +0000 (11:25 +0100)
Disk /dev/md0: 419 MB, 419168256 bytes
2 heads, 4 sectors/track, 102336 cylinders, total 818688 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 65536 bytes
Disk identifier: 0x081479c3

    Device Boot      Start         End      Blocks   Id  System
/dev/md0p1             200      818687      409244   83  Linux
Partition 1 does not start on physical block boundary.

Signed-off-by: Karel Zak <kzak@redhat.com>
fdisk/fdisk.c

index f269164c1efc1dfbb752ef93c52b4d7ac9c04494..424ad0d40f35f11fca314e7a0723f78ab0430f23 100644 (file)
@@ -1033,6 +1033,7 @@ get_partition_table_geometry(void) {
        }
 }
 
+
 /*
  * Sets LBA of the first partition
  */
@@ -1796,6 +1797,14 @@ static void check_consistency(struct partition *p, int partition) {
        }
 }
 
+static void
+check_alignment(struct partition *p, int partition)
+{
+       if (!lba_is_aligned(get_start_sect(p)))
+               printf(_("Partition %i does not start on physical block boundary.\n"),
+                       partition + 1);
+}
+
 static void
 list_disk_geometry(void) {
        long long bytes = (total_number_of_sectors << 9);
@@ -2031,6 +2040,7 @@ list_table(int xtra) {
 /* type name */                (type = partition_type(p->sys_ind)) ?
                        type : _("Unknown"));
                        check_consistency(p, i);
+                       check_alignment(p, i);
                }
        }
 
@@ -2063,8 +2073,10 @@ x_list_table(int extend) {
                                cylinder(p->end_sector, p->end_cyl),
                                (unsigned long) get_start_sect(p),
                                (unsigned long) get_nr_sects(p), p->sys_ind);
-                       if (p->sys_ind)
+                       if (p->sys_ind) {
                                check_consistency(p, i);
+                               check_alignment(p, i);
+                       }
                }
        }
 }
@@ -2141,6 +2153,7 @@ verify(void) {
                p = pe->part_table;
                if (p->sys_ind && !IS_EXTENDED (p->sys_ind)) {
                        check_consistency(p, i);
+                       check_alignment(p, i);
                        if (get_partition_start(pe) < first[i])
                                printf(_("Warning: bad start-of-data in "
                                        "partition %d\n"), i + 1);