From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1nMeZn-0000w2-CX for mharc-grub-devel@gnu.org; Tue, 22 Feb 2022 18:28:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35982) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMeZl-0000v9-Qd; Tue, 22 Feb 2022 18:28:09 -0500 Received: from [2a0c:e300::1] (port=56402 helo=hera.aquilenet.fr) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMeZj-0000qT-0N; Tue, 22 Feb 2022 18:28:09 -0500 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 8ADD0F8; Wed, 23 Feb 2022 00:28:02 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id J7JkrLnvC6im; Wed, 23 Feb 2022 00:28:01 +0100 (CET) Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 819235D8; Wed, 23 Feb 2022 00:28:01 +0100 (CET) Received: from samy by begin with local (Exim 4.95) (envelope-from ) id 1nMeZb-00FPYQ-R3; Wed, 23 Feb 2022 00:27:59 +0100 Date: Wed, 23 Feb 2022 00:27:59 +0100 From: Samuel Thibault To: grub-devel@gnu.org Cc: bug-hurd@gnu.org Subject: [PATCH] hurd: Support device entries with @/dev/disk: qualifier Message-ID: <20220222232759.f5ed4lgkq5jt5ld6@begin> Mail-Followup-To: grub-devel@gnu.org, bug-hurd@gnu.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: NeoMutt/20170609 (1.8.3) X-Spamd-Bar: / Authentication-Results: hera.aquilenet.fr; none X-Rspamd-Server: hera X-Rspamd-Queue-Id: 8ADD0F8 X-Spamd-Result: default: False [0.40 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; TO_DN_NONE(0.00)[]; MID_RHS_NOT_FQDN(0.50)[]; RCVD_COUNT_THREE(0.00)[3] X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a0c:e300::1 (failed) Received-SPF: neutral client-ip=2a0c:e300::1; envelope-from=samuel.thibault@ens-lyon.org; helo=hera.aquilenet.fr X-Spam_score_int: -2 X-Spam_score: -0.3 X-Spam_bar: / X-Spam_report: (-0.3 / 5.0 requ) BAYES_00=-1.9, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_NEUTRAL=0.779, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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, 22 Feb 2022 23:28:10 -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 Index: grub2-2.06/grub-core/osdep/hurd/getroot.c =================================================================== --- grub2-2.06.orig/grub-core/osdep/hurd/getroot.c +++ grub2-2.06/grub-core/osdep/hurd/getroot.c @@ -112,11 +112,23 @@ grub_util_find_hurd_root_device (const c 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; - char *next; - ret = malloc (size); - next = stpncpy (ret, "/dev/", size); - stpncpy (next, dev_name, size - (next - ret)); + + 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_t size = sizeof ("/dev/") - 1 + strlen (dev_name) + 1; + char *next; + ret = malloc (size); + next = stpncpy (ret, "/dev/", size); + stpncpy (next, dev_name, size - (next - ret)); + } } else if (!strncmp (name, "file:", sizeof ("file:") - 1)) ret = strdup (name + sizeof ("file:") - 1); @@ -166,12 +178,27 @@ grub_util_part_to_disk (const char *os_d || strncmp ("/dev/hd", os_dev, 7) == 0))) { *is_part = !is_fulldisk (path, os_dev); + + if (path[0] == '@') + { + /* non-bootstrap disk driver, the /dev/ entry is normally set up with + the same @. */ + char *next_path = strchr (path, ':'); + if (next_path) + { + char *n = strdup (next_path + 1); + free (path); + path = n; + } + } + if (path[0] != '/') { char *n = xasprintf ("/dev/%s", path); free (path); path = n; } + return path; } free (path);