grub-devel
[Top][All Lists]
Advanced

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

[PATCH]: grub: Partitions can start at zero.


From: David Miller
Subject: [PATCH]: grub: Partitions can start at zero.
Date: Sun, 19 Apr 2009 17:30:31 -0700 (PDT)

With Sun partitions, individual partitions can start at disk
address zero.  That's right, zero.

This works because UFS and EXT{2,3,4} superblocks are offset
far enough into the partition that it won't overwrite the
disk label nor the boot block.

I added an, arguably hackish, heuristic to handle this properly.
Basically if the OS device name does not end in a digit we'll believe
that a zero hdg.start value can be a partition.

If anyone has a better way to handle this, let me know :-)

2009-04-19  David S. Miller  <address@hidden>

        * util/hostdisk.c (device_is_wholedisk): New function.
        (grub_util_biosdisk_get_grub_dev): Shortcut when hdg.start is
        zero only if device_is_wholedisk() returns true.
---
 util/hostdisk.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/util/hostdisk.c b/util/hostdisk.c
index aa41703..b55d7fe 100644
--- a/util/hostdisk.c
+++ b/util/hostdisk.c
@@ -827,6 +827,16 @@ convert_system_partition_to_system_disk (const char 
*os_dev)
 }
 
 static int
+device_is_wholedisk (const char *os_dev)
+{
+  int len = strlen (os_dev);
+
+  if (os_dev[len - 1] < '0' || os_dev[len - 1] > '9')
+    return 1;
+  return 0;
+}
+
+static int
 find_system_device (const char *os_dev)
 {
   int i;
@@ -961,7 +971,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
 
     grub_util_info ("%s starts from %lu", os_dev, hdg.start);
     
-    if (hdg.start == 0)
+    if (hdg.start == 0 && device_is_wholedisk (os_dev))
       return name;
 
     grub_util_info ("opening the device %s", name);
-- 
1.6.2.3





reply via email to

[Prev in Thread] Current Thread [Next in Thread]