diff --git a/lib/std/Io/Threaded.zig b/lib/std/Io/Threaded.zig index c63e2b6c56..d55cd67140 100644 --- a/lib/std/Io/Threaded.zig +++ b/lib/std/Io/Threaded.zig @@ -3430,6 +3430,17 @@ fn dirCreateFileAtomic( // useless when we have to make up a bogus path name to do the rename() // anyway. if (native_os == .linux and !options.replace) tmpfile: { + const flags: posix.O = if (@hasField(posix.O, "TMPFILE")) .{ + .ACCMODE = .RDWR, + .TMPFILE = true, + .CLOEXEC = true, + } else if (@hasField(posix.O, "TMPFILE0") and !@hasField(posix.O, "TMPFILE2")) .{ + .ACCMODE = .RDWR, + .TMPFILE0 = true, + .TMPFILE1 = true, + .CLOEXEC = true, + } else break :tmpfile; + const dest_dirname = Dir.path.dirname(dest_path); if (dest_dirname) |dirname| { // This has a nice side effect of preemptively triggering EISDIR or @@ -3456,12 +3467,6 @@ fn dirCreateFileAtomic( var path_buffer: [posix.PATH_MAX]u8 = undefined; const sub_path_posix = try pathToPosix(dest_dirname orelse ".", &path_buffer); - const flags: posix.O = .{ - .ACCMODE = .RDWR, - .TMPFILE = true, - .CLOEXEC = true, - }; - const syscall: Syscall = try .start(); while (true) { const rc = openat_sym(dir.handle, sub_path_posix, flags, options.permissions.toMode()); diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index a1626113ac..023674e710 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -459,13 +459,14 @@ pub const O = switch (native_arch) { NOFOLLOW: bool = false, NOATIME: bool = false, CLOEXEC: bool = false, - _20: u1 = 0, + TMPFILE0: bool = false, PATH: bool = false, - _22: u10 = 0, + _22: u4 = 0, + TMPFILE1: bool = false, + _27: u5 = 0, // #define O_RSYNC 04010000 // #define O_SYNC 04010000 - // #define O_TMPFILE 020200000 // #define O_NDELAY O_NONBLOCK }, .m68k => packed struct(u32) {