From patchwork Thu May 28 04:30:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 22416 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id CD60127BBE3; Thu, 28 May 2020 05:31:08 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 0958427BBE1 for ; Thu, 28 May 2020 05:31:08 +0100 (BST) Received: from localhost ([::1]:54612 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jeACB-00034n-HL for patchwork@mira.cbaines.net; Thu, 28 May 2020 00:31:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59196) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jeAC6-000348-5X for guix-patches@gnu.org; Thu, 28 May 2020 00:31:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39058) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jeAC5-00033x-Rf for guix-patches@gnu.org; Thu, 28 May 2020 00:31:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jeAC5-0007up-On for guix-patches@gnu.org; Thu, 28 May 2020 00:31:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#37305] [PATCH v3] Allow booting from a Btrfs subvolume Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 28 May 2020 04:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37305 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Pierre Neidhardt Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , 37305-done@debbugs.gnu.org Received: via spool by 37305-done@debbugs.gnu.org id=D37305.159064022730384 (code D ref 37305); Thu, 28 May 2020 04:31:01 +0000 Received: (at 37305-done) by debbugs.gnu.org; 28 May 2020 04:30:27 +0000 Received: from localhost ([127.0.0.1]:50604 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jeABW-0007u0-BY for submit@debbugs.gnu.org; Thu, 28 May 2020 00:30:26 -0400 Received: from mail-qv1-f66.google.com ([209.85.219.66]:37424) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jeABV-0007tn-Eg for 37305-done@debbugs.gnu.org; Thu, 28 May 2020 00:30:26 -0400 Received: by mail-qv1-f66.google.com with SMTP id y9so2671439qvs.4 for <37305-done@debbugs.gnu.org>; Wed, 27 May 2020 21:30:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=cxkMw0fo6tEFaD+059y9hL2+sVPQVCa4th/SdTxSMPM=; b=FAyxF4XGR/pULcmxFEvLQ3PymgZUkqFKbi0ong5WvK4c0mj7IlCDVUCmo61sz7pyID ClMDelJgsGhFp5qSbbJ0J1dvMtVON/g8QSJMy86f3mS/nnvAgYvroQ8DgcJosPX2C+1Z Ctqkxqrzr15Bq/7RvEbqyFcjg/Q+PoTPNV4UYRI1mDEyXYgJuSBm5NRxvHJrqI+Co0qt 7R5k9H1d+wlbm2IMW6qZs+jX9x17/PeeFKAihoIH0k6iwkM17TlCHxZGA1IwJ1eTGF2K sRd82BuUjgSHQipA4Ih5lY324RSetZmwnGFg807N3/h8N6LUd/1p5C45OWxd959ugadg MFWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=cxkMw0fo6tEFaD+059y9hL2+sVPQVCa4th/SdTxSMPM=; b=PO1/0gG9dAvp3amFSKwJJeTzoRJjDO3JPfDhXvRopMMjnkesQmsxK6a9dkCgU2U/ot ZYo5gEiwusCp3trdaVfVfKZWGhdUWp9lOx7RZF5a3P1pa8eFGRpBlHeZMWFBlGZhng0k HRgnsH09T1Br/gwxM2/ZrVa2iNWw7nNGCNPKmhZX7OfmVcIDCOxJgku/rkO4mCLquFZM DnULTuhfdAUEd4yGAqx5eptQ6matP1WfWFzYmJtq1RtKr6KoamUQFf1L3yPfZNdtBWny HAYGeOOHWZkLSF4vuaNqS3yfG3hT5ZJIQSkpgF51w7BpmptcZpJ8OUWD3jT/sHZetnGs BnuQ== X-Gm-Message-State: AOAM531xjGKtiZPEqAj7HEJlIS7Rk8Wnwc/318AWOPwLhbAq5WnNAet/ njcOYpggIsdh1eGoKvexX6b4kx141dwFtg== X-Google-Smtp-Source: ABdhPJxkfUtNPhE2xhiZFlrXN+cwfgkX85gzAPf7gQOic863MJX5PECCyVin4KWCl6Ts8Mh6c78mHQ== X-Received: by 2002:a0c:fde6:: with SMTP id m6mr1328871qvu.92.1590640219654; Wed, 27 May 2020 21:30:19 -0700 (PDT) Received: from hurd (dsl-10-130-200.b2b2c.ca. [72.10.130.200]) by smtp.gmail.com with ESMTPSA id h77sm4256906qke.37.2020.05.27.21.30.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 21:30:18 -0700 (PDT) From: Maxim Cournoyer References: <875zg2xtsb.fsf@gmail.com> <87lfoxbn2e.fsf@gnu.org> <87v9n1pts1.fsf@raisin.i-did-not-set--mail-host-address--so-tickle-me> <87o8qmheqm.fsf@ambrevar.xyz> <874ksebkup.fsf_-_@gmail.com> <87y2pohpqx.fsf@gnu.org> <87v9kqpyhu.fsf@gmail.com> <87sgfuclh8.fsf@gnu.org> <87tv09epux.fsf@ambrevar.xyz> Date: Thu, 28 May 2020 00:30:17 -0400 In-Reply-To: <87tv09epux.fsf@ambrevar.xyz> (Pierre Neidhardt's message of "Thu, 21 May 2020 08:58:30 +0200") Message-ID: <87lflc65ra.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Hello, Pierre Neidhardt writes: > Ludovic Courtès writes: > >> To me, another consideration is familiarity with Btrfs for those who’ll >> touch the code: to someone not familiar with it, the code may be viewed >> as “read-only” because it says “btrfs”. Whereas if it clearly states >> that it’s just about prepending a directory name or similar, it’s easy >> to reason about it. > > Agreed, this is where I was going to with my comment on ZFS. > Maybe the "btrfs" part of the symbols can be left out to make it more > general and understandable. I've adapted with the naming suggested earlier by Ludovic. Does the patch below fit the bill? Thanks, Maxim From ee23cc391cce7b8dcdcb5146d4b84a55881a5cb9 Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Wed, 27 May 2020 22:44:28 -0400 Subject: [PATCH] bootloader: grub: Rename the btrfs-subvolume-file-name parameter. Following discussion in , it seems more appropriate to give the parameter a more generic name that better describes what it does. * gnu/bootloader/grub.scm (normalize-file): Rename the btrfs-subvolume-file-name parameter to store-directory-prefix. (eye-candy): Likewise. (grub-configuration-file): Likewise. * gnu/system.scm (operating-system-bootcfg): Adapt. --- gnu/bootloader/grub.scm | 46 ++++++++++++++++++++--------------------- gnu/system.scm | 2 +- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm index bb40c551a7..7b2fc18103 100644 --- a/gnu/bootloader/grub.scm +++ b/gnu/bootloader/grub.scm @@ -58,8 +58,8 @@ ;;; ;;; Code: -(define* (normalize-file file mount-point btrfs-subvolume-file-name) - "Strip MOUNT-POINT and prepend BTRFS-SUBVOLUME-FILE-NAME to FILE, a +(define* (normalize-file file mount-point store-directory-prefix) + "Strip MOUNT-POINT and prepend STORE-DIRECTORY-PREFIX to FILE, a G-expression or other lowerable object denoting a file name." (define (strip-mount-point mount-point file) @@ -72,12 +72,12 @@ G-expression or other lowerable object denoting a file name." file))) file)) - (define (prepend-btrfs-subvolume-file-name btrfs-subvolume-file-name file) - (if btrfs-subvolume-file-name - #~(string-append #$btrfs-subvolume-file-name #$file) + (define (prepend-store-directory-prefix store-directory-prefix file) + (if store-directory-prefix + #~(string-append #$store-directory-prefix #$file) file)) - (prepend-btrfs-subvolume-file-name btrfs-subvolume-file-name + (prepend-store-directory-prefix store-directory-prefix (strip-mount-point mount-point file))) @@ -135,14 +135,14 @@ file with the resolution provided in CONFIG." (_ #f))))) (define* (eye-candy config store-device store-mount-point - #:key btrfs-store-subvolume-file-name system port) + #:key store-directory-prefix system port) "Return a gexp that writes to PORT (a port-valued gexp) the 'grub.cfg' part concerned with graphics mode, background images, colors, and all that. STORE-DEVICE designates the device holding the store, and STORE-MOUNT-POINT is its mount point; these are used to determine where the background image and fonts must be searched for. SYSTEM must be the target system string---e.g., -\"x86_64-linux\". BTRFS-STORE-SUBVOLUME-FILE-NAME is the file name of the -Btrfs subvolume, to be prepended to any store path, if any." +\"x86_64-linux\". STORE-DIRECTORY-PREFIX is a directory prefix to prepend to +any store path." (define setup-gfxterm-body (let ((gfxmode (or (and-let* ((theme (bootloader-configuration-theme config)) @@ -181,12 +181,12 @@ fi~%" #+font-file) (define font-file (normalize-file (file-append grub "/share/grub/unicode.pf2") store-mount-point - btrfs-store-subvolume-file-name)) + store-directory-prefix)) (define image (normalize-file (grub-background-image config) store-mount-point - btrfs-store-subvolume-file-name)) + store-directory-prefix)) (and image #~(format #$port " @@ -320,13 +320,13 @@ code." #:key (system (%current-system)) (old-entries '()) - btrfs-subvolume-file-name) + store-directory-prefix) "Return the GRUB configuration file corresponding to CONFIG, a object, and where the store is available at -STORE-FS, a object. OLD-ENTRIES is taken to be a list -of menu entries corresponding to old generations of the system. -BTRFS-SUBVOLUME-FILE-NAME may be used to specify on which subvolume a -Btrfs root file system resides." +STORE-FS, a object. OLD-ENTRIES is taken to be a list of menu +entries corresponding to old generations of the system. +STORE-DIRECTORY-PREFIX may be used to specify a store prefix, as is required +when booting a root file system on a Btrfs subvolume." (define all-entries (append entries (bootloader-configuration-menu-entries config))) (define (menu-entry->gexp entry) @@ -336,17 +336,17 @@ Btrfs root file system resides." (arguments (menu-entry-linux-arguments entry)) (kernel (normalize-file (menu-entry-linux entry) device-mount-point - btrfs-subvolume-file-name)) + store-directory-prefix)) (initrd (normalize-file (menu-entry-initrd entry) device-mount-point - btrfs-subvolume-file-name))) + store-directory-prefix))) ;; Here DEVICE is the store and DEVICE-MOUNT-POINT is its mount point. ;; Use the right file names for KERNEL and INITRD in case ;; DEVICE-MOUNT-POINT is not "/", meaning that the store is on a ;; separate partition. - ;; When BTRFS-SUBVOLUME-FILE-NAME is defined, prepend it the kernel and - ;; initrd paths, to allow booting from a Btrfs subvolume. + ;; When STORE-DIRECTORY-PREFIX is defined, prepend it to the kernel and + ;; initrd paths, for example to allow booting from a Btrfs subvolume. #~(format port "menuentry ~s { ~a linux ~a ~a @@ -360,7 +360,7 @@ Btrfs root file system resides." (eye-candy config (menu-entry-device (first all-entries)) (menu-entry-device-mount-point (first all-entries)) - #:btrfs-store-subvolume-file-name btrfs-subvolume-file-name + #:store-directory-prefix store-directory-prefix #:system system #:port #~port)) @@ -371,8 +371,8 @@ Btrfs root file system resides." (keymap* (and layout (keyboard-layout-file layout #:grub grub))) (keymap (and keymap* - (if btrfs-subvolume-file-name - #~(string-append #$btrfs-subvolume-file-name + (if store-directory-prefix + #~(string-append #$store-directory-prefix #$keymap*) keymap*)))) #~(when #$keymap diff --git a/gnu/system.scm b/gnu/system.scm index d929187695..ac8bbd1d16 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -1118,7 +1118,7 @@ a list of , to populate the \"old entries\" menu." (generate-config-file bootloader-conf (list entry) #:old-entries old-entries - #:btrfs-subvolume-file-name + #:store-directory-prefix (btrfs-store-subvolume-file-name file-systems)))) (define* (operating-system-boot-parameters os root-device -- 2.26.2