]> git.ozlabs.org Git - petitboot/blob - discover/paths.h
discover/boot: Improve kexec error reporting
[petitboot] / discover / paths.h
1 #ifndef PATHS_H
2 #define PATHS_H
3
4 #include <url/url.h>
5
6 /**
7  * Utility function for joining two paths. Adds a / between a and b if
8  * required.
9  *
10  * Returns a newly-allocated string.
11  */
12 char *join_paths(void *alloc_ctx, const char *a, const char *b);
13
14 /**
15  * Returns the base path for mount points
16  */
17 const char *mount_base(void);
18
19 struct load_task;
20
21 struct load_url_result {
22         enum {
23                 LOAD_OK,    /* load complete. other members should only be
24                                accessed if status == LOAD_OK */
25
26                 LOAD_ERROR, /* only signalled to async loaders
27                              * (sync will see a NULL result) */
28
29                 LOAD_ASYNC, /* async load still in progress */
30
31                 LOAD_CANCELLED,
32         } status;
33         struct pb_url           *url;
34         const char              *local;
35         bool                    cleanup_local;
36         struct load_task        *task;
37 };
38
39 /* callback type for asynchronous loads. The callback implementation is
40  * responsible for freeing result.
41  */
42 typedef void (*load_url_complete)(struct load_url_result *result, void *data);
43
44 /* Load a (potentially remote) file, and return a guaranteed-local name */
45 struct load_url_result *load_url_async(void *ctx, struct pb_url *url,
46                 load_url_complete complete, void *data);
47
48 /* Cancel a pending load */
49 void load_url_async_cancel(struct load_url_result *res);
50
51 struct load_url_result *load_url(void *ctx, struct pb_url *url);
52
53 #endif /* PATHS_H */