summaryrefslogtreecommitdiffstats
path: root/source/a/util-linux/0002-fdisk-don-t-ignore-1MiB-granularity-on-512-byte-sect.patch
blob: 4d3622c32c7fc533f9183b4f8243cda2407b222f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
--- ./fdisk/fdisk.c.orig	2012-05-25 04:44:58.977195366 -0500
+++ ./fdisk/fdisk.c	2012-08-02 12:00:59.692457377 -0500
@@ -569,6 +569,19 @@
 lba_is_aligned(unsigned long long lba)
 {
 	unsigned int granularity = max(phy_sector_size, min_io_size);
+	unsigned long long offset;
+
+	if (grain > granularity)
+		granularity = grain;
+	offset = (lba * sector_size) & (granularity - 1);
+
+	return !((granularity + alignment_offset - offset) & (granularity - 1));
+}
+
+static int
+lba_is_phy_aligned(unsigned long long lba)
+{
+	unsigned int granularity = max(phy_sector_size, min_io_size);
 	unsigned long long offset = (lba * sector_size) & (granularity - 1);
 
 	return !((granularity + alignment_offset - offset) & (granularity - 1));
@@ -1808,7 +1821,7 @@
 static void
 check_alignment(unsigned long long lba, int partition)
 {
-	if (!lba_is_aligned(lba))
+	if (!lba_is_phy_aligned(lba))
 		printf(_("Partition %i does not start on physical sector boundary.\n"),
 			partition + 1);
 }