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