4 #include <talloc/talloc.h>
6 #include <discover/resource.h>
7 #include <discover/parser.h>
8 #include <discover/parser-utils.h>
14 static const char *const grub2_conf_files[] = {
20 "/boot/grub/grub.cfg",
21 "/boot/grub2/grub.cfg",
22 "/boot/grub/menu.lst",
28 "/BOOT/GRUB/GRUB.CFG",
29 "/BOOT/GRUB/MENU.LST",
33 struct grub2_resource_info {
38 /* we use slightly different resources for grub2 */
39 struct resource *create_grub2_resource(void *ctx,
40 struct discover_device *orig_device,
41 const char *root, const char *path)
43 struct grub2_resource_info *info;
46 res = talloc(ctx, struct resource);
49 info = talloc(res, struct grub2_resource_info);
50 talloc_reference(info, root);
51 info->root = talloc_strdup(info, root);
52 info->path = talloc_strdup(info, path);
54 res->resolved = false;
58 resolve_resource_against_device(res, orig_device, path);
63 bool resolve_grub2_resource(struct device_handler *handler,
66 struct grub2_resource_info *info = res->info;
67 struct discover_device *dev;
69 assert(!res->resolved);
71 dev = device_lookup_by_uuid(handler, info->root);
76 resolve_resource_against_device(res, dev, info->path);
82 static int grub2_parse(struct discover_context *dc, char *buf, int len)
84 struct grub2_parser *parser;
86 parser = grub2_parser_create(dc);
88 grub2_parser_parse(parser, buf, len);
95 static struct parser grub2_parser = {
97 .method = CONF_METHOD_LOCAL_FILE,
99 .filenames = grub2_conf_files,
100 .resolve_resource = resolve_grub2_resource,
103 register_parser(grub2_parser);