From patchwork Wed Nov 20 02:42:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Kerr X-Patchwork-Id: 1197786 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47Hnh53h8Gz9sPV for ; Wed, 20 Nov 2019 14:08:21 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="LuUfffK/"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 47Hnh52ZdyzDqtQ for ; Wed, 20 Nov 2019 14:08:21 +1100 (AEDT) X-Original-To: petitboot@lists.ozlabs.org Delivered-To: petitboot@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 47Hn9W1hWGzDqgs for ; Wed, 20 Nov 2019 13:45:19 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="LuUfffK/"; dkim-atps=neutral Received: by ozlabs.org (Postfix, from userid 1023) id 47Hn9W0C05z9s7T; Wed, 20 Nov 2019 13:45:18 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1574217919; bh=qyJRJQ6AfQp9hW54kBMcwGX4QrUlPJFVFbKAZ2FMF4g=; h=From:To:Subject:Date:From; b=LuUfffK/tqkLtlllEMoHOjKWh9Xb2hjbOkiXa9FxBwF2OHDU1sMew0o2yBzjkhSbp XRtFv2/J97QGpHRmORnOmKALdJKC2ffTCROigSZksrR6iBSIvkOl5M0iIJWvHlZ1so m2203NS+dA5EjvuzQ9T+UtmYPIUChxDaU/8HdAGUW3XL32GU/i6XqslYiVHrg+gH2k HFNTuLX+/1uSa+AkVl1HE8WKFAG7fEuBCXCg3+IgzmNk+cQ2Ichsyl6l41mpkeDaoD HraAepw34lj2Ka/oFiTHiApR1U2vO6Bm07iL8P3Ag3BM7DecfL6pnsTM/IPof4G79t sYg9+WIgWyicQ== From: Jeremy Kerr To: petitboot@lists.ozlabs.org Subject: [PATCH 00/14] discover/grub2: Add support for grub2 file specifiers Date: Wed, 20 Nov 2019 10:42:52 +0800 Message-Id: <20191120024306.16526-1-jk@ozlabs.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" This series implements grub2-syle file references, of the form: (device)/path - as documented at https://www.gnu.org/software/grub/manual/grub/html_node/File-name-syntax.html This allows cross-device specifiers for boot option resources, as well as general scripting (eg., the '-f' tests, and a new 'source' command). The (device) component of these specifiers corresponds to the petitboot device ID, which in turn is just the kernel name for the device. As with actual grub, these names may be volatile, so are rarely used directly in scripts. Instead, most scripts will use the 'search' function to resolve a UUID or label into one of these IDs. To enable this, we extend support for proper resolution for the search builtin. We also add a 'source' command, supporting this specifier syntax. Finally, this change adds a couple of tests using example RHEL8 boot configs, which depend on these features. Cheers, Jeremy Reviewed-by: Samuel Mendoza-Jonas --- Jeremy Kerr (14): discover/grub2: 'search' set-variable defaults to root discover/grub2: Use getopt for `search` argument parsing discover/grub2: test for (ignored) --no-floppy argument discover/grub2: Add support for UUID and label for 'search' command discover/grub2: expose a struct for grub2 file references discover/grub2: Add parsing code for grub2 file specifiers discover/grub2: add support for grub2-style path specifiers in resources discover/grub2: Allow (device)/path references in general script usage discover/grub2: Add a reference from script to parser discover/grub2: expose internal parse function discover/grub2: make statements_execute non-static discover/grub2: implement 'source' command test/parser: Add test for recent RHCOS grub2 config test/parser: Add RHEL8 grub config test discover/grub2/blscfg.c | 19 +- discover/grub2/builtins.c | 208 +++++++++++++++--- discover/grub2/grub2-parser.y | 17 +- discover/grub2/grub2.c | 110 +++++++-- discover/grub2/grub2.h | 32 ++- discover/grub2/script.c | 3 +- test/parser/Makefile.am | 11 + test/parser/data/grub2-rhcos-ootpa.conf | 194 ++++++++++++++++ test/parser/data/grub2-rhel8.conf | 190 ++++++++++++++++ test/parser/test-grub2-devpath-scripting.c | 56 +++++ test/parser/test-grub2-devpath.c | 88 ++++++++ test/parser/test-grub2-rhcos-ootpa.c | 38 ++++ test/parser/test-grub2-rhel8.c | 21 ++ test/parser/test-grub2-search-args.c | 35 +++ test/parser/test-grub2-search-label.c | 47 ++++ test/parser/test-grub2-search-uuid.c | 55 +++++ test/parser/test-grub2-source-functions.c | 46 ++++ .../test-grub2-source-recursion-infinite.c | 43 ++++ test/parser/test-grub2-source-recursion.c | 58 +++++ test/parser/test-grub2-source.c | 54 +++++ 20 files changed, 1254 insertions(+), 71 deletions(-) create mode 100644 test/parser/data/grub2-rhcos-ootpa.conf create mode 100644 test/parser/data/grub2-rhel8.conf create mode 100644 test/parser/test-grub2-devpath-scripting.c create mode 100644 test/parser/test-grub2-devpath.c create mode 100644 test/parser/test-grub2-rhcos-ootpa.c create mode 100644 test/parser/test-grub2-rhel8.c create mode 100644 test/parser/test-grub2-search-args.c create mode 100644 test/parser/test-grub2-search-label.c create mode 100644 test/parser/test-grub2-search-uuid.c create mode 100644 test/parser/test-grub2-source-functions.c create mode 100644 test/parser/test-grub2-source-recursion-infinite.c create mode 100644 test/parser/test-grub2-source-recursion.c create mode 100644 test/parser/test-grub2-source.c