All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Grégoire Sutre" <gregoire.sutre@gmail.com>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: [Patch] strip disk->name of partition suffix in grub_disk_open
Date: Fri, 09 Jul 2010 19:23:49 +0200	[thread overview]
Message-ID: <4C375B25.7060306@gmail.com> (raw)

[-- 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;


             reply	other threads:[~2010-07-09 17:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-09 17:23 Grégoire Sutre [this message]
2010-07-20 13:52 ` [Patch] strip disk->name of partition suffix in grub_disk_open Vladimir 'φ-coder/phcoder' Serbinenko
2010-07-21  0:12   ` Grégoire Sutre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C375B25.7060306@gmail.com \
    --to=gregoire.sutre@gmail.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.