]>
Commit | Line | Data |
---|---|---|
58f21e63 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
7e87c7d9 ZJS |
2 | |
3 | #pragma once | |
4 | ||
195b36cf LP |
5 | #include <inttypes.h> |
6 | #include <stdbool.h> | |
7 | #include <sys/types.h> | |
8 | ||
9 | #include "sd-id128.h" | |
7e87c7d9 | 10 | |
93f14ce2 LP |
11 | #include "string-util.h" |
12 | ||
13 | typedef enum BootEntryType { | |
14 | BOOT_ENTRY_CONF, /* Type #1 entries: *.conf files */ | |
15 | BOOT_ENTRY_UNIFIED, /* Type #2 entries: *.efi files */ | |
16 | BOOT_ENTRY_LOADER, /* Additional entries augmented from LoaderEntries EFI var */ | |
17 | _BOOT_ENTRY_MAX, | |
18 | _BOOT_ENTRY_INVALID = -1, | |
19 | } BootEntryType; | |
20 | ||
7e87c7d9 | 21 | typedef struct BootEntry { |
93f14ce2 | 22 | BootEntryType type; |
2d3bfb69 | 23 | char *id; /* This is the file basename without extension */ |
43b736a8 LP |
24 | char *path; /* This is the full path to the drop-in file */ |
25 | char *root; /* The root path in which the drop-in was found, i.e. to which 'kernel', 'efi' and 'initrd' are relative */ | |
7e87c7d9 | 26 | char *title; |
64f05708 | 27 | char *show_title; |
7e87c7d9 ZJS |
28 | char *version; |
29 | char *machine_id; | |
30 | char *architecture; | |
31 | char **options; | |
32 | char *kernel; /* linux is #defined to 1, yikes! */ | |
33 | char *efi; | |
34 | char **initrd; | |
35 | char *device_tree; | |
36 | } BootEntry; | |
37 | ||
38 | typedef struct BootConfig { | |
39 | char *default_pattern; | |
40 | char *timeout; | |
41 | char *editor; | |
c1d4e298 JJ |
42 | char *auto_entries; |
43 | char *auto_firmware; | |
d37b0737 | 44 | char *console_mode; |
7e87c7d9 ZJS |
45 | |
46 | char *entry_oneshot; | |
47 | char *entry_default; | |
48 | ||
49 | BootEntry *entries; | |
50 | size_t n_entries; | |
51 | ssize_t default_entry; | |
52 | } BootConfig; | |
53 | ||
93f14ce2 LP |
54 | static inline bool boot_config_has_entry(BootConfig *config, const char *id) { |
55 | size_t j; | |
56 | ||
57 | for (j = 0; j < config->n_entries; j++) | |
58 | if (streq(config->entries[j].id, id)) | |
59 | return true; | |
60 | ||
61 | return false; | |
62 | } | |
63 | ||
38bd74d6 LP |
64 | static inline BootEntry* boot_config_default_entry(BootConfig *config) { |
65 | if (config->default_entry < 0) | |
66 | return NULL; | |
67 | ||
68 | return config->entries + config->default_entry; | |
69 | } | |
70 | ||
7e87c7d9 | 71 | void boot_config_free(BootConfig *config); |
a2f8664e | 72 | int boot_entries_load_config(const char *esp_path, const char *xbootldr_path, BootConfig *config); |
eea4ce1e | 73 | int boot_entries_load_config_auto(const char *override_esp_path, const char *override_xbootldr_path, BootConfig *config); |
93f14ce2 | 74 | int boot_entries_augment_from_loader(BootConfig *config, bool only_auto); |
64f05708 ZJS |
75 | |
76 | static inline const char* boot_entry_title(const BootEntry *entry) { | |
12580bc3 | 77 | return entry->show_title ?: entry->title ?: entry->id; |
64f05708 | 78 | } |
af918182 | 79 | |
5caa3167 | 80 | int find_esp_and_warn(const char *path, bool unprivileged_mode, char **ret_path, uint32_t *ret_part, uint64_t *ret_pstart, uint64_t *ret_psize, sd_id128_t *ret_uuid); |
15cb6c98 | 81 | int find_xbootldr_and_warn(const char *path, bool unprivileged_mode, char **ret_path,sd_id128_t *ret_uuid); |
1b20d889 | 82 | |
93f14ce2 LP |
83 | const char* boot_entry_type_to_string(BootEntryType t) _const_; |
84 | BootEntryType boot_entry_type_from_string(const char *s) _pure_; |