| ... | @@ -809,6 +809,28 @@ pub const Loop = struct { | ... | @@ -809,6 +809,28 @@ pub const Loop = struct { |
| 809 | return req_node.data.msg.readv.result; | 809 | return req_node.data.msg.readv.result; |
| 810 | } | 810 | } |
| 811 | | 811 | |
| | 812 | /// Performs an async `os.pread` using a separate thread. |
| | 813 | /// `fd` must block and not return EAGAIN. |
| | 814 | pub fn pread(self: *Loop, fd: os.fd_t, buf: []u8, offset: u64) os.PReadError!usize { |
| | 815 | var req_node = Request.Node{ |
| | 816 | .data = .{ |
| | 817 | .msg = .{ |
| | 818 | .pread = .{ |
| | 819 | .fd = fd, |
| | 820 | .buf = buf, |
| | 821 | .offset = offset, |
| | 822 | .result = undefined, |
| | 823 | }, |
| | 824 | }, |
| | 825 | .finish = .{ .TickNode = .{ .data = @frame() } }, |
| | 826 | }, |
| | 827 | }; |
| | 828 | suspend { |
| | 829 | self.posixFsRequest(&req_node); |
| | 830 | } |
| | 831 | return req_node.data.msg.pread.result; |
| | 832 | } |
| | 833 | |
| 812 | /// Performs an async `os.preadv` using a separate thread. | 834 | /// Performs an async `os.preadv` using a separate thread. |
| 813 | /// `fd` must block and not return EAGAIN. | 835 | /// `fd` must block and not return EAGAIN. |
| 814 | pub fn preadv(self: *Loop, fd: os.fd_t, iov: []const os.iovec, offset: u64) os.ReadError!usize { | 836 | pub fn preadv(self: *Loop, fd: os.fd_t, iov: []const os.iovec, offset: u64) os.ReadError!usize { |
| ... | @@ -895,6 +917,35 @@ pub const Loop = struct { | ... | @@ -895,6 +917,35 @@ pub const Loop = struct { |
| 895 | return req_node.data.msg.pwritev.result; | 917 | return req_node.data.msg.pwritev.result; |
| 896 | } | 918 | } |
| 897 | | 919 | |
| | 920 | /// Performs an async `os.faccessatZ` using a separate thread. |
| | 921 | /// `fd` must block and not return EAGAIN. |
| | 922 | pub fn faccessatZ( |
| | 923 | self: *Loop, |
| | 924 | dirfd: os.fd_t, |
| | 925 | path_z: [*:0]const u8, |
| | 926 | mode: u32, |
| | 927 | flags: u32, |
| | 928 | ) os.AccessError!void { |
| | 929 | var req_node = Request.Node{ |
| | 930 | .data = .{ |
| | 931 | .msg = .{ |
| | 932 | .faccessat = .{ |
| | 933 | .dirfd = dirfd, |
| | 934 | .path = path_z, |
| | 935 | .mode = mode, |
| | 936 | .flags = flags, |
| | 937 | .result = undefined, |
| | 938 | }, |
| | 939 | }, |
| | 940 | .finish = .{ .TickNode = .{ .data = @frame() } }, |
| | 941 | }, |
| | 942 | }; |
| | 943 | suspend { |
| | 944 | self.posixFsRequest(&req_node); |
| | 945 | } |
| | 946 | return req_node.data.msg.faccessat.result; |
| | 947 | } |
| | 948 | |
| 898 | fn workerRun(self: *Loop) void { | 949 | fn workerRun(self: *Loop) void { |
| 899 | while (true) { | 950 | while (true) { |
| 900 | while (true) { | 951 | while (true) { |
| ... | @@ -1038,6 +1089,9 @@ pub const Loop = struct { | ... | @@ -1038,6 +1089,9 @@ pub const Loop = struct { |
| 1038 | .pwritev => |*msg| { | 1089 | .pwritev => |*msg| { |
| 1039 | msg.result = noasync os.pwritev(msg.fd, msg.iov, msg.offset); | 1090 | msg.result = noasync os.pwritev(msg.fd, msg.iov, msg.offset); |
| 1040 | }, | 1091 | }, |
| | 1092 | .pread => |*msg| { |
| | 1093 | msg.result = noasync os.pread(msg.fd, msg.buf, msg.offset); |
| | 1094 | }, |
| 1041 | .preadv => |*msg| { | 1095 | .preadv => |*msg| { |
| 1042 | msg.result = noasync os.preadv(msg.fd, msg.iov, msg.offset); | 1096 | msg.result = noasync os.preadv(msg.fd, msg.iov, msg.offset); |
| 1043 | }, | 1097 | }, |
| ... | @@ -1047,6 +1101,9 @@ pub const Loop = struct { | ... | @@ -1047,6 +1101,9 @@ pub const Loop = struct { |
| 1047 | .openat => |*msg| { | 1101 | .openat => |*msg| { |
| 1048 | msg.result = noasync os.openatC(msg.fd, msg.path, msg.flags, msg.mode); | 1102 | msg.result = noasync os.openatC(msg.fd, msg.path, msg.flags, msg.mode); |
| 1049 | }, | 1103 | }, |
| | 1104 | .faccessat => |*msg| { |
| | 1105 | msg.result = noasync os.faccessatZ(msg.dirfd, msg.path, msg.mode, msg.flags); |
| | 1106 | }, |
| 1050 | .close => |*msg| noasync os.close(msg.fd), | 1107 | .close => |*msg| noasync os.close(msg.fd), |
| 1051 | } | 1108 | } |
| 1052 | switch (node.data.finish) { | 1109 | switch (node.data.finish) { |
| ... | @@ -1120,10 +1177,12 @@ pub const Loop = struct { | ... | @@ -1120,10 +1177,12 @@ pub const Loop = struct { |
| 1120 | write: Write, | 1177 | write: Write, |
| 1121 | writev: WriteV, | 1178 | writev: WriteV, |
| 1122 | pwritev: PWriteV, | 1179 | pwritev: PWriteV, |
| | 1180 | pread: PRead, |
| 1123 | preadv: PReadV, | 1181 | preadv: PReadV, |
| 1124 | open: Open, | 1182 | open: Open, |
| 1125 | openat: OpenAt, | 1183 | openat: OpenAt, |
| 1126 | close: Close, | 1184 | close: Close, |
| | 1185 | faccessat: FAccessAt, |
| 1127 | | 1186 | |
| 1128 | /// special - means the fs thread should exit | 1187 | /// special - means the fs thread should exit |
| 1129 | end, | 1188 | end, |
| ... | @@ -1161,6 +1220,15 @@ pub const Loop = struct { | ... | @@ -1161,6 +1220,15 @@ pub const Loop = struct { |
| 1161 | pub const Error = os.PWriteError; | 1220 | pub const Error = os.PWriteError; |
| 1162 | }; | 1221 | }; |
| 1163 | | 1222 | |
| | 1223 | pub const PRead = struct { |
| | 1224 | fd: os.fd_t, |
| | 1225 | buf: []u8, |
| | 1226 | offset: usize, |
| | 1227 | result: Error!usize, |
| | 1228 | |
| | 1229 | pub const Error = os.PReadError; |
| | 1230 | }; |
| | 1231 | |
| 1164 | pub const PReadV = struct { | 1232 | pub const PReadV = struct { |
| 1165 | fd: os.fd_t, | 1233 | fd: os.fd_t, |
| 1166 | iov: []const os.iovec, | 1234 | iov: []const os.iovec, |
| ... | @@ -1192,6 +1260,16 @@ pub const Loop = struct { | ... | @@ -1192,6 +1260,16 @@ pub const Loop = struct { |
| 1192 | pub const Close = struct { | 1260 | pub const Close = struct { |
| 1193 | fd: os.fd_t, | 1261 | fd: os.fd_t, |
| 1194 | }; | 1262 | }; |
| | 1263 | |
| | 1264 | pub const FAccessAt = struct { |
| | 1265 | dirfd: os.fd_t, |
| | 1266 | path: [*:0]const u8, |
| | 1267 | mode: u32, |
| | 1268 | flags: u32, |
| | 1269 | result: Error!void, |
| | 1270 | |
| | 1271 | pub const Error = os.AccessError; |
| | 1272 | }; |
| 1195 | }; | 1273 | }; |
| 1196 | }; | 1274 | }; |
| 1197 | }; | 1275 | }; |