summaryrefslogtreecommitdiffstats
path: root/src/boot
diff options
context:
space:
mode:
authorValentin David <me@valentindavid.com>2023-10-19 23:13:45 +0200
committerLuca Boccassi <luca.boccassi@gmail.com>2023-10-20 17:18:09 +0200
commit7a876307bb64cb4cd20388229f79cf5da3fa3ec2 (patch)
tree9736ce603664958a1c272ede796051dac118f3ce /src/boot
parentmkfs-util: set timezone to UTC when copying files into fat partition (diff)
downloadsystemd-7a876307bb64cb4cd20388229f79cf5da3fa3ec2.tar.xz
systemd-7a876307bb64cb4cd20388229f79cf5da3fa3ec2.zip
stub: Ignore the boot counter when looking for .extra.d directory
If `foo+3-0.efi` is booted when there are some files in `foo.efi.extra.d`, those files are ignored. But after the boot is blessed and the system rebooted, those file are taken into account, and the boot is different from first boot. This behavior is a bit puzzling. Instead we now ignore the counter and always look for the extra files in `foo.efi.extra.d` and always boot the same way.
Diffstat (limited to 'src/boot')
-rw-r--r--src/boot/efi/util.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/boot/efi/util.c b/src/boot/efi/util.c
index 32796f9ff2..25f5e0f032 100644
--- a/src/boot/efi/util.c
+++ b/src/boot/efi/util.c
@@ -646,6 +646,34 @@ void *find_configuration_table(const EFI_GUID *guid) {
return NULL;
}
+static void remove_boot_count(char16_t *path) {
+ char16_t *prefix_end;
+ const char16_t *tail;
+ uint64_t ignored;
+
+ assert(path);
+
+ prefix_end = strchr16(path, '+');
+ if (!prefix_end)
+ return;
+
+ tail = prefix_end + 1;
+
+ if (!parse_number16(tail, &ignored, &tail))
+ return;
+
+ if (*tail == '-') {
+ ++tail;
+ if (!parse_number16(tail, &ignored, &tail))
+ return;
+ }
+
+ if (!IN_SET(*tail, '\0', '.'))
+ return;
+
+ strcpy16(prefix_end, tail);
+}
+
char16_t *get_extra_dir(const EFI_DEVICE_PATH *file_path) {
if (!file_path)
return NULL;
@@ -666,5 +694,6 @@ char16_t *get_extra_dir(const EFI_DEVICE_PATH *file_path) {
return NULL;
convert_efi_path(file_path_str);
+ remove_boot_count(file_path_str);
return xasprintf("%ls.extra.d", file_path_str);
}