Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1nqyP4-0004XG-BY for mharc-grub-devel@gnu.org; Tue, 17 May 2022 10:42:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57154) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqyOz-0004UM-Va; Tue, 17 May 2022 10:42:23 -0400 Received: from sonata.ens-lyon.org ([140.77.166.138]:37194) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqyOx-0002Br-VO; Tue, 17 May 2022 10:42:21 -0400 Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id A4CC32010B; Tue, 17 May 2022 16:42:15 +0200 (CEST) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UehWUmYNM2b4; Tue, 17 May 2022 16:42:15 +0200 (CEST) Received: from begin (nat-inria-interne-52-gw-01-bso.bordeaux.inria.fr [194.199.1.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id 7486720107; Tue, 17 May 2022 16:42:15 +0200 (CEST) Received: from samy by begin with local (Exim 4.95) (envelope-from ) id 1nqyOt-00GdmY-KZ; Tue, 17 May 2022 16:42:15 +0200 Date: Tue, 17 May 2022 16:42:15 +0200 From: Samuel Thibault To: Daniel Kiper Cc: The development of GNU GRUB , bug-hurd@gnu.org Subject: Re: [PATCHv3] hurd: Support device entries with @/dev/disk: qualifier Message-ID: <20220517144215.netcozwq3gasicte@begin> Mail-Followup-To: Daniel Kiper , The development of GNU GRUB , bug-hurd@gnu.org References: <20220222232759.f5ed4lgkq5jt5ld6@begin> <20220223233413.wkk66pxp5p2q2wrf@begin> <20220427150411.o2tabth2j7ze5y7b@tomti.i.net-space.pl> <20220427210029.rncxg4hohty7wswt@begin> <20220517142210.hrqnwn6rrkyqlbkq@tomti.i.net-space.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220517142210.hrqnwn6rrkyqlbkq@tomti.i.net-space.pl> Organization: I am not organized User-Agent: NeoMutt/20170609 (1.8.3) Received-SPF: pass client-ip=140.77.166.138; envelope-from=SRS0=Cd7z=VZ=ens-lyon.org=samuel.thibault@bounce.ens-lyon.org; helo=sonata.ens-lyon.org X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-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:42:24 -0000 Daniel Kiper, le mar. 17 mai 2022 16:22:10 +0200, a ecrit: > 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. Ok, please do so :) Samuel > Otherwise Reviewed-by: Daniel Kiper > > Daniel > > > + free (*parent); > > + *parent = n; > > + } > > + } > > } > > } > > if (offset) >