| ... | ... | @@ -4217,7 +4217,7 @@ fn dirCreateFilePosix( |
| 4217 | 4217 | userdata: ?*anyopaque, |
| 4218 | 4218 | dir: Dir, |
| 4219 | 4219 | sub_path: []const u8, |
| 4220 | | flags: Dir.CreateFileOptions, |
| 4220 | options: Dir.CreateFileOptions, |
| 4221 | 4221 | ) File.OpenError!File { |
| 4222 | 4222 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 4223 | 4223 | _ = t; |
| ... | ... | @@ -4225,34 +4225,35 @@ fn dirCreateFilePosix( |
| 4225 | 4225 | var path_buffer: [posix.PATH_MAX]u8 = undefined; |
| 4226 | 4226 | const sub_path_posix = try pathToPosix(sub_path, &path_buffer); |
| 4227 | 4227 | |
| 4228 | | var os_flags: posix.O = .{ |
| 4229 | | .ACCMODE = if (flags.read) .RDWR else .WRONLY, |
| 4228 | var flags: posix.O = .{ |
| 4229 | .ACCMODE = if (options.read) .RDWR else .WRONLY, |
| 4230 | 4230 | .CREAT = true, |
| 4231 | | .TRUNC = flags.truncate, |
| 4232 | | .EXCL = flags.exclusive, |
| 4231 | .TRUNC = options.truncate, |
| 4232 | .EXCL = options.exclusive, |
| 4233 | 4233 | }; |
| 4234 | | if (@hasField(posix.O, "LARGEFILE")) os_flags.LARGEFILE = true; |
| 4235 | | if (@hasField(posix.O, "CLOEXEC")) os_flags.CLOEXEC = true; |
| 4234 | if (@hasField(posix.O, "LARGEFILE")) flags.LARGEFILE = true; |
| 4235 | if (@hasField(posix.O, "CLOEXEC")) flags.CLOEXEC = true; |
| 4236 | if (@hasField(posix.O, "RESOLVE_BENEATH")) flags.RESOLVE_BENEATH = options.resolve_beneath; |
| 4236 | 4237 | |
| 4237 | 4238 | // Use the O locking flags if the os supports them to acquire the lock |
| 4238 | 4239 | // atomically. Note that the NONBLOCK flag is removed after the openat() |
| 4239 | 4240 | // call is successful. |
| 4240 | | if (have_flock_open_flags) switch (flags.lock) { |
| 4241 | if (have_flock_open_flags) switch (options.lock) { |
| 4241 | 4242 | .none => {}, |
| 4242 | 4243 | .shared => { |
| 4243 | | os_flags.SHLOCK = true; |
| 4244 | | os_flags.NONBLOCK = flags.lock_nonblocking; |
| 4244 | flags.SHLOCK = true; |
| 4245 | flags.NONBLOCK = options.lock_nonblocking; |
| 4245 | 4246 | }, |
| 4246 | 4247 | .exclusive => { |
| 4247 | | os_flags.EXLOCK = true; |
| 4248 | | os_flags.NONBLOCK = flags.lock_nonblocking; |
| 4248 | flags.EXLOCK = true; |
| 4249 | flags.NONBLOCK = options.lock_nonblocking; |
| 4249 | 4250 | }, |
| 4250 | 4251 | }; |
| 4251 | 4252 | |
| 4252 | 4253 | const fd: posix.fd_t = fd: { |
| 4253 | 4254 | const syscall: Syscall = try .start(); |
| 4254 | 4255 | while (true) { |
| 4255 | | const rc = openat_sym(dir.handle, sub_path_posix, os_flags, flags.permissions.toMode()); |
| 4256 | const rc = openat_sym(dir.handle, sub_path_posix, flags, options.permissions.toMode()); |
| 4256 | 4257 | switch (posix.errno(rc)) { |
| 4257 | 4258 | .SUCCESS => { |
| 4258 | 4259 | syscall.finish(); |
| ... | ... | @@ -4298,9 +4299,9 @@ fn dirCreateFilePosix( |
| 4298 | 4299 | }; |
| 4299 | 4300 | errdefer closeFd(fd); |
| 4300 | 4301 | |
| 4301 | | if (have_flock and !have_flock_open_flags and flags.lock != .none) { |
| 4302 | | const lock_nonblocking: i32 = if (flags.lock_nonblocking) posix.LOCK.NB else 0; |
| 4303 | | const lock_flags = switch (flags.lock) { |
| 4302 | if (have_flock and !have_flock_open_flags and options.lock != .none) { |
| 4303 | const lock_nonblocking: i32 = if (options.lock_nonblocking) posix.LOCK.NB else 0; |
| 4304 | const lock_flags = switch (options.lock) { |
| 4304 | 4305 | .none => unreachable, |
| 4305 | 4306 | .shared => posix.LOCK.SH | lock_nonblocking, |
| 4306 | 4307 | .exclusive => posix.LOCK.EX | lock_nonblocking, |
| ... | ... | @@ -4332,7 +4333,7 @@ fn dirCreateFilePosix( |
| 4332 | 4333 | } |
| 4333 | 4334 | } |
| 4334 | 4335 | |
| 4335 | | if (have_flock_open_flags and flags.lock_nonblocking) { |
| 4336 | if (have_flock_open_flags and options.lock_nonblocking) { |
| 4336 | 4337 | var fl_flags: usize = fl: { |
| 4337 | 4338 | const syscall: Syscall = try .start(); |
| 4338 | 4339 | while (true) { |
| ... | ... | @@ -4785,45 +4786,46 @@ fn dirOpenFilePosix( |
| 4785 | 4786 | userdata: ?*anyopaque, |
| 4786 | 4787 | dir: Dir, |
| 4787 | 4788 | sub_path: []const u8, |
| 4788 | | flags: Dir.OpenFileOptions, |
| 4789 | options: Dir.OpenFileOptions, |
| 4789 | 4790 | ) File.OpenError!File { |
| 4790 | 4791 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 4791 | 4792 | |
| 4792 | 4793 | var path_buffer: [posix.PATH_MAX]u8 = undefined; |
| 4793 | 4794 | const sub_path_posix = try pathToPosix(sub_path, &path_buffer); |
| 4794 | 4795 | |
| 4795 | | var os_flags: posix.O = switch (native_os) { |
| 4796 | var flags: posix.O = switch (native_os) { |
| 4796 | 4797 | .wasi => .{ |
| 4797 | | .read = flags.mode != .write_only, |
| 4798 | | .write = flags.mode != .read_only, |
| 4799 | | .NOFOLLOW = !flags.follow_symlinks, |
| 4798 | .read = options.mode != .write_only, |
| 4799 | .write = options.mode != .read_only, |
| 4800 | .NOFOLLOW = !options.follow_symlinks, |
| 4800 | 4801 | }, |
| 4801 | 4802 | else => .{ |
| 4802 | | .ACCMODE = switch (flags.mode) { |
| 4803 | .ACCMODE = switch (options.mode) { |
| 4803 | 4804 | .read_only => .RDONLY, |
| 4804 | 4805 | .write_only => .WRONLY, |
| 4805 | 4806 | .read_write => .RDWR, |
| 4806 | 4807 | }, |
| 4807 | | .NOFOLLOW = !flags.follow_symlinks, |
| 4808 | .NOFOLLOW = !options.follow_symlinks, |
| 4808 | 4809 | }, |
| 4809 | 4810 | }; |
| 4810 | | if (@hasField(posix.O, "CLOEXEC")) os_flags.CLOEXEC = true; |
| 4811 | | if (@hasField(posix.O, "LARGEFILE")) os_flags.LARGEFILE = true; |
| 4812 | | if (@hasField(posix.O, "NOCTTY")) os_flags.NOCTTY = !flags.allow_ctty; |
| 4813 | | if (@hasField(posix.O, "PATH") and flags.path_only) os_flags.PATH = true; |
| 4811 | if (@hasField(posix.O, "CLOEXEC")) flags.CLOEXEC = true; |
| 4812 | if (@hasField(posix.O, "LARGEFILE")) flags.LARGEFILE = true; |
| 4813 | if (@hasField(posix.O, "NOCTTY")) flags.NOCTTY = !options.allow_ctty; |
| 4814 | if (@hasField(posix.O, "PATH")) flags.PATH = options.path_only; |
| 4815 | if (@hasField(posix.O, "RESOLVE_BENEATH")) flags.RESOLVE_BENEATH = options.resolve_beneath; |
| 4814 | 4816 | |
| 4815 | | // Use the O locking flags if the os supports them to acquire the lock |
| 4817 | // Use the O locking options if the os supports them to acquire the lock |
| 4816 | 4818 | // atomically. Note that the NONBLOCK flag is removed after the openat() |
| 4817 | 4819 | // call is successful. |
| 4818 | | if (have_flock_open_flags) switch (flags.lock) { |
| 4820 | if (have_flock_open_flags) switch (options.lock) { |
| 4819 | 4821 | .none => {}, |
| 4820 | 4822 | .shared => { |
| 4821 | | os_flags.SHLOCK = true; |
| 4822 | | os_flags.NONBLOCK = flags.lock_nonblocking; |
| 4823 | flags.SHLOCK = true; |
| 4824 | flags.NONBLOCK = options.lock_nonblocking; |
| 4823 | 4825 | }, |
| 4824 | 4826 | .exclusive => { |
| 4825 | | os_flags.EXLOCK = true; |
| 4826 | | os_flags.NONBLOCK = flags.lock_nonblocking; |
| 4827 | flags.EXLOCK = true; |
| 4828 | flags.NONBLOCK = options.lock_nonblocking; |
| 4827 | 4829 | }, |
| 4828 | 4830 | }; |
| 4829 | 4831 | |
| ... | ... | @@ -4832,7 +4834,7 @@ fn dirOpenFilePosix( |
| 4832 | 4834 | const fd: posix.fd_t = fd: { |
| 4833 | 4835 | const syscall: Syscall = try .start(); |
| 4834 | 4836 | while (true) { |
| 4835 | | const rc = openat_sym(dir.handle, sub_path_posix, os_flags, mode); |
| 4837 | const rc = openat_sym(dir.handle, sub_path_posix, flags, mode); |
| 4836 | 4838 | switch (posix.errno(rc)) { |
| 4837 | 4839 | .SUCCESS => { |
| 4838 | 4840 | syscall.finish(); |
| ... | ... | @@ -4878,7 +4880,7 @@ fn dirOpenFilePosix( |
| 4878 | 4880 | }; |
| 4879 | 4881 | errdefer closeFd(fd); |
| 4880 | 4882 | |
| 4881 | | if (!flags.allow_directory) { |
| 4883 | if (!options.allow_directory) { |
| 4882 | 4884 | const is_dir = is_dir: { |
| 4883 | 4885 | const stat = fileStat(t, .{ |
| 4884 | 4886 | .handle = fd, |
| ... | ... | @@ -4893,9 +4895,9 @@ fn dirOpenFilePosix( |
| 4893 | 4895 | if (is_dir) return error.IsDir; |
| 4894 | 4896 | } |
| 4895 | 4897 | |
| 4896 | | if (have_flock and !have_flock_open_flags and flags.lock != .none) { |
| 4897 | | const lock_nonblocking: i32 = if (flags.lock_nonblocking) posix.LOCK.NB else 0; |
| 4898 | | const lock_flags = switch (flags.lock) { |
| 4898 | if (have_flock and !have_flock_open_flags and options.lock != .none) { |
| 4899 | const lock_nonblocking: i32 = if (options.lock_nonblocking) posix.LOCK.NB else 0; |
| 4900 | const lock_flags = switch (options.lock) { |
| 4899 | 4901 | .none => unreachable, |
| 4900 | 4902 | .shared => posix.LOCK.SH | lock_nonblocking, |
| 4901 | 4903 | .exclusive => posix.LOCK.EX | lock_nonblocking, |
| ... | ... | @@ -4926,7 +4928,7 @@ fn dirOpenFilePosix( |
| 4926 | 4928 | } |
| 4927 | 4929 | } |
| 4928 | 4930 | |
| 4929 | | if (have_flock_open_flags and flags.lock_nonblocking) { |
| 4931 | if (have_flock_open_flags and options.lock_nonblocking) { |
| 4930 | 4932 | var fl_flags: usize = fl: { |
| 4931 | 4933 | const syscall: Syscall = try .start(); |
| 4932 | 4934 | while (true) { |