| ... | ... | @@ -281,6 +281,7 @@ pub const libc = struct { |
| 281 | 281 | pub extern fn getcwd(buf: [*]u8, size: usize) ?[*:0]u8; |
| 282 | 282 | pub extern fn fchmod(fildes: c_int, mode: mode_t) c_int; |
| 283 | 283 | pub extern fn faccessat(fd: c_int, path: [*:0]const u8, amode: c_int, flag: c_int) c_int; |
| 284 | pub extern fn readlinkat(fd: c_int, noalias path: [*:0]const u8, noalias buf: [*]u8, len: usize) isize; |
| 284 | 285 | }; |
| 285 | 286 | |
| 286 | 287 | pub const natural_t = c_uint; |
| ... | ... | @@ -575,3 +576,10 @@ pub fn faccessat(fd: c_int, path: [*:0]const u8, amode: c_int, flag: c_int) !voi |
| 575 | 576 | if (rc == -1) return errno.fromInt(errno.fromLibC()); |
| 576 | 577 | std.debug.assert(rc == 0); |
| 577 | 578 | } |
| 579 | pub fn readlinkat(dirfd: c_int, noalias path: [*:0]const u8, noalias buf: []u8) ![:0]u8 { |
| 580 | const rc = libc.readlinkat(dirfd, path, buf.ptr, buf.len); |
| 581 | if (rc == -1) return errno.fromInt(errno.fromLibC()); |
| 582 | std.debug.assert(rc >= 0); |
| 583 | buf[@intCast(rc)] = 0; |
| 584 | return buf[0..@intCast(rc) :0]; |
| 585 | } |