summaryrefslogtreecommitdiffstats
path: root/master/debian/grub_legacy_0_based_partitions.patch
blob: f245434ed24ceac0159d5f22da2c5d2baf4c4501 (plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
Index: b/grub-core/kern/emu/hostdisk.c
===================================================================
--- a/grub-core/kern/emu/hostdisk.c
+++ b/grub-core/kern/emu/hostdisk.c
@@ -1131,7 +1131,7 @@
   char *bsd_part_str = NULL;
 
   if (dos_part >= 0)
-    dos_part_str = xasprintf (",%d", dos_part + 1);
+    dos_part_str = xasprintf (",%d", dos_part + (getenv ("GRUB_LEGACY_0_BASED_PARTITIONS") ? 0 : 1));
 
   if (bsd_part >= 0)
     bsd_part_str = xasprintf (",%d", bsd_part + 1);
@@ -1619,6 +1619,29 @@
 
 	if (start == part_start)
 	  {
+	    if (getenv ("GRUB_LEGACY_0_BASED_PARTITIONS"))
+	      {
+		int dos_part, bsd_part;
+		char *fullname, *comma;
+
+		if (partition->parent)
+		  {
+		    dos_part = partition->parent->number;
+		    bsd_part = partition->number;
+		  }
+		else
+		  {
+		    dos_part = partition->number;
+		    bsd_part = -1;
+		  }
+
+		fullname = make_device_name (drive, dos_part, bsd_part);
+		comma = strchr (fullname, ',');
+		partname = comma ? xstrdup (comma + 1) : NULL;
+		free (fullname);
+		return 1;
+	      }
+
 	    partname = grub_partition_get_name (partition);
 	    return 1;
 	  }