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) {...@@ -136,7 +136,7 @@ pub const dev_t = switch (native_os) {
136pub const mode_t = switch (native_os) {136pub const mode_t = switch (native_os) {
137 .linux => linux.mode_t,137 .linux => linux.mode_t,
138 .emscripten => emscripten.mode_t,138 .emscripten => emscripten.mode_t,
139 .openbsd, .haiku, .netbsd, .solaris, .illumos, .wasi => u32,139 .openbsd, .haiku, .netbsd, .solaris, .illumos, .wasi, .windows => u32,
140 .freebsd, .macos, .ios, .tvos, .watchos, .visionos, .dragonfly => u16,140 .freebsd, .macos, .ios, .tvos, .watchos, .visionos, .dragonfly => u16,
141 else => u0,141 else => u0,
142};142};
...@@ -9330,8 +9330,8 @@ pub const fork = switch (native_os) {...@@ -9330,8 +9330,8 @@ pub const fork = switch (native_os) {
9330pub extern "c" fn access(path: [*:0]const u8, mode: c_uint) c_int;9330pub extern "c" fn access(path: [*:0]const u8, mode: c_uint) c_int;
9331pub extern "c" fn faccessat(dirfd: fd_t, path: [*:0]const u8, mode: c_uint, flags: c_uint) c_int;9331pub extern "c" fn faccessat(dirfd: fd_t, path: [*:0]const u8, mode: c_uint, flags: c_uint) c_int;
9332pub extern "c" fn pipe(fds: *[2]fd_t) c_int;9332pub extern "c" fn pipe(fds: *[2]fd_t) c_int;
9333pub extern "c" fn mkdir(path: [*:0]const u8, mode: c_uint) 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: u32) c_int;9334pub extern "c" fn mkdirat(dirfd: fd_t, path: [*:0]const u8, mode: mode_t) c_int;
9335pub extern "c" fn symlink(existing: [*:0]const u8, new: [*:0]const u8) c_int;9335pub extern "c" fn symlink(existing: [*:0]const u8, new: [*:0]const u8) c_int;
9336pub extern "c" fn symlinkat(oldpath: [*:0]const u8, newdirfd: fd_t, newpath: [*:0]const u8) c_int;9336pub extern "c" fn symlinkat(oldpath: [*:0]const u8, newdirfd: fd_t, newpath: [*:0]const u8) c_int;
9337pub extern "c" fn rename(old: [*:0]const u8, new: [*:0]const u8) c_int;9337pub 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...@@ -854,7 +854,7 @@ pub fn readlinkat(dirfd: i32, noalias path: [*:0]const u8, noalias buf_ptr: [*]u
854 return syscall4(.readlinkat, @as(usize, @bitCast(@as(isize, dirfd))), @intFromPtr(path), @intFromPtr(buf_ptr), buf_len);854 return syscall4(.readlinkat, @as(usize, @bitCast(@as(isize, dirfd))), @intFromPtr(path), @intFromPtr(buf_ptr), buf_len);
855}855}
856856
857pub fn mkdir(path: [*:0]const u8, mode: u32) usize {857pub fn mkdir(path: [*:0]const u8, mode: mode_t) usize {
858 if (@hasField(SYS, "mkdir")) {858 if (@hasField(SYS, "mkdir")) {
859 return syscall2(.mkdir, @intFromPtr(path), mode);859 return syscall2(.mkdir, @intFromPtr(path), mode);
860 } else {860 } else {
...@@ -862,7 +862,7 @@ pub fn mkdir(path: [*:0]const u8, mode: u32) usize {...@@ -862,7 +862,7 @@ pub fn mkdir(path: [*:0]const u8, mode: u32) usize {
862 }862 }
863}863}
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 {
866 return syscall3(.mkdirat, @as(usize, @bitCast(@as(isize, dirfd))), @intFromPtr(path), mode);866 return syscall3(.mkdirat, @as(usize, @bitCast(@as(isize, dirfd))), @intFromPtr(path), mode);
867}867}
868868
lib/std/posix.zig+7-7
...@@ -2875,7 +2875,7 @@ pub fn renameatW(...@@ -2875,7 +2875,7 @@ pub fn renameatW(
2875/// On Windows, `sub_dir_path` should be encoded as [WTF-8](https://simonsapin.github.io/wtf-8/).2875/// On Windows, `sub_dir_path` should be encoded as [WTF-8](https://simonsapin.github.io/wtf-8/).
2876/// On WASI, `sub_dir_path` should be encoded as valid UTF-8.2876/// On WASI, `sub_dir_path` should be encoded as valid UTF-8.
2877/// On other platforms, `sub_dir_path` is an opaque sequence of bytes with no particular encoding.2877/// 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 {
2879 if (native_os == .windows) {2879 if (native_os == .windows) {
2880 const sub_dir_path_w = try windows.sliceToPrefixedFileW(dir_fd, sub_dir_path);2880 const sub_dir_path_w = try windows.sliceToPrefixedFileW(dir_fd, sub_dir_path);
2881 return mkdiratW(dir_fd, sub_dir_path_w.span(), mode);2881 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...@@ -2887,7 +2887,7 @@ pub fn mkdirat(dir_fd: fd_t, sub_dir_path: []const u8, mode: u32) MakeDirError!v
2887 }2887 }
2888}2888}
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 {
2891 _ = mode;2891 _ = mode;
2892 switch (wasi.path_create_directory(dir_fd, sub_dir_path.ptr, sub_dir_path.len)) {2892 switch (wasi.path_create_directory(dir_fd, sub_dir_path.ptr, sub_dir_path.len)) {
2893 .SUCCESS => return,2893 .SUCCESS => return,
...@@ -2912,7 +2912,7 @@ pub fn mkdiratWasi(dir_fd: fd_t, sub_dir_path: []const u8, mode: u32) MakeDirErr...@@ -2912,7 +2912,7 @@ pub fn mkdiratWasi(dir_fd: fd_t, sub_dir_path: []const u8, mode: u32) MakeDirErr
2912}2912}
29132913
2914/// Same as `mkdirat` except the parameters are null-terminated.2914/// 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 {
2916 if (native_os == .windows) {2916 if (native_os == .windows) {
2917 const sub_dir_path_w = try windows.cStrToPrefixedFileW(dir_fd, sub_dir_path);2917 const sub_dir_path_w = try windows.cStrToPrefixedFileW(dir_fd, sub_dir_path);
2918 return mkdiratW(dir_fd, sub_dir_path_w.span(), mode);2918 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...@@ -2946,7 +2946,7 @@ pub fn mkdiratZ(dir_fd: fd_t, sub_dir_path: [*:0]const u8, mode: u32) MakeDirErr
2946}2946}
29472947
2948/// Windows-only. Same as `mkdirat` except the parameter WTF16 LE encoded.2948/// 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 {
2950 _ = mode;2950 _ = mode;
2951 const sub_dir_handle = windows.OpenFile(sub_path_w, .{2951 const sub_dir_handle = windows.OpenFile(sub_path_w, .{
2952 .dir = dir_fd,2952 .dir = dir_fd,
...@@ -2994,7 +2994,7 @@ pub const MakeDirError = error{...@@ -2994,7 +2994,7 @@ pub const MakeDirError = error{
2994/// On Windows, `dir_path` should be encoded as [WTF-8](https://simonsapin.github.io/wtf-8/).2994/// On Windows, `dir_path` should be encoded as [WTF-8](https://simonsapin.github.io/wtf-8/).
2995/// On WASI, `dir_path` should be encoded as valid UTF-8.2995/// On WASI, `dir_path` should be encoded as valid UTF-8.
2996/// On other platforms, `dir_path` is an opaque sequence of bytes with no particular encoding.2996/// 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 {
2998 if (native_os == .wasi and !builtin.link_libc) {2998 if (native_os == .wasi and !builtin.link_libc) {
2999 return mkdirat(wasi.AT.FDCWD, dir_path, mode);2999 return mkdirat(wasi.AT.FDCWD, dir_path, mode);
3000 } else if (native_os == .windows) {3000 } else if (native_os == .windows) {
...@@ -3010,7 +3010,7 @@ pub fn mkdir(dir_path: []const u8, mode: u32) MakeDirError!void {...@@ -3010,7 +3010,7 @@ pub fn mkdir(dir_path: []const u8, mode: u32) MakeDirError!void {
3010/// On Windows, `dir_path` should be encoded as [WTF-8](https://simonsapin.github.io/wtf-8/).3010/// On Windows, `dir_path` should be encoded as [WTF-8](https://simonsapin.github.io/wtf-8/).
3011/// On WASI, `dir_path` should be encoded as valid UTF-8.3011/// On WASI, `dir_path` should be encoded as valid UTF-8.
3012/// On other platforms, `dir_path` is an opaque sequence of bytes with no particular encoding.3012/// 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 {
3014 if (native_os == .windows) {3014 if (native_os == .windows) {
3015 const dir_path_w = try windows.cStrToPrefixedFileW(null, dir_path);3015 const dir_path_w = try windows.cStrToPrefixedFileW(null, dir_path);
3016 return mkdirW(dir_path_w.span(), mode);3016 return mkdirW(dir_path_w.span(), mode);
...@@ -3041,7 +3041,7 @@ pub fn mkdirZ(dir_path: [*:0]const u8, mode: u32) MakeDirError!void {...@@ -3041,7 +3041,7 @@ pub fn mkdirZ(dir_path: [*:0]const u8, mode: u32) MakeDirError!void {
3041}3041}
30423042
3043/// Windows-only. Same as `mkdir` but the parameters is WTF16LE encoded.3043/// 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 {
3045 _ = mode;3045 _ = mode;
3046 const sub_dir_handle = windows.OpenFile(dir_path_w, .{3046 const sub_dir_handle = windows.OpenFile(dir_path_w, .{
3047 .dir = fs.cwd().fd,3047 .dir = fs.cwd().fd,