* [Patch] strip disk->name of partition suffix in grub_disk_open
@ 2010-07-09 17:23 Grégoire Sutre
2010-07-20 13:52 ` Vladimir 'φ-coder/phcoder' Serbinenko
0 siblings, 1 reply; 3+ messages in thread
From: Grégoire Sutre @ 2010-07-09 17:23 UTC (permalink / raw)
To: The development of GRUB 2
[-- Attachment #1: Type: text/plain, Size: 430 bytes --]
Hi,
When the argument passed to grub_disk_open is a string containing a
partition, e.g. "hd0,msdos3,bsd7", disk->name is set to the full
string instead of just the prefix up to the first ',' (here "hd0").
This leads to incorrect partition identifiers when the disk name and
the partition name are concatenated (I observed this in the debug
messages of my nested partitions patch).
The attached patch fixes this issue.
Grégoire
[-- Attachment #2: grub_disk_open.diff --]
[-- Type: text/plain, Size: 499 bytes --]
=== modified file 'kern/disk.c'
--- kern/disk.c 2010-02-07 00:48:38 +0000
+++ kern/disk.c 2010-07-09 16:44:06 +0000
@@ -248,11 +248,16 @@ grub_disk_open (const char *name)
if (! disk)
return 0;
- disk->name = grub_strdup (name);
+ p = find_part_sep (name);
+
+ if (p)
+ disk->name = grub_strndup (name, p - name);
+ else
+ disk->name = grub_strdup (name);
+
if (! disk->name)
goto fail;
- p = find_part_sep (name);
if (p)
{
grub_size_t len = p - name;
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [Patch] strip disk->name of partition suffix in grub_disk_open
2010-07-09 17:23 [Patch] strip disk->name of partition suffix in grub_disk_open Grégoire Sutre
@ 2010-07-20 13:52 ` Vladimir 'φ-coder/phcoder' Serbinenko
2010-07-21 0:12 ` Grégoire Sutre
0 siblings, 1 reply; 3+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2010-07-20 13:52 UTC (permalink / raw)
To: grub-devel
[-- Attachment #1: Type: text/plain, Size: 854 bytes --]
On 07/09/2010 07:23 PM, Grégoire Sutre wrote:
> Hi,
>
> When the argument passed to grub_disk_open is a string containing a
> partition, e.g. "hd0,msdos3,bsd7", disk->name is set to the full
> string instead of just the prefix up to the first ',' (here "hd0").
> This leads to incorrect partition identifiers when the disk name and
> the partition name are concatenated (I observed this in the debug
> messages of my nested partitions patch).
Which functions concatenate disk->name with anything else? It looks like
disk->name is with partitions by design.
>
> The attached patch fixes this issue.
>
> Grégoire
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
>
--
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 294 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch] strip disk->name of partition suffix in grub_disk_open
2010-07-20 13:52 ` Vladimir 'φ-coder/phcoder' Serbinenko
@ 2010-07-21 0:12 ` Grégoire Sutre
0 siblings, 0 replies; 3+ messages in thread
From: Grégoire Sutre @ 2010-07-21 0:12 UTC (permalink / raw)
To: The development of GNU GRUB
On 07/20/2010 03:52 PM, Vladimir 'φ-coder/phcoder' Serbinenko wrote:
> Which functions concatenate disk->name with anything else? It looks like
> disk->name is with partitions by design.
In several places, the (full) grub partition name is obtained by
concatenating disk->name with the result of grub_partition_get_name.
If I read the code correctly, this is what is done in:
function iterate_partition, file normal/completion.c.
function grub_device_iterate, file kern/device.c
function grub_efidisk_get_device_name, file disk/efi/efidisk.c
and I did the same in
function grub_util_biosdisk_get_grub_dev, file kern/emu/hostdisk.c
and more recently, for warnings/dprintfs, in
function grub_partition_check_containment, file kern/partition.c
function bsdlabel_partition_map_iterate, file partmap/bsdlabel.c
Assuming that the above are correct and that disk->name is correctly
set in grub_disk_open (e.g. hd0,msdos3,bsd7), then shouldn't
disk->partition have a NULL parent (which is not the case right now)?
Grégoire
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-07-21 0:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-09 17:23 [Patch] strip disk->name of partition suffix in grub_disk_open Grégoire Sutre
2010-07-20 13:52 ` Vladimir 'φ-coder/phcoder' Serbinenko
2010-07-21 0:12 ` Grégoire Sutre
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.