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