From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id EI5zJS9SHWIpdgEAgWs5BA (envelope-from ) for ; Mon, 28 Feb 2022 23:52:31 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id OGZrHi9SHWIBbwAAG6o9tA (envelope-from ) for ; Mon, 28 Feb 2022 23:52:31 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 3B74A21DBD for ; Mon, 28 Feb 2022 23:52:30 +0100 (CET) Received: from localhost ([::1]:45914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nOosX-0006AZ-1Z for larch@yhetil.org; Mon, 28 Feb 2022 17:52:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53254) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nOos7-00069w-AO for bug-guix@gnu.org; Mon, 28 Feb 2022 17:52:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:41048) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nOos6-0000gc-KX for bug-guix@gnu.org; Mon, 28 Feb 2022 17:52:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nOos6-0008Cr-BQ for bug-guix@gnu.org; Mon, 28 Feb 2022 17:52:02 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#40998: [PATCH 1/4] system: Add a version field to the record. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Mon, 28 Feb 2022 22:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40998 X-GNU-PR-Package: guix X-GNU-PR-Keywords: patch To: 40998@debbugs.gnu.org Received: via spool by 40998-submit@debbugs.gnu.org id=B40998.164608868931484 (code B ref 40998); Mon, 28 Feb 2022 22:52:02 +0000 Received: (at 40998) by debbugs.gnu.org; 28 Feb 2022 22:51:29 +0000 Received: from localhost ([127.0.0.1]:34941 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nOorV-0008Be-2H for submit@debbugs.gnu.org; Mon, 28 Feb 2022 17:51:29 -0500 Received: from mail-qv1-f52.google.com ([209.85.219.52]:43987) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nOorP-0008BJ-Iy for 40998@debbugs.gnu.org; Mon, 28 Feb 2022 17:51:23 -0500 Received: by mail-qv1-f52.google.com with SMTP id c14so10356905qvk.10 for <40998@debbugs.gnu.org>; Mon, 28 Feb 2022 14:51:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pgBgeKIJ80GUPqRsUuOcijxTXOHyh+Y5TGaICnL0Pwg=; b=Ta0SujBGF43hj4vE9j1EYhCXlIEE0DSnvr9HHhlgmq1OqUuSkfvrNl6jgMaR8YWbtj LgLAZrb/kILUnJDui1KQYVzLZhJeFItGn6Ps40gO2f0ToJIJczztwKIe1vfKFw6FXWA5 GSgrZ+DzmCTDhof9rNohlsMg6nxTBjDdnjxpgcfXS9aLFWiJR3vJ/uM2QYWoKAgiVxEc TSnNOKeb5mGJ00h1y2bpEYjtQ661UzaeAldeKXI+c1wMjbjBVplHD9Nf0RyLrj+lSjYf Hgmtx7yJSKOtd2BGzm2I+RSEss2jIopqCyhBgcXmgQO1bDDlsHHeSIyhMq4x3oEdAiB6 AWFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pgBgeKIJ80GUPqRsUuOcijxTXOHyh+Y5TGaICnL0Pwg=; b=u/I3X2Q2sMm7GUeBJua1ZLwWYw9FBffuawPqECAJKcyg2IZNwdifByWY9CFYkhySAl lg1tTtPnG/EloUgEwnLDydJNKPKEIj8yUtvhk6qi3st8JTVH50vw8B99v10bYhT/wEQr bxhtR6afAl+7KbHoOWMI9gjlHdlFCGQg+sKUNzJcBuTXoD50ACgJ4PKbj+mieHrhgQes fTBkXA4ZIfB9bMEu1+C70wBsB/SYJdL+KQWv9m62OjYKVYiuO9IHDGfmM5Om6AbIeplB sR6rFQq0xxCj9UXfp4sKDYmDyPeuOWzArf99i7i4VTQ8pogqlWH0EZ3wE4Uf89bHLvlA YWCQ== X-Gm-Message-State: AOAM5320NreVEAaiWW6YtMcG9ViTvs12N1mFzhQ9rOO4W0Rs5CKyXq2E P9iZdOIZSsvSj/lxMuEzmH7hjD8RxLiroA== X-Google-Smtp-Source: ABdhPJxBG7UUn21zTUtPn5GNkyZMKeBxbS6FXaapms6vvztzWRJ5MptCoWU6u676v+JAHx/QLXSNfA== X-Received: by 2002:ac8:5d49:0:b0:2df:f50f:f4eb with SMTP id g9-20020ac85d49000000b002dff50ff4ebmr9880594qtx.202.1646088673833; Mon, 28 Feb 2022 14:51:13 -0800 (PST) Received: from localhost.localdomain (dsl-141-227.b2b2c.ca. [66.158.141.227]) by smtp.gmail.com with ESMTPSA id b17-20020ae9eb11000000b0064917bda713sm5562714qkg.85.2022.02.28.14.51.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 14:51:13 -0800 (PST) From: Maxim Cournoyer Date: Mon, 28 Feb 2022 17:50:43 -0500 Message-Id: <20220228225047.11105-1-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxim Cournoyer Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1646088750; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=pgBgeKIJ80GUPqRsUuOcijxTXOHyh+Y5TGaICnL0Pwg=; b=X6kb6NSvreBpzd3Bft9H/QM+CQSiquCKu1VsgLWTlecTh3+b6qjzN54rYHR1jJ6t2yXpY4 fwS8VTc1xCedg8TOibxhEONrKw+W1I4LHXNJfO29aQymyhEZxU+rWUVJjsnE2imADP/wbB xi9CrLSKegc/uGhogw++vF6yw8u7HOYcBd9cqjnI4sJuLS9vDDgcKIggTwEolY2hFuY/8+ 64fPN5YQMg4EKAd+jJTxA4u8VgMdlulceQW9169GW+23ZiP5Gioo+l78vbXErhf6nOy/nU 7D2RXlTo75tqXgzJtJ7jjzW8tpBCsYfApV6fzCnsV6Yevvy2Ewcx/6UiZntAWw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1646088750; a=rsa-sha256; cv=none; b=QuDXYbc7qBDd9fK41tr1hushGoDIhi1As1UvD8YPppZ5YsXwmKgKnkanoNwy6NGODi1Iwx fKGSThspZGvhs+5ffWfjLKAV+EHBGVUztyC1juge7weVETyAcmj1e6Wd3cj+mpWxuKzuj+ NJMasgZRDUaIVCm84DHmy8gJ47/gLaGOAkK3iK3RjnnY4zgCg3O5T0IpUNPMQWFZzOPMGI OH9Kuzhh8cfS8QixXaFHKuGoWV3ZRREYSZ5Ooespl0abfucWQ5KxZSDMV7LAVfUyvsaOUC rK75O7k9V0lMMYnHrPmiYMhyqi8pzRT/YTPsMXZk1chfALJbbQTstzKI4Rc24Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=Ta0SujBG; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 5.51 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=Ta0SujBG; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 3B74A21DBD X-Spam-Score: 5.51 X-Migadu-Scanner: scn0.migadu.com X-TUID: qFD3GzZ/SQpj This version field exposes the (already present) version information of a boot parameters file. * gnu/system.scm (%boot-parameters-version): New variable. ()[version]: New field. (read-boot-parameters): Use it. (operating-system-boot-parameters-file): Likewise. * tests/boot-parameters.scm (test-read-boot-parameters): Use %boot-parameters-version as the default version value in the template. --- gnu/system.scm | 20 ++++++++++++++++---- tests/boot-parameters.scm | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/gnu/system.scm b/gnu/system.scm index cc925de16f..9ae158dea6 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -9,7 +9,7 @@ ;;; Copyright © 2020 Danny Milosavljevic ;;; Copyright © 2020, 2021 Brice Waegeneire ;;; Copyright © 2020 Florian Pelz -;;; Copyright © 2020 Maxim Cournoyer +;;; Copyright © 2020, 2022 Maxim Cournoyer ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen ;;; Copyright © 2020 Efraim Flashner ;;; Copyright © 2021 Maxime Devos @@ -161,6 +161,8 @@ (define-module (gnu system) boot-parameters-kernel-arguments boot-parameters-initrd boot-parameters-multiboot-modules + boot-parameters-version + %boot-parameters-version read-boot-parameters read-boot-parameters-file boot-parameters->menu-entry @@ -295,6 +297,8 @@ (define (operating-system-kernel-arguments os root-device) ;;; Boot parameters ;;; +(define %boot-parameters-version 0) + (define-record-type* boot-parameters make-boot-parameters boot-parameters? (label boot-parameters-label) @@ -322,7 +326,9 @@ (define-record-type* (kernel boot-parameters-kernel) (kernel-arguments boot-parameters-kernel-arguments) (initrd boot-parameters-initrd) - (multiboot-modules boot-parameters-multiboot-modules)) + (multiboot-modules boot-parameters-multiboot-modules) + (version boot-parameters-version ;positive integer + (default %boot-parameters-version))) (define (ensure-not-/dev device) "If DEVICE starts with a slash, return #f. This is meant to filter out @@ -359,12 +365,18 @@ (define uuid-sexp->uuid (warning (G_ "unrecognized uuid ~a at '~a'~%") x (port-filename port)) #f))) + ;; New versions are not backward-compatible, so only accept past and current + ;; versions, not future ones. + (define (version? n) + (member n (iota (1+ %boot-parameters-version)))) + (match (read port) - (('boot-parameters ('version 0) + (('boot-parameters ('version (? version? version)) ('label label) ('root-device root) ('kernel kernel) rest ...) (boot-parameters + (version version) (label label) (root-device (device-sexp->device root)) @@ -1500,7 +1512,7 @@ (define* (operating-system-boot-parameters-file os system-kernel-arguments?))) (scheme-file "parameters" #~(boot-parameters - (version 0) + (version #$(boot-parameters-version params)) (label #$(boot-parameters-label params)) (root-device #$(device->sexp diff --git a/tests/boot-parameters.scm b/tests/boot-parameters.scm index b2799d0596..d4b680df2e 100644 --- a/tests/boot-parameters.scm +++ b/tests/boot-parameters.scm @@ -101,7 +101,7 @@ (define (quote-uuid uuid) ;; Call read-boot-parameters with the desired string as input. (define* (test-read-boot-parameters #:key - (version 0) + (version %boot-parameters-version) (bootloader-name 'grub) (bootloader-menu-entries '()) (label %default-label) -- 2.34.0