From patchwork Fri Jan 15 01:19:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Heinrich Kiwi X-Patchwork-Id: 1426742 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DH3J40nFmz9sVw for ; Fri, 15 Jan 2021 12:19:48 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=tr1shBd1; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4DH3J35jf2zDsX3 for ; Fri, 15 Jan 2021 12:19:47 +1100 (AEDT) X-Original-To: petitboot@lists.ozlabs.org Delivered-To: petitboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=klaus@linux.vnet.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=tr1shBd1; dkim-atps=neutral Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4DH3Hw611jzDsVk for ; Fri, 15 Jan 2021 12:19:39 +1100 (AEDT) Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 10F1AFZD018530 for ; Thu, 14 Jan 2021 20:19:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=pp1; bh=T4P4XDD9oEZcTUnw8ixxYg0ayK9iERYBFWZQ79xZnMQ=; b=tr1shBd1HYK8E3NYug96oqX8TmbQnPJ+1JUGVFkGONc4MfAAtt4p98bA+1QF3LtdLYun Cu3UrsMK2nhYX8/btbb4Yis7OFzQOgD+H/3Yk1OC8QPRa0i/gqiG4B9DLmPJYv6Dbmvh K5sdFZpwzcLFcHkC9J8eYnG1TFfZGEVQb6ibXGivQEh5dSj62/7v3si4p8Z/PKP8/29d o+04vdSakMnYh4nkk88zInzGqsueYy7slqf6jpAbpAIPPIurIyrXZtquUIhht9lAu6hm mwvuE+vtO0lLC7B9lE9bvtTtTHjNwsXS3i7v81tccrbrFeDsy/Ch78OuoHfwAwaqrmFS 9Q== Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0a-001b2d01.pphosted.com with ESMTP id 3630nyrng6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 14 Jan 2021 20:19:37 -0500 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 10F169cs029758 for ; Fri, 15 Jan 2021 01:19:36 GMT Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by ppma02dal.us.ibm.com with ESMTP id 35y44a3hwy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 15 Jan 2021 01:19:36 +0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 10F1JZ4q21823800 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Jan 2021 01:19:35 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7855A7805C; Fri, 15 Jan 2021 01:19:35 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 86A127805E; Fri, 15 Jan 2021 01:19:34 +0000 (GMT) Received: from klaus-virtual-ubuntu.aus.stglabs.ibm.com (unknown [9.80.236.160]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 15 Jan 2021 01:19:34 +0000 (GMT) From: Klaus Heinrich Kiwi To: petitboot@lists.ozlabs.org Subject: [PATCH v2 2/2] discover/grub2: Add the '-e' test support Date: Thu, 14 Jan 2021 22:19:31 -0300 Message-Id: <20210115011931.5076-1-klaus@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <77e155f1-1641-8773-892e-2e45ad6cf34c@linux.vnet.ibm.com> References: <77e155f1-1641-8773-892e-2e45ad6cf34c@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343, 18.0.737 definitions=2021-01-14_10:2021-01-14, 2021-01-14 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 impostorscore=0 mlxscore=0 lowpriorityscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 priorityscore=1501 adultscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101150003 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: , MIME-Version: 1.0 Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" Grub2 allows a special-case of file test using the '-e' operator, where the path can be empty, and the device existance is tested. E.g.: if [ -e (md/md-boot) ]; then Add the support for testing this condition. This fixes the following RH CoreOS bug: https://bugzilla.redhat.com/show_bug.cgi?id=1915540 Signed-off-by: Klaus Heinrich Kiwi --- discover/grub2/builtins.c | 7 ++++++- test/parser/test-grub2-ubuntu-13_04-x86.c | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/discover/grub2/builtins.c b/discover/grub2/builtins.c index 31cbe0e..291bb03 100644 --- a/discover/grub2/builtins.c +++ b/discover/grub2/builtins.c @@ -245,6 +245,11 @@ static bool builtin_test_op_file(struct grub2_script *script, char op, return false; switch (op) { + case 'e': + /* -e: for grub, a special case is testing for the device + * presence itself (e.g. allows null file). */ + result = true; + break; case 's': /* -s: return true if file exists and has non-zero size */ result = !path ? false : statbuf.st_size > 0; @@ -336,7 +341,7 @@ static bool builtin_test_op(struct grub2_script *script, return strlen(a1) != 0; } - if (!strcmp(op, "-s") || !strcmp(op, "-f")) { + if (!strcmp(op, "-s") || !strcmp(op, "-f") || !(strcmp(op, "-e"))) { *consumed = 2; return builtin_test_op_file(script, op[1], a1); } diff --git a/test/parser/test-grub2-ubuntu-13_04-x86.c b/test/parser/test-grub2-ubuntu-13_04-x86.c index 2f9aefd..785781a 100644 --- a/test/parser/test-grub2-ubuntu-13_04-x86.c +++ b/test/parser/test-grub2-ubuntu-13_04-x86.c @@ -19,13 +19,13 @@ void run_test(struct parser_test *test) check_unresolved_resource(opt->boot_image); check_unresolved_resource(opt->initrd); check_name(opt, "Kubuntu GNU/Linux"); - check_args(opt, "root=UUID=29beca39-9181-4780-bbb2-ab5d4be59aaf ro quiet splash "); + check_args(opt, "root=UUID=29beca39-9181-4780-bbb2-ab5d4be59aaf ro quiet splash vt.handoff=7"); opt = get_boot_option(ctx, 1); check_unresolved_resource(opt->boot_image); check_unresolved_resource(opt->initrd); check_name(opt, "Kubuntu GNU/Linux, with Linux 3.8.0-19-generic"); - check_args(opt, "root=UUID=29beca39-9181-4780-bbb2-ab5d4be59aaf ro quiet splash "); + check_args(opt, "root=UUID=29beca39-9181-4780-bbb2-ab5d4be59aaf ro quiet splash vt.handoff=7"); opt = get_boot_option(ctx, 2); check_name(opt, "Kubuntu GNU/Linux, with Linux 3.8.0-19-generic (recovery mode)");