From: Karel Zak Date: Tue, 3 Nov 2009 11:09:36 +0000 (+0100) Subject: fdisk: check for partition boundary X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8e23f2d20f7dd21a318c070b14b45075c8170d4f;p=util-linux fdisk: check for partition boundary 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 --- diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c index f269164c..424ad0d4 100644 --- a/fdisk/fdisk.c +++ b/fdisk/fdisk.c @@ -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);