From: Javier Martinez Canillas Date: Wed, 28 Mar 2018 12:24:43 +0000 (+0200) Subject: discover/grub: Allow to choose a different BLS directory X-Git-Tag: v1.8.0~15 X-Git-Url: https://git.ozlabs.org/?p=petitboot;a=commitdiff_plain;h=d01dfd5a6ca8283939265875dc69d665f955aba2;hp=d09e1761f51f3cba8ca6190380f4a312948d8f4c discover/grub: Allow to choose a different BLS directory 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 Signed-off-by: Samuel Mendoza-Jonas --- diff --git a/discover/grub2/blscfg.c b/discover/grub2/blscfg.c index 0f69f7e..02ac621 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;