]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/bootspec.h
12accc6c44302c67f9915af2f0cfb03df204f8e9
[thirdparty/systemd.git] / src / shared / bootspec.h
1 /***
2 This file is part of systemd.
3
4 Copyright 2017 Zbigniew Jędrzejewski-Szmek
5
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
10
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
18 ***/
19
20 #pragma once
21
22 #include <stdlib.h>
23
24 typedef struct BootEntry {
25 char *filename;
26
27 char *title;
28 char *show_title;
29 char *version;
30 char *machine_id;
31 char *architecture;
32 char **options;
33 char *kernel; /* linux is #defined to 1, yikes! */
34 char *efi;
35 char **initrd;
36 char *device_tree;
37 } BootEntry;
38
39 typedef struct BootConfig {
40 char *default_pattern;
41 char *timeout;
42 char *editor;
43 char *auto_entries;
44 char *auto_firmware;
45 char *console_mode;
46
47 char *entry_oneshot;
48 char *entry_default;
49
50 BootEntry *entries;
51 size_t n_entries;
52 ssize_t default_entry;
53 } BootConfig;
54
55 void boot_entry_free(BootEntry *entry);
56 int boot_entry_load(const char *path, BootEntry *entry);
57 int boot_entries_find(const char *dir, BootEntry **entries, size_t *n_entries);
58
59 int boot_loader_read_conf(const char *path, BootConfig *config);
60 void boot_config_free(BootConfig *config);
61 int boot_entries_load_config(const char *esp_path, BootConfig *config);
62
63 static inline const char* boot_entry_title(const BootEntry *entry) {
64 return entry->show_title ?: entry->title ?: entry->filename;
65 }
66
67 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);