Commit b7057368 authored by Jörg Thalheim's avatar Jörg Thalheim
Browse files

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
parent 83350226
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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)