| ... | @@ -2650,6 +2650,7 @@ pub const libc = struct { | ... | @@ -2650,6 +2650,7 @@ pub const libc = struct { |
| 2650 | pub extern fn accept4(socket: c_int, noalias address: ?*struct_sockaddr, noalias address_len: *socklen_t, flags: c_int) c_int; | 2650 | pub extern fn accept4(socket: c_int, noalias address: ?*struct_sockaddr, noalias address_len: *socklen_t, flags: c_int) c_int; |
| 2651 | pub extern fn memfd_create(name: [*:0]const u8, flags: c_uint) c_int; | 2651 | pub extern fn memfd_create(name: [*:0]const u8, flags: c_uint) c_int; |
| 2652 | pub extern fn sendfile(out_fd: c_int, in_fd: c_int, offset: ?*const off_t, count: usize) isize; | 2652 | pub extern fn sendfile(out_fd: c_int, in_fd: c_int, offset: ?*const off_t, count: usize) isize; |
| | 2653 | pub extern fn getdents(dirfd: c_int, buf: [*]u8, nbytes: usize) c_int; |
| 2653 | }; | 2654 | }; |
| 2654 | | 2655 | |
| 2655 | pub const clock_t = c_long; | 2656 | pub const clock_t = c_long; |
| ... | @@ -2694,6 +2695,7 @@ pub const struct_sockaddr_in = extern struct { family: AF = .INET, port: in_port | ... | @@ -2694,6 +2695,7 @@ pub const struct_sockaddr_in = extern struct { family: AF = .INET, port: in_port |
| 2694 | pub const struct_sockaddr_in6 = extern struct { family: AF = .INET6, port: in_port_t, flowinfo: u32, addr: struct_in6_addr, scope_id: u32 }; | 2695 | pub const struct_sockaddr_in6 = extern struct { family: AF = .INET6, port: in_port_t, flowinfo: u32, addr: struct_in6_addr, scope_id: u32 }; |
| 2695 | pub const struct_sockaddr_un = extern struct { family: AF = .UNIX, path: [108]u8 }; | 2696 | pub const struct_sockaddr_un = extern struct { family: AF = .UNIX, path: [108]u8 }; |
| 2696 | pub const struct_addrinfo = extern struct { flags: c_int, family: c_int, socktype: c_int, protocol: c_int, addrlen: socklen_t, addr: ?*struct_sockaddr, canonname: ?[*:0]u8, next: ?*struct_addrinfo }; | 2697 | pub const struct_addrinfo = extern struct { flags: c_int, family: c_int, socktype: c_int, protocol: c_int, addrlen: socklen_t, addr: ?*struct_sockaddr, canonname: ?[*:0]u8, next: ?*struct_addrinfo }; |
| | 2698 | pub const struct_dirent = extern struct { ino: ino_t, off: off_t, reclen: c_ushort, type: DT, name: [NAME_MAX + 1]u8 }; |
| 2697 | | 2699 | |
| 2698 | pub const AT = struct { | 2700 | pub const AT = struct { |
| 2699 | pub const FDCWD = -100; | 2701 | pub const FDCWD = -100; |
| ... | @@ -3028,6 +3030,18 @@ pub const SO = struct { | ... | @@ -3028,6 +3030,18 @@ pub const SO = struct { |
| 3028 | pub const DOMAIN = 39; | 3030 | pub const DOMAIN = 39; |
| 3029 | }; | 3031 | }; |
| 3030 | | 3032 | |
| | 3033 | pub const DT = enum(u8) { |
| | 3034 | UNKNOWN = 0, |
| | 3035 | FIFO = 1, |
| | 3036 | CHR = 2, |
| | 3037 | DIR = 4, |
| | 3038 | BLK = 6, |
| | 3039 | REG = 8, |
| | 3040 | LNK = 10, |
| | 3041 | SOCK = 12, |
| | 3042 | WHT = 14, |
| | 3043 | }; |
| | 3044 | |
| 3031 | pub fn getpid() pid_t { | 3045 | pub fn getpid() pid_t { |
| 3032 | return libc.getpid(); | 3046 | return libc.getpid(); |
| 3033 | } | 3047 | } |
| ... | @@ -3188,3 +3202,9 @@ pub fn sendfile(out_fd: c_int, in_fd: c_int, offset: ?*const off_t, count: usize | ... | @@ -3188,3 +3202,9 @@ pub fn sendfile(out_fd: c_int, in_fd: c_int, offset: ?*const off_t, count: usize |
| 3188 | std.debug.assert(rc >= 0); | 3202 | std.debug.assert(rc >= 0); |
| 3189 | return @intCast(rc); | 3203 | return @intCast(rc); |
| 3190 | } | 3204 | } |
| | 3205 | pub fn getdents(dirfd: c_int, buf: []u8) errno.Error!usize { |
| | 3206 | const rc = libc.getdents(dirfd, buf.ptr, buf.len); |
| | 3207 | if (rc == -1) return errno.fromInt(errno.fromLibC()); |
| | 3208 | std.debug.assert(rc >= 0); |
| | 3209 | return @intCast(rc); |
| | 3210 | } |