]> git.ozlabs.org Git - petitboot/blob - discover/device-handler.h
discover: kexec harder
[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 enum conf_method {
15         CONF_METHOD_LOCAL_FILE, /* discover by looking at local files on this
16                                    block device */
17
18         CONF_METHOD_DHCP,       /* configuration from a DHCP response */
19
20         CONF_METHOD_UNKNOWN = -1,
21 };
22
23 struct discover_device {
24         struct device           *device;
25
26         char                    **links;
27         int                     n_links;
28
29         char                    *uuid;
30         char                    *label;
31
32         char                    *mount_path;
33         char                    *device_path;
34
35         struct list             boot_options;
36 };
37
38 struct discover_boot_option {
39         struct parser           *source;
40         struct discover_device  *device;
41         struct boot_option      *option;
42         struct list_item        list;
43
44         struct resource         *boot_image;
45         struct resource         *initrd;
46         struct resource         *icon;
47 };
48
49
50 struct discover_context {
51         struct parser           *parser;
52         struct event            *event;
53         struct discover_device  *device;
54         struct list             boot_options;
55         struct pb_url           *conf_url;
56         enum conf_method        method;
57 };
58
59 struct device_handler *device_handler_init(struct discover_server *server,
60                 int dry_run);
61
62 void device_handler_destroy(struct device_handler *devices);
63
64 int device_handler_get_device_count(const struct device_handler *handler);
65 const struct discover_device *device_handler_get_device(
66         const struct device_handler *handler, unsigned int index);
67
68 struct device *discover_context_device(struct discover_context *ctx);
69 struct discover_boot_option *discover_boot_option_create(
70                 struct discover_context *ctx,
71                 struct discover_device *dev);
72 void discover_context_add_boot_option(struct discover_context *ctx,
73                 struct discover_boot_option *opt);
74
75 int device_handler_event(struct device_handler *handler, struct event *event);
76
77 struct discover_device *device_lookup_by_name(struct device_handler *handler,
78                 const char *name);
79 struct discover_device *device_lookup_by_path(struct device_handler *handler,
80                 const char *path);
81 struct discover_device *device_lookup_by_uuid(struct device_handler *handler,
82                 const char *uuid);
83 struct discover_device *device_lookup_by_label(struct device_handler *handler,
84                 const char *label);
85 struct discover_device *device_lookup_by_id(struct device_handler *handler,
86                 const char *id);
87
88 void device_handler_boot(struct device_handler *handler,
89                 struct boot_command *cmd);
90
91 #endif /* _DEVICE_HANDLER_H */