Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1LvhPI-0004q9-6F for mharc-grub-devel@gnu.org; Sun, 19 Apr 2009 20:30:44 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LvhPF-0004q0-Qp for grub-devel@gnu.org; Sun, 19 Apr 2009 20:30:41 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LvhPE-0004pn-Es for grub-devel@gnu.org; Sun, 19 Apr 2009 20:30:40 -0400 Received: from [199.232.76.173] (port=43425 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LvhPE-0004pk-9I for grub-devel@gnu.org; Sun, 19 Apr 2009 20:30:40 -0400 Received: from [74.93.104.97] (port=54253 helo=sunset.davemloft.net) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LvhPD-0007ov-UB for grub-devel@gnu.org; Sun, 19 Apr 2009 20:30:40 -0400 Received: from localhost (localhost [127.0.0.1]) by sunset.davemloft.net (Postfix) with ESMTP id D424935C12C for ; Sun, 19 Apr 2009 17:30:31 -0700 (PDT) Date: Sun, 19 Apr 2009 17:30:31 -0700 (PDT) Message-Id: <20090419.173031.143347517.davem@davemloft.net> To: grub-devel@gnu.org From: David Miller X-Mailer: Mew version 6.2.51 on Emacs 22.1 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: [PATCH]: grub: Partitions can start at zero. X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Apr 2009 00:30:42 -0000 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 * 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