[PATCH 5/7] fdisk: check for partition boundary

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 fdisk/fdisk.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
index f269164..424ad0d 100644
--- a/fdisk/fdisk.c
+++ b/fdisk/fdisk.c
@@ -1033,6 +1033,7 @@ get_partition_table_geometry(void) {
 	}
 }
 
+
 /*
  * Sets LBA of the first partition
  */
@@ -1797,6 +1798,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);
 	long megabytes = bytes/1000000;
@@ -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);
-- 
1.6.5.1

--
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux