authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2025-01-28 03:01:18-08:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-01-29 14:57:07+01:00
log0bf57b71145865fd5da27cfc3d50191666317b0a
tree144227bc62effefe53668783562f1010b344cfe5
parent898658e3a0c4fdc4f352033d62921a8c6bfa2baa

std: mkdir(2) mode uses mode_t


3 files changed, 12 insertions(+), 12 deletions(-)

lib/std/c.zig+3-3
......@@ -136,7 +136,7 @@ pub const dev_t = switch (native_os) {
136136pub const mode_t = switch (native_os) {
137137 .linux => linux.mode_t,
138138 .emscripten => emscripten.mode_t,
139 .openbsd, .haiku, .netbsd, .solaris, .illumos, .wasi => u32,
139 .openbsd, .haiku, .netbsd, .solaris, .illumos, .wasi, .windows => u32,
140140 .freebsd, .macos, .ios, .tvos, .watchos, .visionos, .dragonfly => u16,
141141 else => u0,
142142};
......@@ -9330,8 +9330,8 @@ pub const fork = switch (native_os) {
93309330pub extern "c" fn access(path: [*:0]const u8, mode: c_uint) c_int;
93319331pub extern "c" fn faccessat(dirfd: fd_t, path: [*:0]const u8, mode: c_uint, flags: c_uint) c_int;
93329332pub extern "c" fn pipe(fds: *[2]fd_t) c_int;
9333pub extern "c" fn mkdir(path: [*:0]const u8, mode: c_uint) c_int;
9334pub extern "c" fn mkdirat(dirfd: fd_t, path: [*:0]const u8, mode: u32) c_int;
9333pub extern "c" fn mkdir(path: [*:0]const u8, mode: mode_t) c_int;
9334pub extern "c" fn mkdirat(dirfd: fd_t, path: [*:0]const u8, mode: mode_t) c_int;
93359335pub extern "c" fn symlink(existing: [*:0]const u8, new: [*:0]const u8) c_int;
93369336pub extern "c" fn symlinkat(oldpath: [*:0]const u8, newdirfd: fd_t, newpath: [*:0]const u8) c_int;
93379337pub extern "c" fn rename(old: [*:0]const u8, new: [*:0]const u8) c_int;
lib/std/os/linux.zig+2-2
......@@ -854,7 +854,7 @@ pub fn readlinkat(dirfd: i32, noalias path: [*:0]const u8, noalias buf_ptr: [*]u
854854 return syscall4(.readlinkat, @as(usize, @bitCast(@as(isize, dirfd))), @intFromPtr(path), @intFromPtr(buf_ptr), buf_len);
855855}
856856
857pub fn mkdir(path: [*:0]const u8, mode: u32) usize {
857pub fn mkdir(path: [*:0]const u8, mode: mode_t) usize {
858858 if (@hasField(SYS, "mkdir")) {
859859 return syscall2(.mkdir, @intFromPtr(path), mode);
860860 } else {
......@@ -862,7 +862,7 @@ pub fn mkdir(path: [*:0]const u8, mode: u32) usize {
862862 }
863863}
864864
865pub fn mkdirat(dirfd: i32, path: [*:0]const u8, mode: u32) usize {
865pub fn mkdirat(dirfd: i32, path: [*:0]const u8, mode: mode_t) usize {
866866 return syscall3(.mkdirat, @as(usize, @bitCast(@as(isize, dirfd))), @intFromPtr(path), mode);
867867}
868868
lib/std/posix.zig+7-7
......@@ -2875,7 +2875,7 @@ pub fn renameatW(
28752875/// On Windows, `sub_dir_path` should be encoded as [WTF-8](https://simonsapin.github.io/wtf-8/).
28762876/// On WASI, `sub_dir_path` should be encoded as valid UTF-8.
28772877/// On other platforms, `sub_dir_path` is an opaque sequence of bytes with no particular encoding.
2878pub fn mkdirat(dir_fd: fd_t, sub_dir_path: []const u8, mode: u32) MakeDirError!void {
2878pub fn mkdirat(dir_fd: fd_t, sub_dir_path: []const u8, mode: mode_t) MakeDirError!void {
28792879 if (native_os == .windows) {
28802880 const sub_dir_path_w = try windows.sliceToPrefixedFileW(dir_fd, sub_dir_path);
28812881 return mkdiratW(dir_fd, sub_dir_path_w.span(), mode);
......@@ -2887,7 +2887,7 @@ pub fn mkdirat(dir_fd: fd_t, sub_dir_path: []const u8, mode: u32) MakeDirError!v
28872887 }
28882888}
28892889
2890pub fn mkdiratWasi(dir_fd: fd_t, sub_dir_path: []const u8, mode: u32) MakeDirError!void {
2890pub fn mkdiratWasi(dir_fd: fd_t, sub_dir_path: []const u8, mode: mode_t) MakeDirError!void {
28912891 _ = mode;
28922892 switch (wasi.path_create_directory(dir_fd, sub_dir_path.ptr, sub_dir_path.len)) {
28932893 .SUCCESS => return,
......@@ -2912,7 +2912,7 @@ pub fn mkdiratWasi(dir_fd: fd_t, sub_dir_path: []const u8, mode: u32) MakeDirErr
29122912}
29132913
29142914/// Same as `mkdirat` except the parameters are null-terminated.
2915pub fn mkdiratZ(dir_fd: fd_t, sub_dir_path: [*:0]const u8, mode: u32) MakeDirError!void {
2915pub fn mkdiratZ(dir_fd: fd_t, sub_dir_path: [*:0]const u8, mode: mode_t) MakeDirError!void {
29162916 if (native_os == .windows) {
29172917 const sub_dir_path_w = try windows.cStrToPrefixedFileW(dir_fd, sub_dir_path);
29182918 return mkdiratW(dir_fd, sub_dir_path_w.span(), mode);
......@@ -2946,7 +2946,7 @@ pub fn mkdiratZ(dir_fd: fd_t, sub_dir_path: [*:0]const u8, mode: u32) MakeDirErr
29462946}
29472947
29482948/// Windows-only. Same as `mkdirat` except the parameter WTF16 LE encoded.
2949pub fn mkdiratW(dir_fd: fd_t, sub_path_w: []const u16, mode: u32) MakeDirError!void {
2949pub fn mkdiratW(dir_fd: fd_t, sub_path_w: []const u16, mode: mode_t) MakeDirError!void {
29502950 _ = mode;
29512951 const sub_dir_handle = windows.OpenFile(sub_path_w, .{
29522952 .dir = dir_fd,
......@@ -2994,7 +2994,7 @@ pub const MakeDirError = error{
29942994/// On Windows, `dir_path` should be encoded as [WTF-8](https://simonsapin.github.io/wtf-8/).
29952995/// On WASI, `dir_path` should be encoded as valid UTF-8.
29962996/// On other platforms, `dir_path` is an opaque sequence of bytes with no particular encoding.
2997pub fn mkdir(dir_path: []const u8, mode: u32) MakeDirError!void {
2997pub fn mkdir(dir_path: []const u8, mode: mode_t) MakeDirError!void {
29982998 if (native_os == .wasi and !builtin.link_libc) {
29992999 return mkdirat(wasi.AT.FDCWD, dir_path, mode);
30003000 } else if (native_os == .windows) {
......@@ -3010,7 +3010,7 @@ pub fn mkdir(dir_path: []const u8, mode: u32) MakeDirError!void {
30103010/// On Windows, `dir_path` should be encoded as [WTF-8](https://simonsapin.github.io/wtf-8/).
30113011/// On WASI, `dir_path` should be encoded as valid UTF-8.
30123012/// On other platforms, `dir_path` is an opaque sequence of bytes with no particular encoding.
3013pub fn mkdirZ(dir_path: [*:0]const u8, mode: u32) MakeDirError!void {
3013pub fn mkdirZ(dir_path: [*:0]const u8, mode: mode_t) MakeDirError!void {
30143014 if (native_os == .windows) {
30153015 const dir_path_w = try windows.cStrToPrefixedFileW(null, dir_path);
30163016 return mkdirW(dir_path_w.span(), mode);
......@@ -3041,7 +3041,7 @@ pub fn mkdirZ(dir_path: [*:0]const u8, mode: u32) MakeDirError!void {
30413041}
30423042
30433043/// Windows-only. Same as `mkdir` but the parameters is WTF16LE encoded.
3044pub fn mkdirW(dir_path_w: []const u16, mode: u32) MakeDirError!void {
3044pub fn mkdirW(dir_path_w: []const u16, mode: mode_t) MakeDirError!void {
30453045 _ = mode;
30463046 const sub_dir_handle = windows.OpenFile(dir_path_w, .{
30473047 .dir = fs.cwd().fd,