| ... | ... | @@ -2371,6 +2371,29 @@ pub fn fstat(fd: fd_t) FStatError!Stat { |
| 2371 | 2371 | } |
| 2372 | 2372 | } |
| 2373 | 2373 | |
| 2374 | const FStatAtError = FStatError || error{NameTooLong}; |
| 2375 | |
| 2376 | pub fn fstatat(dirfd: fd_t, pathname: []const u8, flags: u32) FStatAtError![]Stat { |
| 2377 | const pathname_c = try toPosixPath(pathname); |
| 2378 | return fstatatC(dirfd, &pathname_c, flags); |
| 2379 | } |
| 2380 | |
| 2381 | pub fn fstatatC(dirfd: fd_t, pathname: [*:0]const u8, flags: u32) FStatAtError!Stat { |
| 2382 | var stat: Stat = undefined; |
| 2383 | switch (errno(system.fstatat(dirfd, pathname, &stat, flags))) { |
| 2384 | 0 => return stat, |
| 2385 | EINVAL => unreachable, |
| 2386 | EBADF => unreachable, // Always a race condition. |
| 2387 | ENOMEM => return error.SystemResources, |
| 2388 | EACCES => return error.AccessDenied, |
| 2389 | EFAULT => unreachable, |
| 2390 | ENAMETOOLONG => return error.NameTooLong, |
| 2391 | ENOENT => return error.FileNotFound, |
| 2392 | ENOTDIR => return error.FileNotFound, |
| 2393 | else => |err| return unexpectedErrno(err), |
| 2394 | } |
| 2395 | } |
| 2396 | |
| 2374 | 2397 | pub const KQueueError = error{ |
| 2375 | 2398 | /// The per-process limit on the number of open file descriptors has been reached. |
| 2376 | 2399 | ProcessFdQuotaExceeded, |