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