| author | |
| committer | |
| log | 682815f6e9df8fa7ec25f0b327b4eab7c3d52f2a |
| tree | 444249d1aeab4e2aaceef47d7d8eb1210181eabd |
| parent | 773bf8013391d2b309cfcb50bf9e1c7db25cc3f2 |
| signature |
Use libc interface for:
- getdents
- kill
- openat
- setgid
- setuid2 files changed, 10 insertions(+), 5 deletions(-)
std/c/freebsd.zig+5| ... | @@ -14,9 +14,14 @@ pub extern "c" fn sysctl(name: [*]c_int, namelen: c_uint, oldp: ?*c_void, oldlen | ... | @@ -14,9 +14,14 @@ pub extern "c" fn sysctl(name: [*]c_int, namelen: c_uint, oldp: ?*c_void, oldlen |
| 14 | pub extern "c" fn sysctlbyname(name: [*]const u8, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int; | 14 | pub extern "c" fn sysctlbyname(name: [*]const u8, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int; |
| 15 | pub extern "c" fn sysctlnametomib(name: [*]const u8, mibp: ?*c_int, sizep: ?*usize) c_int; | 15 | pub extern "c" fn sysctlnametomib(name: [*]const u8, mibp: ?*c_int, sizep: ?*usize) c_int; |
| 16 | pub extern "c" fn getdirentries(fd: c_int, buf_ptr: [*]u8, nbytes: usize, basep: *i64) usize; | 16 | pub extern "c" fn getdirentries(fd: c_int, buf_ptr: [*]u8, nbytes: usize, basep: *i64) usize; |
| 17 | pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) usize; | ||
| 17 | pub extern "c" fn pipe2(arg0: *[2]c_int, arg1: u32) c_int; | 18 | pub extern "c" fn pipe2(arg0: *[2]c_int, arg1: u32) c_int; |
| 18 | pub extern "c" fn preadv(fd: c_int, iov: *const c_void, iovcnt: c_int, offset: usize) isize; | 19 | pub extern "c" fn preadv(fd: c_int, iov: *const c_void, iovcnt: c_int, offset: usize) isize; |
| 19 | pub extern "c" fn pwritev(fd: c_int, iov: *const c_void, iovcnt: c_int, offset: usize) isize; | 20 | pub extern "c" fn pwritev(fd: c_int, iov: *const c_void, iovcnt: c_int, offset: usize) isize; |
| 21 | pub extern "c" fn openat(fd: c_int, path: ?[*]const u8, flags: c_int) c_int; | ||
| 22 | pub extern "c" fn setgid(ruid: c_uint, euid: c_uint) c_int; | ||
| 23 | pub extern "c" fn setuid(uid: c_uint) c_int; | ||
| 24 | pub extern "c" fn kill(pid: c_int, sig: c_int) c_int; | ||
| 20 | 25 | ||
| 21 | /// Renamed from `kevent` to `Kevent` to avoid conflict with function name. | 26 | /// Renamed from `kevent` to `Kevent` to avoid conflict with function name. |
| 22 | pub const Kevent = extern struct { | 27 | pub const Kevent = extern struct { |
std/os/freebsd/index.zig+5-5| ... | @@ -573,7 +573,7 @@ pub fn getcwd(buf: [*]u8, size: usize) usize { | ... | @@ -573,7 +573,7 @@ pub fn getcwd(buf: [*]u8, size: usize) usize { |
| 573 | } | 573 | } |
| 574 | 574 | ||
| 575 | pub fn getdents(fd: i32, dirp: [*]u8, count: usize) usize { | 575 | pub fn getdents(fd: i32, dirp: [*]u8, count: usize) usize { |
| 576 | return arch.syscall3(SYS_getdents, @bitCast(usize, isize(fd)), @ptrToInt(dirp), count); | 576 | return errnoWrap(@bitCast(isize, c.getdents(fd, drip, count))); |
| 577 | } | 577 | } |
| 578 | 578 | ||
| 579 | pub fn getdirentries(fd: i32, buf_ptr: [*]u8, buf_len: usize, basep: *i64) usize { | 579 | pub fn getdirentries(fd: i32, buf_ptr: [*]u8, buf_len: usize, basep: *i64) usize { |
| ... | @@ -667,7 +667,7 @@ pub fn create(path: [*]const u8, perm: usize) usize { | ... | @@ -667,7 +667,7 @@ pub fn create(path: [*]const u8, perm: usize) usize { |
| 667 | } | 667 | } |
| 668 | 668 | ||
| 669 | pub fn openat(dirfd: i32, path: [*]const u8, flags: usize, mode: usize) usize { | 669 | pub fn openat(dirfd: i32, path: [*]const u8, flags: usize, mode: usize) usize { |
| 670 | return arch.syscall4(SYS_openat, @bitCast(usize, isize(dirfd)), @ptrToInt(path), flags, mode); | 670 | return errnoWrap(c.openat(@bitCast(usize, isize(dirfd)), @ptrToInt(path), flags, mode)); |
| 671 | } | 671 | } |
| 672 | 672 | ||
| 673 | pub fn close(fd: i32) usize { | 673 | pub fn close(fd: i32) usize { |
| ... | @@ -683,7 +683,7 @@ pub fn exit(code: i32) noreturn { | ... | @@ -683,7 +683,7 @@ pub fn exit(code: i32) noreturn { |
| 683 | } | 683 | } |
| 684 | 684 | ||
| 685 | pub fn kill(pid: i32, sig: i32) usize { | 685 | pub fn kill(pid: i32, sig: i32) usize { |
| 686 | return arch.syscall2(SYS_kill, @bitCast(usize, isize(pid)), @bitCast(usize, isize(sig))); | 686 | return errnoWrap(c.kill(pid, sig)); |
| 687 | } | 687 | } |
| 688 | 688 | ||
| 689 | pub fn unlink(path: [*]const u8) usize { | 689 | pub fn unlink(path: [*]const u8) usize { |
| ... | @@ -700,11 +700,11 @@ pub fn nanosleep(req: *const timespec, rem: ?*timespec) usize { | ... | @@ -700,11 +700,11 @@ pub fn nanosleep(req: *const timespec, rem: ?*timespec) usize { |
| 700 | } | 700 | } |
| 701 | 701 | ||
| 702 | pub fn setuid(uid: u32) usize { | 702 | pub fn setuid(uid: u32) usize { |
| 703 | return arch.syscall1(SYS_setuid, uid); | 703 | return errnoWrap(c.setuid(uid)); |
| 704 | } | 704 | } |
| 705 | 705 | ||
| 706 | pub fn setgid(gid: u32) usize { | 706 | pub fn setgid(gid: u32) usize { |
| 707 | return arch.syscall1(SYS_setgid, gid); | 707 | return errnoWrap(c.setgid(gid)); |
| 708 | } | 708 | } |
| 709 | 709 | ||
| 710 | pub fn setreuid(ruid: u32, euid: u32) usize { | 710 | pub fn setreuid(ruid: u32, euid: u32) usize { |