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