From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1JvM00-0002rc-Bc for mharc-grub-devel@gnu.org; Sun, 11 May 2008 20:34:40 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JvLzy-0002qu-Dc for grub-devel@gnu.org; Sun, 11 May 2008 20:34:38 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JvLzx-0002qc-3h for grub-devel@gnu.org; Sun, 11 May 2008 20:34:38 -0400 Received: from [199.232.76.173] (port=47215 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JvLzw-0002qZ-NZ for grub-devel@gnu.org; Sun, 11 May 2008 20:34:36 -0400 Received: from c60.cesmail.net ([216.154.195.49]:9548) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.60) (envelope-from ) id 1JvLzw-0008Rf-5I for grub-devel@gnu.org; Sun, 11 May 2008 20:34:36 -0400 Received: from unknown (HELO relay.cesmail.net) ([192.168.1.81]) by c60.cesmail.net with ESMTP; 11 May 2008 20:34:34 -0400 Received: from [192.168.1.21] (static-72-92-88-10.phlapa.fios.verizon.net [72.92.88.10]) by relay.cesmail.net (Postfix) with ESMTP id 64AAF619058 for ; Sun, 11 May 2008 20:34:34 -0400 (EDT) From: Pavel Roskin To: The development of GRUB 2 Content-Type: text/plain Date: Sun, 11 May 2008 20:34:33 -0400 Message-Id: <1210552473.24691.18.camel@dv> Mime-Version: 1.0 X-Mailer: Evolution 2.22.1 (2.22.1-2.fc9) Content-Transfer-Encoding: 7bit X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [PATCH RFC] Simplifying linux_find_partition() 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, 12 May 2008 00:34:38 -0000 Hello! linux_find_partition() is used to make it possible to access partitions using the native OS devices for the partitions, rather than the device for the whole drive. As new devices are supported by GRUB, linux_find_partition() should be updated to support them, but this is not always done. The reason is that the problem is not obvious and doesn't prevent the basic functionality. This patch simplifies the code and makes it handle all devices supported by Linux, perhaps even all devices that will be supported. I'm assuming that linux_find_partition() is only called for whole drives, not for partitions, so the code doesn't need to strip anything from the device name. We only need to strip "disc" from devfs names. Also, I checked devices.txt from Linux, and I see a simple pattern there. If the device ends in a number, the partitions are made by adding "p" and the number. Otherwise, only the number is added. ChangeLog: * util/biosdisk.c (linux_find_partition): Don't try to handle anything but whole drives. Simplify logic. Add "p%d" after numbers and "%d" after other characters. diff --git a/util/biosdisk.c b/util/biosdisk.c index fcf01a4..7079a97 100644 --- a/util/biosdisk.c +++ b/util/biosdisk.c @@ -226,40 +226,16 @@ linux_find_partition (char *dev, unsigned long sector) p = real_dev + len - 4; format = "part%d"; } - else if ((strncmp (real_dev + 5, "hd", 2) == 0 - || strncmp (real_dev + 5, "vd", 2) == 0 - || strncmp (real_dev + 5, "sd", 2) == 0) - && real_dev[7] >= 'a' && real_dev[7] <= 'z') + else if (real_dev[len - 1] >= '0' && real_dev[len - 1] <= '9') { - p = real_dev + 8; - format = "%d"; - } - else if (strncmp (real_dev + 5, "rd/c", 4) == 0) /* dac960 */ - { - p = strchr (real_dev + 9, 'd'); - if (! p) - return 0; - - p++; - while (*p && isdigit (*p)) - p++; - + p = real_dev + len; format = "p%d"; } - else if (strncmp (real_dev + 5, "cciss/c", sizeof("cciss/c")-1) == 0) + else { - p = strchr (real_dev + 5 + sizeof("cciss/c")-1, 'd'); - if (! p) - return 0; - - p++; - while (*p && isdigit (*p)) - p++; - - format = "p%d"; + p = real_dev + len; + format = "%d"; } - else - return 0; for (i = 1; i < 10000; i++) { -- Regards, Pavel Roskin