summary refs log tree commit diff
path: root/nixos/modules/system
diff options
context:
space:
mode:
authorJörg Thalheim <joerg@thalheim.io>2023-10-10 10:53:58 +0200
committerJörg Thalheim <Mic92@users.noreply.github.com>2023-10-10 14:49:51 +0200
commitb7057368c8c23e622cbf06089b313268fad053e2 (patch)
tree428a72021e2dad94d67038d7cb0bfc4617690f23 /nixos/modules/system
parent8335022649bf58adc24d0599e48ec69d632f439e (diff)
downloadnixpkgs-b7057368c8c23e622cbf06089b313268fad053e2.tar
nixpkgs-b7057368c8c23e622cbf06089b313268fad053e2.tar.gz
nixpkgs-b7057368c8c23e622cbf06089b313268fad053e2.tar.bz2
nixpkgs-b7057368c8c23e622cbf06089b313268fad053e2.tar.lz
nixpkgs-b7057368c8c23e622cbf06089b313268fad053e2.tar.xz
nixpkgs-b7057368c8c23e622cbf06089b313268fad053e2.tar.zst
nixpkgs-b7057368c8c23e622cbf06089b313268fad053e2.zip
systemd-boot-builder: add missing fsync in atomic writes
write(2) and close(2) doesn't ensure the file content actually got synched, so let's also fsync before doing the rename
Diffstat (limited to 'nixos/modules/system')
-rw-r--r--nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py
index 78b43c57e90..310584e398b 100644
--- a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py
+++ b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py
@@ -66,6 +66,8 @@ def write_loader_conf(profile: str | None, generation: int, specialisation: str
         if not @editor@:
             f.write("editor 0\n")
         f.write("console-mode @consoleMode@\n")
+        f.flush()
+        os.fsync(f.fileno())
     os.rename("@efiSysMountPoint@/loader/loader.conf.tmp", "@efiSysMountPoint@/loader/loader.conf")
 
 
@@ -143,6 +145,8 @@ def write_entry(profile: str | None, generation: int, specialisation: str | None
                     description=describe_generation(profile, generation, specialisation)))
         if machine_id is not None:
             f.write("machine-id %s\n" % machine_id)
+        f.flush()
+        os.fsync(f.fileno())
     os.rename(tmp_path, entry_file)