From patchwork Wed Mar 28 12:24:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 892117 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40B6cT21X3z9ryk for ; Wed, 28 Mar 2018 23:28:41 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40B6cT0QQqzF2L0 for ; Wed, 28 Mar 2018 23:28:41 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com X-Original-To: petitboot@lists.ozlabs.org Delivered-To: petitboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=redhat.com (client-ip=74.125.82.66; helo=mail-wm0-f66.google.com; envelope-from=javierm@redhat.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40B6X955fBzF2L0 for ; Wed, 28 Mar 2018 23:24:56 +1100 (AEDT) Received: by mail-wm0-f66.google.com with SMTP id x82so4914978wmg.1 for ; Wed, 28 Mar 2018 05:24:56 -0700 (PDT) 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:date:message-id; bh=SZwHnlnqHWjkT/cBDs3ZS3kPahHzWC0QsxSFqz11STE=; b=jXFQns37prMOntb6qNOpD7hDfmLyaHg1w1Tiq7L6vkAKswl+7+Ay4QUvbIiq8cGFrV qTxDZ/wKi5GMVi7ehczZ3nPrOeVr5wSTE3bsr+tPbmhwJrTlNVbXzmrwpL8tYoysSaYq 6Pw/FsgZXVO+355/8uwftmsVZ+rNSpwrf+pPWylXg1K/MPmKFM3UoL03qMPHH20XpmkZ 9waW/SmJhWCKcWWdjk9Sh9zANVQ9PQdCs0gG7FFCGiE+36EYzl8e0IDYfK7YUvUKaMLO ivhuJWaHVxRN0hP3wQu73YxzWDMZNV5SLi7Ewx4yaKOKBHsHSq+3mc18Z7EbdKSonGIc wqFw== X-Gm-Message-State: AElRT7E9nD5mQxpeYACOAe8EwYI4Y3j5n83yk8cxno4vaJTwgwogglkB mDyynNEl08YvoX/MZ9qmxPRKoC+T02w= X-Google-Smtp-Source: AIpwx49AEfiDNUoGT3ikDGViZbAbICLJor+v2BnkKC0KAbrVJMpeJW/NiNxSdrgnAWHwXCf2JHPLCA== X-Received: by 10.28.148.202 with SMTP id w193mr2331152wmd.62.1522239893025; Wed, 28 Mar 2018 05:24:53 -0700 (PDT) Received: from minerva.redhat.com ([90.77.100.34]) by smtp.gmail.com with ESMTPSA id f84sm5606306wmh.44.2018.03.28.05.24.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Mar 2018 05:24:52 -0700 (PDT) From: Javier Martinez Canillas To: petitboot@lists.ozlabs.org Subject: [PATCH] discover/grub: Allow to choose a different BLS directory Date: Wed, 28 Mar 2018 14:24:43 +0200 Message-Id: <20180328122444.17245-1-javierm@redhat.com> X-Mailer: git-send-email 2.14.3 X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Javier Martinez Canillas , Peter Jones , Jan Hlavac , Samuel Mendoza-Jonas MIME-Version: 1.0 Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" The default path to search for BootLoaderSpec configuration files is /loader/entries but in some setups a different directory may be used. So allow this to be chosen by using a blsdir GRUB environment variable. Signed-off-by: Javier Martinez Canillas --- Hello, I noticed that missed support for this in my previous patch, and it's supported by our GRUB 2 so let's have it in Petitboot for consistency. It also makes the Petitboot implementation more flexible. Best regards, Javier discover/grub2/blscfg.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/discover/grub2/blscfg.c b/discover/grub2/blscfg.c index 0f69f7e29106..02ac621be061 100644 --- a/discover/grub2/blscfg.c +++ b/discover/grub2/blscfg.c @@ -180,6 +180,7 @@ int builtin_blscfg(struct grub2_script *script, struct conf_context *conf; struct bls_state *state; char *buf, *filename; + const char *blsdir; int n, len, rc = -1; conf = talloc_zero(dc, struct conf_context); @@ -191,12 +192,16 @@ int builtin_blscfg(struct grub2_script *script, conf->process_pair = bls_process_pair; conf->finish = bls_finish; - n = parser_scandir(dc, BLS_DIR, &bls_entries, bls_filter, bls_sort); + blsdir = script_env_get(script, "blsdir"); + if (!blsdir) + blsdir = BLS_DIR; + + n = parser_scandir(dc, blsdir, &bls_entries, bls_filter, bls_sort); if (n <= 0) goto err; while (n--) { - filename = talloc_asprintf(dc, BLS_DIR"/%s", + filename = talloc_asprintf(dc, "%s/%s", blsdir, bls_entries[n]->d_name); if (!filename) break;