diff options
Diffstat (limited to 'vendor/modernc.org/libc/libc_linux.go')
-rw-r--r-- | vendor/modernc.org/libc/libc_linux.go | 168 |
1 files changed, 168 insertions, 0 deletions
diff --git a/vendor/modernc.org/libc/libc_linux.go b/vendor/modernc.org/libc/libc_linux.go index d594ab4a..0989c6d5 100644 --- a/vendor/modernc.org/libc/libc_linux.go +++ b/vendor/modernc.org/libc/libc_linux.go @@ -200,6 +200,18 @@ func Xopen64(t *TLS, pathname uintptr, flags int32, args uintptr) int32 { return int32(n) } +// int openat(int dirfd, const char *pathname, int flags, mode_t mode); +func Xopenat(t *TLS, dirfd int32, pathname uintptr, flags int32, mode types.Mode_t) int32 { + // From golang.org/x/sys/unix/zsyscall_linux.go + fd, _, err := unix.Syscall6(unix.SYS_OPENAT, uintptr(dirfd), pathname, uintptr(flags), uintptr(mode), 0, 0) + if err != 0 { + t.setErrno(err) + return -1 + } + + return int32(fd) +} + // off_t lseek(int fd, off_t offset, int whence); func Xlseek(t *TLS, fd int32, offset types.Off_t, whence int32) types.Off_t { return types.Off_t(Xlseek64(t, fd, offset, whence)) @@ -347,6 +359,29 @@ func Xfchmod(t *TLS, fd int32, mode types.Mode_t) int32 { return 0 } +// int fchmodat(int dirfd, const char *pathname, mode_t mode, int flags); +func Xfchmodat(t *TLS, dirfd int32, pathname uintptr, mode types.Mode_t, flags int32) int32 { + // From golang.org/x/sys/unix/syscall_linux.go + // Linux fchmodat doesn't support the flags parameter. Mimick glibc's behavior + // and check the flags. Otherwise the mode would be applied to the symlink + // destination which is not what the user expects. + if flags&^unix.AT_SYMLINK_NOFOLLOW != 0 { + t.setErrno(unix.EINVAL) + return -1 + } else if flags&unix.AT_SYMLINK_NOFOLLOW != 0 { + t.setErrno(unix.EOPNOTSUPP) + return -1 + } + + // From golang.org/x/sys/unix/zsyscall_linux.go + if _, _, err := unix.Syscall(unix.SYS_FCHMODAT, uintptr(dirfd), pathname, uintptr(mode)); err != 0 { + t.setErrno(err) + return -1 + } + + return 0 +} + // int fchown(int fd, uid_t owner, gid_t group); func Xfchown(t *TLS, fd int32, owner types.Uid_t, group types.Gid_t) int32 { if _, _, err := unix.Syscall(unix.SYS_FCHOWN, uintptr(fd), uintptr(owner), uintptr(group)); err != 0 { @@ -1421,3 +1456,136 @@ func Xuuid_parse(t *TLS, in uintptr, uu uintptr) int32 { copy((*RawMem)(unsafe.Pointer(uu))[:unsafe.Sizeof(uuid.Uuid_t{})], r[:]) return 0 } + +// int mkdirat(int dirfd, const char *pathname, mode_t mode); +func Xmkdirat(t *TLS, dirfd int32, pathname uintptr, mode types.Mode_t) int32 { + // From golang.org/x/sys/unix/zsyscall_linux.go + if _, _, err := unix.Syscall(unix.SYS_MKDIRAT, uintptr(dirfd), pathname, uintptr(mode)); err != 0 { + t.setErrno(err) + return -1 + } + + return 0 +} + +// int symlinkat(const char *target, int newdirfd, const char *linkpath); +func Xsymlinkat(t *TLS, target uintptr, newdirfd int32, linkpath uintptr) int32 { + // From golang.org/x/sys/unix/zsyscall_linux.go + if _, _, err := unix.Syscall(unix.SYS_SYMLINKAT, target, uintptr(newdirfd), linkpath); err != 0 { + t.setErrno(err) + return -1 + } + + return 0 +} + +// int utimensat(int dirfd, const char *pathname, const struct timespec times[2], int flags); +func Xutimensat(t *TLS, dirfd int32, pathname, times uintptr, flags int32) int32 { + // From golang.org/x/sys/unix/zsyscall_linux.go + if _, _, err := unix.Syscall6(unix.SYS_UTIMENSAT, uintptr(dirfd), pathname, times, uintptr(flags), 0, 0); err != 0 { + t.setErrno(err) + return -1 + } + + return 0 +} + +// int unlinkat(int dirfd, const char *pathname, int flags); +func Xunlinkat(t *TLS, dirfd int32, pathname uintptr, flags int32) int32 { + // From golang.org/x/sys/unix/zsyscall_linux.go + if _, _, err := unix.Syscall(unix.SYS_UNLINKAT, uintptr(dirfd), pathname, uintptr(flags)); err != 0 { + t.setErrno(err) + return -1 + } + + return 0 +} + +// int faccessat(int dirfd, const char *pathname, int mode, int flags); +func Xfaccessat(t *TLS, dirfd int32, pathname uintptr, mode, flags int32) int32 { + // From golang.org/x/sys/unix/zsyscall_linux.go + if _, _, err := unix.Syscall(unix.SYS_FACCESSAT, uintptr(dirfd), pathname, uintptr(mode)); err != 0 { + t.setErrno(err) + return -1 + } + + return 0 +} + +// int renameat2(int olddirfd, const char *oldpath, int newdirfd, const char *newpath, unsigned int flags); +func Xrenameat2(t *TLS, olddirfd int32, oldpath uintptr, newdirfd int32, newpath uintptr, flags int32) int32 { + // From golang.org/x/sys/unix/zsyscall_linux.go + if _, _, err := unix.Syscall6(unix.SYS_RENAMEAT2, uintptr(olddirfd), oldpath, uintptr(newdirfd), newpath, uintptr(flags), 0); err != 0 { + t.setErrno(err) + return -1 + } + + return 0 +} + +// int mknodat(int dirfd, const char *pathname, mode_t mode, dev_t dev); +func Xmknodat(t *TLS, dirfd int32, pathname uintptr, mode types.Mode_t, dev types.Dev_t) int32 { + // From golang.org/x/sys/unix/zsyscall_linux.go + if _, _, err := unix.Syscall6(unix.SYS_MKNODAT, uintptr(dirfd), pathname, uintptr(mode), uintptr(dev), 0, 0); err != 0 { + t.setErrno(err) + return -1 + } + + return 0 +} + +// int fchownat(int dirfd, const char *pathname, uid_t owner, gid_t group, int flags); +func Xfchownat(t *TLS, dirfd int32, pathname uintptr, uid types.Uid_t, gid types.Gid_t, flags int32) int32 { + // From golang.org/x/sys/unix/zsyscall_linux.go + if _, _, err := unix.Syscall6(unix.SYS_FCHOWNAT, uintptr(dirfd), pathname, uintptr(uid), uintptr(gid), uintptr(flags), 0); err != 0 { + t.setErrno(err) + return -1 + } + + return 0 +} + +// int linkat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath, int flags); +func Xlinkat(t *TLS, olddirfd int32, oldpath uintptr, newdirfd int32, newpath uintptr, flags int32) int32 { + // From golang.org/x/sys/unix/zsyscall_linux.go + if _, _, err := unix.Syscall6(unix.SYS_LINKAT, uintptr(olddirfd), oldpath, uintptr(newdirfd), newpath, uintptr(flags), 0); err != 0 { + t.setErrno(err) + return -1 + } + + return 0 +} + +// int pipe2(int pipefd[2], int flags); +func Xpipe2(t *TLS, pipefd uintptr, flags int32) int32 { + // From golang.org/x/sys/unix/zsyscall_linux.go + if _, _, err := unix.Syscall(unix.SYS_PIPE2, pipefd, uintptr(flags), 0); err != 0 { + t.setErrno(t) + return -1 + } + + return 0 +} + +// int dup3(int oldfd, int newfd, int flags); +func Xdup3(t *TLS, oldfd int32, newfd int32, flags int32) int32 { + // From golang.org/x/sys/unix/zsyscall_linux.go + if _, _, err := unix.Syscall(unix.SYS_DUP3, uintptr(oldfd), uintptr(newfd), uintptr(flags)); err != 0 { + t.setErrno(err) + return -1 + } + + return 0 +} + +// ssize_t readlinkat(int dirfd, const char *pathname, char *buf, size_t bufsiz); +func Xreadlinkat(t *TLS, dirfd int32, pathname, buf uintptr, bufsiz types.Size_t) types.Ssize_t { + // From golang.org/x/sys/unix/zsyscall_linux.go + n, _, err := unix.Syscall6(unix.SYS_READLINKAT, uintptr(dirfd), pathname, buf, uintptr(bufsiz), 0, 0) + if err != 0 { + t.setErrno(err) + return -1 + } + + return types.Ssize_t(n) +} |