From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1njom7-0001V6-7b for mharc-grub-devel@gnu.org; Wed, 27 Apr 2022 17:00:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51424) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njom5-0001U2-TZ; Wed, 27 Apr 2022 17:00:38 -0400 Received: from sonata.ens-lyon.org ([140.77.166.138]:36712) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njom3-0007b8-TM; Wed, 27 Apr 2022 17:00:37 -0400 Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 2AB5020146; Wed, 27 Apr 2022 23:00:30 +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 WxQxY8bxBQ30; Wed, 27 Apr 2022 23:00:30 +0200 (CEST) Received: from begin.home (lfbn-bor-1-255-114.w90-50.abo.wanadoo.fr [90.50.98.114]) (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 0C88D20116; Wed, 27 Apr 2022 23:00:29 +0200 (CEST) Received: from samy by begin.home with local (Exim 4.95) (envelope-from ) id 1njolx-00Evu0-I2; Wed, 27 Apr 2022 23:00:29 +0200 Date: Wed, 27 Apr 2022 23:00:29 +0200 From: Samuel Thibault To: The development of GNU GRUB Cc: bug-hurd@gnu.org Subject: [PATCHv3] hurd: Support device entries with @/dev/disk: qualifier Message-ID: <20220427210029.rncxg4hohty7wswt@begin> Mail-Followup-To: The development of GNU GRUB , bug-hurd@gnu.org References: <20220222232759.f5ed4lgkq5jt5ld6@begin> <20220223233413.wkk66pxp5p2q2wrf@begin> <20220427150411.o2tabth2j7ze5y7b@tomti.i.net-space.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220427150411.o2tabth2j7ze5y7b@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=InHP=VF=ens-lyon.org=samuel.thibault@bounce.ens-lyon.org; helo=sonata.ens-lyon.org 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, RCVD_IN_DNSWL_NONE=-0.0001, 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: Wed, 27 Apr 2022 21:00:38 -0000 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); + + free (*parent); + *parent = n; + } + } } } if (offset)