[Top][All Lists]

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

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

From: Vladimir Serbinenko
Subject: Re: [PATCH]: grub: Partitions can start at zero.
Date: Mon, 20 Apr 2009 18:53:35 +0200

On Mon, Apr 20, 2009 at 2:30 AM, David Miller <address@hidden> wrote:

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 :-)
What about the way I proposed in thread on implementing nested partitions?

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);

Grub-devel mailing list

reply via email to

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