summaryrefslogtreecommitdiffstats
path: root/src/shared/bootspec.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* bootspec: Add PE file name to log messagesJan Janssen2022-06-221-18/+19
| | | | Fixes: #23783
* Do not require a valid version when parsing sd-boot loader entriesVictor Westerhuis2022-05-221-3/+5
| | | | This fixes #20820
* Merge pull request #23310 from keszybz/suppress-fuzzer-timeouts-and-errorsYu Watanabe2022-05-091-1/+1
|\ | | | | Suppress fuzzer timeouts and errors
| * tree-wide: drop de-constifying casts for strv iterationZbigniew Jędrzejewski-Szmek2022-05-081-1/+1
| | | | | | | | | | | | | | When the the iterator variable is declared automatically, it "inherits" the const/non-const status from the argument. We don't need to cast a const table to non-const. If we had a programming error and tried to modify the string, the compiler could now catch this.
* | shared/bootspec: add missing terminator to tableZbigniew Jędrzejewski-Szmek2022-05-081-0/+1
| |
* | shared/bootspec: avoid crashing on config without a valueZbigniew Jędrzejewski-Szmek2022-05-081-0/+7
| |
* | shared/bootspec: also export boot_config_load_type1()Zbigniew Jędrzejewski-Szmek2022-05-081-8/+28
| | | | | | | | | | | | The reallocation of memory and counter incrementation is moved from the only caller to the function. This way the callers can remain oblivious of the BootConfig internals.
* | shared/bootspec: expose more parts of the config parsingZbigniew Jędrzejewski-Szmek2022-05-081-20/+35
| |
* | Move printing of boot entries from bootctl.c to shared/Zbigniew Jędrzejewski-Szmek2022-05-081-1/+193
|/ | | | | I want to use this for fuzzing, but also later to return jsonified list of entries from logind.
* basic: split out dev_t related calls into new devno-util.[ch]Lennart Poettering2022-04-131-2/+2
| | | | | | | | | | | | | | No actual code changes, just splitting out of some dev_t handling related calls from stat-util.[ch], they are quite a number already, and deserve their own module now I think. Also, try to settle on the name "devnum" as the name for the concept, instead of "devno" or "dev" or "devid". "devnum" is the name exported in udev APIs, hence probably best to stick to that. (this just renames a few symbols to "devum", local variables are left untouched, to make the patch not too invasive) No actual code changes.
* bootspec: normalize function names/parameter listsLennart Poettering2022-03-281-9/+9
| | | | | | | | | | | | | This normalizes naming of functions operating on BootConfig objects. Let's always call them boot_config_xyz(), like our usual way to name stuff. moreover, move the BootConfig parameter to the beginning, as it's not a return value (which we typically move to the end of the parameter list), but simply an object, that even happens to be initialized already. With these changes the functions are more like our usual way to call things, and less surprises are good.
* bootspec: don't needlessly inline boot_config_find_entry()Lennart Poettering2022-03-281-0/+12
| | | | | | the function contains a loop and if expressions and whatnot. Let's define it as regular function, to make the header easier to read and let the compiler more freedom on whether to inline this or not.
* bootspec: assess default/selected entries *after* we augmented entry list ↵Lennart Poettering2022-03-281-7/+15
| | | | | | with entries from loader Fixes: #22580
* bootspec: normalize oom handling in boot_load_efi_entry_pointers()Lennart Poettering2022-03-281-15/+12
| | | | OOM should usually be fatal, hence make it so here, too.
* bootspec: rename type1 parsers to say "type1" explicitly in the nameLennart Poettering2022-03-281-5/+5
| | | | | | | | This just got too confusing for me. With this change we'll now have _unified as common suffix for stuff loading unified kernels (i.e. type 1), and _type1 as common suffix for type1 entries. Just some renaming.
* bootspec: try harder to suppress duplicate enumerated entriesLennart Poettering2022-03-281-13/+66
| | | | | | | | | | | | | For testing purposes I run one of my system symlinking /boot/loader/ to /efi/loader/. This triggers annoying behaviour in boot entry enumeration: the code ends up iterating through the 'entries' subdir of both, thinking one was actually in the ESP and the other in XBOOTLDR, and thus distinct. This would result in duplicate entries. Let's address that, and filter out duplicates via their inode numbers: never process the same inode twice. This should protect us from any confusion effectively, regardless which inodes are symlinked (or even bind mounted).
* bootspec: pass around BootConfig struct instead of entries/n_entries fields onlyLennart Poettering2022-03-281-21/+16
| | | | | This simplifies the parameter lists quite a bit, at zero change in behaviour.
* bootspec: don't use conf_files_list() for finding type #1 entriesLennart Poettering2022-03-281-27/+59
| | | | | | | | | | | | We can't really use conf_files_list() for finding type #1 entries, since it is case-sensitive, but type #1 entries are typically placed on VFAT, i.e. are case-insensitive. hence, use readdir_all() instead, which is quite similar, but gives us all files, and allows us to do a case-insensitive check. While we are at it, use openat() on the open dir to open the file, and pass that around, to make things a tiny bit more race-free.
* Merge pull request #22791 from keszybz/bootctl-invert-orderLennart Poettering2022-03-231-11/+9
|\ | | | | Invert order of entries w/o sort-key in sd-boot menu
| * sd-boot+bootctl: invert order of entries w/o sort-keyZbigniew Jędrzejewski-Szmek2022-03-181-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | With the changes in 20ec8f534f90c94669ac8f9a50869f22f94fd4c8, we would sort entries with sort-key as expected (higher versions earlier, i.e. at the top of the menu), but entries without the sort-key as before, with higher versions later. When we have a bunch of boot entries grouped by machine-id (or even in the typical case of all boot entries having the same machine id), sorting by id should generally give good results. Entries will be grouped by installation, and then newer entries should generally be at the top of the menu.
| * shared/bootspec: reduce scope of variablesZbigniew Jędrzejewski-Szmek2022-03-181-10/+7
| |
* | strv: make iterator in STRV_FOREACH() declaread in the loopYu Watanabe2022-03-191-4/+0
| | | | | | | | This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
* | Merge pull request #22519 from poettering/boot-order-title-revertZbigniew Jędrzejewski-Szmek2022-03-181-32/+73
|\| | | | | sd-boot: rework boot entry sorting
| * sd-boot: make use of new "sort-key" boot loader spec fieldLennart Poettering2022-03-181-32/+73
| |
* | shared: split out ESP/XBOOTLDR search stuff from bootspec.cLennart Poettering2022-03-181-713/+2
|/ | | | | | | | The code is quite different from the rest of bootspec.c, with different deps and stuff. There's even a /***/ line to separate the two parts. Given how large the file already is, let#s just split it into two. No code changes, just some splitting out.
* Merge pull request #22487 from poettering/bootspec-source-flagsYu Watanabe2022-02-141-67/+182
|\ | | | | bootctl: show all discovered entries, but show state + type in details
| * bootspec: avoid zero size VLALennart Poettering2022-02-141-16/+17
| | | | | | | | | | | | apparently some checkers don't like that. Let's be entirely safe here, and use malloc() based allocation, given that the entries are user controlled.
| * boot: suppress XBOOTLDR if same device as ESP when enumerating entriesLennart Poettering2022-02-141-16/+62
| | | | | | | | | | | | | | | | | | | | On my local system I linked up the ESP and XBOOTLDR partitions, and ended up with duplicate entries being listed. Try hard to detect that and only enumerate entries in the ESP if it turns out that both dirs have the same dev_t. This should detect both bind mounted and symlinked cases and should make our list output less confusing.
| * bootspec: make sure all return values are initialized on return of ↵Lennart Poettering2022-02-141-0/+13
| | | | | | | | | | | | | | | | | | | | find_esp_and_warn() THis makes sure that find_esp_and_warn() + find_xbootldr_and_warn() follow our usual coding style that on success all return values are initialized. We got that right in most successful codepaths out of these functions, but missed the one where the paths are manually overwritten via env vars.
| * bootctl: show more information about boot entry state in listLennart Poettering2022-02-141-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Let's improve display of boot entries and show what type they have (i.e. boot loader spec type 1, or type 2, or auto-discovered or reported by boot loader), and in particular mark entries the boot loader discovered but we can't find (i.e. that likely vanished, or possibly couldn't be found due to a misconfiguration) and that the boot loader didn't find but we see (which are new, or possibly also the result of misconfiguraiton). This is supposed to be a replacement for #22161, but instead of hiding vanished entries, highlights them, which I think is more appropriate for a low-level tool such bootctl. Replaces: #22161 #22398
| * bootspec: also collect/mark the "selected" boot entry (i.e. the one ↵Lennart Poettering2022-02-141-15/+55
| | | | | | | | | | | | currently booted) it's helpful and easy, so let's do it
| * bootspec: also parse new 'beep' loader.conf variableLennart Poettering2022-02-141-0/+3
| |
| * bootspec: parse/show devicetree-overlay field tooLennart Poettering2022-02-141-1/+10
| | | | | | | | | | It has been defined in the boot loader spec, and is the only field we currently don't parse, hence fix that.
| * bootspec: port one more use of basename() to path_extract_filename()Lennart Poettering2022-02-141-9/+11
| |
| * Revert "bootctl: Ignore boot entries (continue #22041)"Lennart Poettering2022-02-141-7/+3
| |
* | tree-wide: use id128_equal_string() at various placesLennart Poettering2022-02-141-4/+6
|/
* bootctl: removed unused parameter only_autoGoffredo Baroncelli2022-01-181-3/+7
| | | | | | | | Remove the parameter 'only_auto' from the function boot_entries_augment_from_loader() because each caller set it always to true. Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it>
* Define FOREACH_DIRENT through FOREACH_DIRENT_ALLZbigniew Jędrzejewski-Szmek2021-12-151-1/+0
| | | | As in the previous commit, 'de' is used as the iterator variable name.
* tree-wide: use new RET_NERRNO() helper at various placesLennart Poettering2021-11-161-1/+2
|
* bootspec: catch up with sd-boot's bootspec implementationLennart Poettering2021-11-111-12/+37
| | | | | | Let's parse the same fields and use them the same way as in sd-boot. Fixes: #20093
* dirent-util: use readdir_ensure_type() in readdir_no_dot() and FOREACH_DIRENT()Yu Watanabe2021-06-231-1/+0
|
* basic/efivars: replace dynanamic creation of efivar names with static stringsZbigniew Jędrzejewski-Szmek2021-06-151-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | Creating those string dynamically at runtime is slow and unnecessary. Let's use static strings with a bit of macro magic and the let the compiler coalesce as much as possible. $ size build/src/shared/libsystemd-shared-248.so{.old,} text data bss dec hex filename 2813453 94572 4584 2912609 2c7161 build/src/shared/libsystemd-shared-248.so.old 2812309 94564 4584 2911457 2c6ce1 build/src/shared/libsystemd-shared-248.so A nice side-effect is that the same form is used everywhere, so it's easier to figure out all variables that are used, and where each specific variable is used. C.f. 2b0445262ad9be2a9bf49956ab8e886ea2e48a0a. Note: 'const char *foo = alloca(…);' seems OK. Our coding style document and alloca(3) only warn against using alloca() in function invocations. Declaring both stack variable and alloca at the same time should be fine: no matter in which order they happen, i.e. if the pointer variable is above the contents, or the contents are above the pointer, or even if the pointer is elided by the compiler, everything should be fine.
* alloc-util: simplify GREEDY_REALLOC() logic by relying on malloc_usable_size()Lennart Poettering2021-05-191-8/+3
| | | | | | | | | | | | | | | | | | | | | | | | We recently started making more use of malloc_usable_size() and rely on it (see the string_erase() story). Given that we don't really support sytems where malloc_usable_size() cannot be trusted beyond statistics anyway, let's go fully in and rework GREEDY_REALLOC() on top of it: instead of passing around and maintaining the currenly allocated size everywhere, let's just derive it automatically from malloc_usable_size(). I am mostly after this for the simplicity this brings. It also brings minor efficiency improvements I guess, but things become so much nicer to look at if we can avoid these allocation size variables everywhere. Note that the malloc_usable_size() man page says relying on it wasn't "good programming practice", but I think it does this for reasons that don't apply here: the greedy realloc logic specifically doesn't rely on the returned extra size, beyond the fact that it is equal or larger than what was requested. (This commit was supposed to be a quick patch btw, but apparently we use the greedy realloc stuff quite a bit across the codebase, so this ends up touching *a*lot* of code.)
* bootspec: assume that the root dir is at the top of its file systemv248-rc2Lennart Poettering2021-02-231-4/+11
| | | | Fixes: #17746
* tree-wide: replace strverscmp() and str_verscmp() with strverscmp_improved()Yu Watanabe2021-02-091-1/+1
|
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* bootspec: tweak error messageLennart Poettering2020-10-191-2/+2
| | | | | Clarify that the name of the entry failed validation, not the entry itself.
* bootspec: don't fail with EIO if searching for ESP and finding one without ↵Lennart Poettering2020-10-011-4/+6
| | | | | | | | an enveloping partition table If this happens this should just mean: we couldn't find the ESP. Fixes: #17122
* efi: cache LoaderEntries EFI variableLennart Poettering2020-05-291-12/+6
| | | | | | Based-on: https://github.com/systemd/systemd/issues/14828#issuecomment-634202054
* bootspec: parse random-seed-mode line in loader.confYu Watanabe2020-01-261-0/+3
| | | | Fixes #14657.