From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1nqy5y-0002YS-T2 for mharc-grub-devel@gnu.org; Tue, 17 May 2022 10:22:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52122) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqy5r-0002TT-JV; Tue, 17 May 2022 10:22:36 -0400 Received: from dibed.net-space.pl ([84.10.22.86]:33508) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_3DES_EDE_CBC_SHA1:192) (Exim 4.90_1) (envelope-from ) id 1nqy5p-00073w-SB; Tue, 17 May 2022 10:22:35 -0400 Received: from router-fw.i.net-space.pl ([192.168.52.1]:51308 "EHLO tomti.i.net-space.pl") by router-fw-old.i.net-space.pl with ESMTP id S2110077AbiEQOWN (ORCPT + 1 other); Tue, 17 May 2022 16:22:13 +0200 X-Comment: RFC 2476 MSA function at dibed.net-space.pl logged sender identity as: dkiper Date: Tue, 17 May 2022 16:22:10 +0200 From: Daniel Kiper To: The development of GNU GRUB , bug-hurd@gnu.org Subject: Re: [PATCHv3] hurd: Support device entries with @/dev/disk: qualifier Message-ID: <20220517142210.hrqnwn6rrkyqlbkq@tomti.i.net-space.pl> References: <20220222232759.f5ed4lgkq5jt5ld6@begin> <20220223233413.wkk66pxp5p2q2wrf@begin> <20220427150411.o2tabth2j7ze5y7b@tomti.i.net-space.pl> <20220427210029.rncxg4hohty7wswt@begin> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220427210029.rncxg4hohty7wswt@begin> User-Agent: NeoMutt/20170113 (1.7.2) Received-SPF: pass client-ip=84.10.22.86; envelope-from=dkiper@net-space.pl; helo=dibed.net-space.pl X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 May 2022 14:22:41 -0000 On Wed, Apr 27, 2022 at 11:00:29PM +0200, Samuel Thibault wrote: > Those are used with non-bootstrap disk drivers, for which libstore has to > open /dev/disk before calling device_open on it instead of on the device > master port. Normally in that case all /dev/ entries also have the @/dev/disk: > qualifier, so we can just drop it. > > Signed-off-by: Samuel Thibault > > Message-Id: <20220223233413.wkk66pxp5p2q2wrf@begin> > > --- > Difference with v2: formatting, using xmalloc instead of malloc. > > Difference with v1: better drop the @/dev/disk: qualifier right from > grub_util_hurd_get_disk_info so it benefits alls the callees and not > only grub_util_part_to_disk. > > diff --git a/grub-core/osdep/hurd/getroot.c b/grub-core/osdep/hurd/getroot.c > index c66b206fa..5f0e366d1 100644 > --- a/grub-core/osdep/hurd/getroot.c > +++ b/grub-core/osdep/hurd/getroot.c > @@ -112,9 +112,21 @@ grub_util_find_hurd_root_device (const char *path) > if (strncmp (name, "device:", sizeof ("device:") - 1) == 0) > { > char *dev_name = name + sizeof ("device:") - 1; > - size_t size = sizeof ("/dev/") - 1 + strlen (dev_name) + 1; > + size_t size; > char *next; > - ret = malloc (size); > + > + if (dev_name[0] == '@') > + { > + /* non-bootstrap disk driver, the /dev/ entry is normally set up with > + * the same @. */ > + char *next_name = strchr (dev_name, ':'); > + > + if (next_name) > + dev_name = next_name + 1; > + } > + > + size = sizeof ("/dev/") - 1 + strlen (dev_name) + 1; > + ret = xmalloc (size); > next = stpncpy (ret, "/dev/", size); > stpncpy (next, dev_name, size - (next - ret)); > } > diff --git a/grub-core/osdep/hurd/hostdisk.c b/grub-core/osdep/hurd/hostdisk.c > index c47b5a5ea..73c442ae5 100644 > --- a/grub-core/osdep/hurd/hostdisk.c > +++ b/grub-core/osdep/hurd/hostdisk.c > @@ -87,6 +87,21 @@ grub_util_hurd_get_disk_info (const char *dev, grub_uint32_t *secsize, grub_disk > *parent = xmalloc (len+1); > memcpy (*parent, data, len); > (*parent)[len] = '\0'; > + > + if ((*parent)[0] == '@') > + { > + /* non-bootstrap disk driver, the /dev/ entry is normally set up with > + * the same @. */ > + char *next_path = strchr (*parent, ':'); > + > + if (next_path) > + { > + char *n = strdup (next_path + 1); I think this should be xstrdup() instead of strdup(). I can fix this for you before push. Otherwise Reviewed-by: Daniel Kiper Daniel > + free (*parent); > + *parent = n; > + } > + } > } > } > if (offset)