]> git.ozlabs.org Git - petitboot/blob - discover/resource.h
ui/ncurses: Use nc-widgets for boot editor
[petitboot] / discover / resource.h
1 #ifndef RESOURCE_H
2 #define RESOURCE_H
3
4 #include <stdbool.h>
5
6 struct discover_boot_option;
7 struct discover_device;
8 struct device_handler;
9 struct pb_url;
10
11 /**
12  * Data for local/remote resources. Resources may be "unresolved", in that
13  * they refer to a device that is not yet present. Unresolved resources
14  * simply contain parser-specific data (generally a device string parsed from
15  * the config file), and may be resolved by the parser once new devices appear.
16  */
17 struct resource {
18         bool resolved;
19         union {
20                 struct pb_url   *url;
21                 void            *info;
22         };
23 };
24
25 void resolve_resource_against_device(struct resource *res,
26         struct discover_device *dev, const char *path);
27
28 /**
29  * devpath resources.
30  *
31  * Most resources in config files will be in one of the following formats:
32  *  - URLs
33  *  - device-local filenames (ie, filenames on the currently-discovered dev)
34  *  - other-device filenames (which speficy the device by a string format,
35  *     using a dev:path format).
36  *
37  * The following definitions are a generic resource handler for these types
38  * of resources. By creating resources with create_devpath_resource,
39  * parsers can use resolve_devpath_resource as their resolve_resouce
40  * callback.
41  */
42
43 struct resource *create_devpath_resource(struct discover_boot_option *opt,
44                 struct discover_device *orig_device,
45                 const char *devpath);
46
47 struct resource *create_url_resource(struct discover_boot_option *opt,
48                 struct pb_url *url);
49
50 bool resolve_devpath_resource(struct device_handler *dev,
51                 struct resource *res);
52
53 #endif /* RESOURCE_H */
54