]> git.ozlabs.org Git - petitboot/blob - discover/device-handler.h
discover: Handle unresolved resources
[petitboot] / discover / device-handler.h
1 #ifndef _DEVICE_HANDLER_H
2 #define _DEVICE_HANDLER_H
3
4 #include <list/list.h>
5
6 struct device_handler;
7 struct discover_device;
8 struct discover_server;
9 struct boot_option;
10 struct boot_command;
11 struct event;
12 struct device;
13
14 struct discover_device {
15         struct device           *device;
16
17         char                    **links;
18         int                     n_links;
19
20         char                    *uuid;
21         char                    *label;
22
23         char                    *mount_path;
24         char                    *device_path;
25
26         struct list             boot_options;
27 };
28
29 struct discover_boot_option {
30         struct parser           *source;
31         struct discover_device  *device;
32         struct boot_option      *option;
33         struct list_item        list;
34
35         struct resource         *boot_image;
36         struct resource         *initrd;
37         struct resource         *icon;
38 };
39
40
41 struct discover_context {
42         struct parser           *parser;
43         struct event            *event;
44         struct discover_device  *device;
45         struct list             boot_options;
46 };
47
48 struct device_handler *device_handler_init(struct discover_server *server,
49                 int dry_run);
50
51 void device_handler_destroy(struct device_handler *devices);
52
53 int device_handler_get_device_count(const struct device_handler *handler);
54 const struct discover_device *device_handler_get_device(
55         const struct device_handler *handler, unsigned int index);
56
57 struct device *discover_context_device(struct discover_context *ctx);
58 struct discover_boot_option *discover_boot_option_create(
59                 struct discover_context *ctx,
60                 struct discover_device *dev);
61 void discover_context_add_boot_option(struct discover_context *ctx,
62                 struct discover_boot_option *opt);
63
64 int device_handler_event(struct device_handler *handler, struct event *event);
65
66 struct discover_device *device_lookup_by_name(struct device_handler *handler,
67                 const char *name);
68 struct discover_device *device_lookup_by_path(struct device_handler *handler,
69                 const char *path);
70 struct discover_device *device_lookup_by_uuid(struct device_handler *handler,
71                 const char *uuid);
72 struct discover_device *device_lookup_by_label(struct device_handler *handler,
73                 const char *label);
74 struct discover_device *device_lookup_by_id(struct device_handler *handler,
75                 const char *id);
76
77 void device_handler_boot(struct device_handler *handler,
78                 struct boot_command *cmd);
79
80 #endif /* _DEVICE_HANDLER_H */