From 91ce1a8f8863d8f740188236f138421d17292d6c Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Thu, 22 Mar 2018 09:41:23 +0100 Subject: discover/grub: Add blscfg command support to parse BootLoaderSpec files The BootLoaderSpec (BLS) defines a file format for boot configurations, so bootloaders can parse these files and create their boot menu entries by using the information provided by them [0]. This allow to configure the boot items as drop-in files in a directory instead of having to parse and modify a bootloader configuration file. The GRUB 2 bootloader provides a blscfg command that parses these files and creates menu entries using this information. Add support for it. [0]: https://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/ Signed-off-by: Javier Martinez Canillas Signed-off-by: Samuel Mendoza-Jonas --- discover/parser.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'discover/parser.c') diff --git a/discover/parser.c b/discover/parser.c index 5598f96..9fe1925 100644 --- a/discover/parser.c +++ b/discover/parser.c @@ -128,6 +128,22 @@ out: return -1; } +int parser_scandir(struct discover_context *ctx, const char *dirname, + struct dirent ***files, int (*filter)(const struct dirent *), + int (*comp)(const struct dirent **, const struct dirent **)) +{ + char *path; + int n; + + path = talloc_asprintf(ctx, "%s%s", ctx->device->mount_path, dirname); + if (!path) + return -1; + + n = scandir(path, files, filter, comp); + talloc_free(path); + return n; +} + void iterate_parsers(struct discover_context *ctx) { struct p_item* i; -- cgit v1.2.1