]> git.ozlabs.org Git - petitboot/commitdiff
discover/grub: Allow to choose a different BLS directory
authorJavier Martinez Canillas <javierm@redhat.com>
Wed, 28 Mar 2018 12:24:43 +0000 (14:24 +0200)
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>
Thu, 29 Mar 2018 02:14:22 +0000 (13:14 +1100)
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 <javierm@redhat.com>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
discover/grub2/blscfg.c

index 0f69f7e291060550df492785cf402e83b6ead78f..02ac621be061b9859d33cc819562decde02f0928 100644 (file)
@@ -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;