From 06130c5e61160b20305c9e6a621fa1c4d0df7858 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 5 Jan 2026 20:31:31 -0800 Subject: [PATCH] std.Io.Threaded: set O_DIRECTORY along with O_TMPFILE --- lib/std/Io/Threaded.zig | 2 ++ lib/std/c.zig | 2 ++ lib/std/os/linux.zig | 8 ++++++++ 3 files changed, 12 insertions(+) diff --git a/lib/std/Io/Threaded.zig b/lib/std/Io/Threaded.zig index 613001224f0a09f13ad872c1902b0d197f92fb09..ed409149509984486c5545879d092ab637a9dc72 100644 --- a/lib/std/Io/Threaded.zig +++ b/lib/std/Io/Threaded.zig @@ -3433,11 +3433,13 @@ fn dirCreateFileAtomic( const flags: posix.O = if (@hasField(posix.O, "TMPFILE")) .{ .ACCMODE = .RDWR, .TMPFILE = true, + .DIRECTORY = true, .CLOEXEC = true, } else if (@hasField(posix.O, "TMPFILE0") and !@hasField(posix.O, "TMPFILE2")) .{ .ACCMODE = .RDWR, .TMPFILE0 = true, .TMPFILE1 = true, + .DIRECTORY = true, .CLOEXEC = true, } else break :tmpfile; diff --git a/lib/std/c.zig b/lib/std/c.zig index 0e620082b40ba0532d4dfe3862ea84254f7c7237..3eea82d3da7edc361681b1608cd1876ac5e0e671 100644 --- a/lib/std/c.zig +++ b/lib/std/c.zig @@ -8427,6 +8427,7 @@ pub const O = switch (native_os) { CLOEXEC: bool = false, SYNC: bool = false, PATH: bool = false, + /// This is typically invalid without also setting `DIRECTORY`. TMPFILE: bool = false, _: u9 = 0, }, @@ -8615,6 +8616,7 @@ pub const O = switch (native_os) { _19: u1 = 0, CLOEXEC: bool = false, PATH: bool = false, + /// This is typically invalid without also setting `DIRECTORY`. TMPFILE: bool = false, _: u9 = 0, }, diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index 023674e71043c1846ca6f7b083d65fd7c53a027f..812e07f7e821d5bd3fa34032b0e9088d74465ef4 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -324,6 +324,7 @@ pub const O = switch (native_arch) { CLOEXEC: bool = false, SYNC: bool = false, PATH: bool = false, + /// This is typically invalid without also setting `DIRECTORY`. TMPFILE: bool = false, _23: u9 = 0, }, @@ -346,6 +347,7 @@ pub const O = switch (native_arch) { CLOEXEC: bool = false, SYNC: bool = false, PATH: bool = false, + /// This is typically invalid without also setting `DIRECTORY`. TMPFILE: bool = false, _23: u9 = 0, }, @@ -368,6 +370,7 @@ pub const O = switch (native_arch) { CLOEXEC: bool = false, SYNC: bool = false, PATH: bool = false, + /// This is typically invalid without also setting `DIRECTORY`. TMPFILE: bool = false, _23: u9 = 0, }, @@ -393,6 +396,7 @@ pub const O = switch (native_arch) { CLOEXEC: bool = false, SYNC: bool = false, PATH: bool = false, + /// This is typically invalid without also setting `DIRECTORY`. TMPFILE: bool = false, _27: u6 = 0, }, @@ -417,6 +421,7 @@ pub const O = switch (native_arch) { CLOEXEC: bool = false, _20: u1 = 0, PATH: bool = false, + /// This is typically invalid without also setting `DIRECTORY`. TMPFILE: bool = false, _23: u9 = 0, }, @@ -439,6 +444,7 @@ pub const O = switch (native_arch) { CLOEXEC: bool = false, SYNC: bool = false, PATH: bool = false, + /// This is typically invalid without also setting `DIRECTORY`. TMPFILE: bool = false, _23: u9 = 0, }, @@ -459,9 +465,11 @@ pub const O = switch (native_arch) { NOFOLLOW: bool = false, NOATIME: bool = false, CLOEXEC: bool = false, + /// This is typically invalid without also setting `TMPFILE1` and `DIRECTORY`. TMPFILE0: bool = false, PATH: bool = false, _22: u4 = 0, + /// This is typically invalid without also setting `TMPFILE0` and `DIRECTORY`. TMPFILE1: bool = false, _27: u5 = 0, -- 2.54.0