From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1nNvbk-00006i-Ve for mharc-grub-devel@gnu.org; Sat, 26 Feb 2022 06:51:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33496) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nNvbi-000053-Tr; Sat, 26 Feb 2022 06:51:26 -0500 Received: from hera.aquilenet.fr ([185.233.100.1]:36886) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nNvbh-0001Tp-4M; Sat, 26 Feb 2022 06:51:26 -0500 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 3358D20A; Sat, 26 Feb 2022 12:51:22 +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 OCFh9gkIzalm; Sat, 26 Feb 2022 12:51:21 +0100 (CET) Received: from begin (unknown [IPv6:2a01:cb19:956:1b00:de41:a9ff:fe47:ec49]) by hera.aquilenet.fr (Postfix) with ESMTPSA id B457F205; Sat, 26 Feb 2022 12:51:20 +0100 (CET) Received: from samy by begin with local (Exim 4.95) (envelope-from ) id 1nNvba-00DkiF-Sm; Sat, 26 Feb 2022 12:51:18 +0100 Date: Sat, 26 Feb 2022 12:51:18 +0100 From: Samuel Thibault To: grub-devel@gnu.org Cc: bug-hurd@gnu.org Subject: [PATCH] hurd: Use part: qualifier Message-ID: <20220226115118.ndxy6wbjs35vfx32@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 Organization: I am not organized User-Agent: NeoMutt/20170609 (1.8.3) X-Spamd-Bar: / Authentication-Results: hera.aquilenet.fr; none X-Rspamd-Server: hera X-Rspamd-Queue-Id: 3358D20A X-Spamd-Result: default: False [0.40 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; HAS_ORG_HEADER(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; RCPT_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; MID_RHS_NOT_FQDN(0.50)[] Received-SPF: neutral client-ip=185.233.100.1; envelope-from=samuel.thibault@ens-lyon.org; helo=hera.aquilenet.fr X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, 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: Sat, 26 Feb 2022 11:51:27 -0000 When using userland drivers such as rumpdisk, we'd rather make ext2fs use parted-based libstore partitioning support. That can be used for kernelland drivers as well, so we can just make grub always use the part: qualifier to switch ext2fs to it. grub_util_find_hurd_root_device then has to understand this syntax and translate it into the /dev/ entry name. Signed-off-by: Samuel Thibault Index: grub2-2.06/util/grub.d/10_hurd.in =================================================================== --- grub2-2.06.orig/util/grub.d/10_hurd.in +++ grub2-2.06/util/grub.d/10_hurd.in @@ -128,9 +128,11 @@ EOF else opts= fi + device=device:${GRUB_DEVICE#/dev/} + device=$(echo "$device" | sed -e 's/^device:\(.*[0-9]\+\)s\([0-9]\+\)$/part:\2:device:\1'/) sed "s/^/$submenu_indentation/" << EOF echo '$(echo "$message" | grub_quote)' - multiboot ${kernel} root=device:${GRUB_DEVICE#/dev/} $opts ${GRUB_CMDLINE_GNUMACH} + multiboot ${kernel} root=$device $opts ${GRUB_CMDLINE_GNUMACH} EOF if [ x$type != xrecovery ] ; then 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 @@ -109,6 +109,16 @@ grub_util_find_hurd_root_device (const c grub_util_error (_("translator `%s' for path `%s' is given only options, " "cannot find device part"), argz, path); + int part = -1; + if (strncmp (name, "part:", sizeof ("part:") - 1) == 0) + { + char *next = strchr (name + sizeof ("part:") - 1, ':'); + if (next) + { + part = atoi (name + sizeof ("part:") - 1); + name = next + 1; + } + } if (strncmp (name, "device:", sizeof ("device:") - 1) == 0) { char *dev_name = name + sizeof ("device:") - 1; @@ -123,11 +133,10 @@ grub_util_find_hurd_root_device (const c } { - 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 (part >= 0) + ret = xasprintf("/dev/%ss%u", dev_name, part); + else + ret = xasprintf("/dev/%s", dev_name); } } else if (!strncmp (name, "file:", sizeof ("file:") - 1))