Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1ntzxZ-0005c6-9S for mharc-grub-devel@gnu.org; Wed, 25 May 2022 18:58:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50680) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntzxV-0005bi-BL; Wed, 25 May 2022 18:58:29 -0400 Received: from domu-toccata.ens-lyon.fr ([140.77.166.138]:37412 helo=sonata.ens-lyon.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ntzxR-0000xC-P7; Wed, 25 May 2022 18:58:28 -0400 Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 0507620103; Thu, 26 May 2022 00:58:22 +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 0eqV8aV6nrJK; Thu, 26 May 2022 00:58:21 +0200 (CEST) Received: from begin (anantes-655-1-33-15.w83-195.abo.wanadoo.fr [83.195.225.15]) (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 E6A2E200FB; Thu, 26 May 2022 00:58:21 +0200 (CEST) Received: from samy by begin with local (Exim 4.95) (envelope-from ) id 1ntzxN-008s1j-Hu; Thu, 26 May 2022 00:58:21 +0200 Date: Thu, 26 May 2022 00:58:21 +0200 From: Samuel Thibault To: grub-devel@gnu.org Cc: bug-hurd@gnu.org Subject: [PATCHv2] hurd: Use part: qualifier Message-ID: <20220525225821.dojcmmg73kw4re4i@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) Received-SPF: pass client-ip=140.77.166.138; envelope-from=SRS0=Urbi=WB=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: Wed, 25 May 2022 22:58:30 -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 --- Difference with v2: rebase on master 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,10 +133,10 @@ grub_util_find_hurd_root_device (const c 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)); + 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)) ret = strdup (name + sizeof ("file:") - 1);