From patchwork Wed Jan 20 19:26:58 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: 1429405 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 4DLbBy571gz9sT6 for ; Thu, 21 Jan 2021 06:27:38 +1100 (AEDT) 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=PogDqa/s; 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 4DLbBy3V4LzDqd7 for ; Thu, 21 Jan 2021 06:27:38 +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; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=PogDqa/s; 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 4DLbBb239QzDqGg for ; Thu, 21 Jan 2021 06:27:18 +1100 (AEDT) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 10KJ3S9K096786; Wed, 20 Jan 2021 14:27:17 -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 : in-reply-to : references; s=pp1; bh=DolWxKjvCPnilGB+6h15l2oLp1Qgf9EOn0b6XLWzJ3s=; b=PogDqa/sKNbZIjG7ueTwH8f6LAw4DPboJyhC2LEA5QcajxbidxKeKSl0JUitkweO8eWi dwB6MzMtDKX/mO7jBAQc5opa03G59vU2Dok79YTnJBT+pBhqpQYLAhI+ISo4MpMjRwy6 p9f3VeWVx9I+0mSU60edJ8GkcEoYm5PpLB38HHeBQi6k6Wle6PAFI1LVo8Stv+mzxm7t rxrEZCe3/pBxNVLmPARgr8Hdbniq5NEFN01O7n71D9+T2uIt4lwR9LHFVsk/FP2+p6zB 8Sd1RbtWfgLGhLSfG2qtIbHxPyJCBci3R45taJrOgUVIx7xUp4RPRTz49Za3XRce/u2w Dg== Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com with ESMTP id 366t4c0wtm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Jan 2021 14:27:16 -0500 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 10KJQTXB026825; Wed, 20 Jan 2021 19:27:16 GMT Received: from b01cxnp23032.gho.pok.ibm.com (b01cxnp23032.gho.pok.ibm.com [9.57.198.27]) by ppma01dal.us.ibm.com with ESMTP id 3668nw08t7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Jan 2021 19:27:16 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 10KJRF3N28770584 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Jan 2021 19:27:15 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3A12E112064; Wed, 20 Jan 2021 19:27:15 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C78CA112061; Wed, 20 Jan 2021 19:27:13 +0000 (GMT) Received: from klaus-virtual-ubuntu.aus.stglabs.ibm.com (unknown [9.80.220.85]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 20 Jan 2021 19:27:13 +0000 (GMT) From: Klaus Heinrich Kiwi To: petitboot@lists.ozlabs.org Subject: [PATCH v3 2/2] discover/grub2: Add the '-e' test support Date: Wed, 20 Jan 2021 16:26:58 -0300 Message-Id: <20210120192658.27930-2-klaus@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210120192658.27930-1-klaus@linux.vnet.ibm.com> References: <35917519-878b-56d3-c995-c97e01f15d3a@linux.vnet.ibm.com> <20210120192658.27930-1-klaus@linux.vnet.ibm.com> In-Reply-To: References: X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343, 18.0.737 definitions=2021-01-20_10:2021-01-20, 2021-01-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 phishscore=0 suspectscore=0 spamscore=0 priorityscore=1501 mlxlogscore=999 malwarescore=0 mlxscore=0 impostorscore=0 lowpriorityscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101200108 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 4b94f99..31f8b6e 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)");