grub-devel
[Top][All Lists]
Advanced

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

Re: [PATCH RFC] Simplifying linux_find_partition()


From: Robert Millan
Subject: Re: [PATCH RFC] Simplifying linux_find_partition()
Date: Mon, 12 May 2008 17:32:29 +0200
User-agent: Mutt/1.5.13 (2006-08-11)

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

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)




reply via email to

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