From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Jva1b-0001f7-6Q for mharc-grub-devel@gnu.org; Mon, 12 May 2008 11:33:15 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Jva1Z-0001dI-0Y for grub-devel@gnu.org; Mon, 12 May 2008 11:33:13 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Jva1X-0001co-Gp for grub-devel@gnu.org; Mon, 12 May 2008 11:33:12 -0400 Received: from [199.232.76.173] (port=53581 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jva1X-0001cl-B0 for grub-devel@gnu.org; Mon, 12 May 2008 11:33:11 -0400 Received: from aybabtu.com ([69.60.117.155]:58059) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Jva1X-0007BA-0B for grub-devel@gnu.org; Mon, 12 May 2008 11:33:11 -0400 Received: from [192.168.10.6] (helo=thorin) by aybabtu.com with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1Jva1V-0000YO-Jy for grub-devel@gnu.org; Mon, 12 May 2008 17:33:10 +0200 Received: from rmh by thorin with local (Exim 4.63) (envelope-from ) id 1Jva0s-0000eB-Ec for grub-devel@gnu.org; Mon, 12 May 2008 17:32:30 +0200 Date: Mon, 12 May 2008 17:32:29 +0200 From: Robert Millan To: The development of GRUB 2 Message-ID: <20080512153229.GB1841@thorin> References: <1210552473.24691.18.camel@dv> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1210552473.24691.18.camel@dv> Organization: free as in freedom X-Message-Flag: Worried about Outlook viruses? Switch to Thunderbird! www.mozilla.com/thunderbird X-Debbugs-No-Ack: true User-Agent: Mutt/1.5.13 (2006-08-11) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. Subject: Re: [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 15:33:13 -0000 On Sun, May 11, 2008 at 08:34:33PM -0400, Pavel Roskin wrote: > 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. Good catch! But please make sure it's never called for partitions. Also, perhaps an even simpler logic could be: if (real_dev[len - 1] >= '0' && real_dev[len - 1] <= '9') real_dev[len++] = 'p'; then you can treat real_dev as "%dp%d" form unconditionally. Would that work? -- Robert Millan I know my rights; I want my phone call! What use is a phone call… if you are unable to speak? (as seen on /.)