Module Name: src Committed By: chs Date: Mon Nov 18 01:35:22 UTC 2013
Modified Files: src/sys/compat/linux32/common: linux32_unistd.c Log Message: implement the *at() syscalls. bring the unimplemented syscall list up to date. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sys/compat/linux32/common/linux32_unistd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/compat/linux32/common/linux32_unistd.c diff -u src/sys/compat/linux32/common/linux32_unistd.c:1.35 src/sys/compat/linux32/common/linux32_unistd.c:1.36 --- src/sys/compat/linux32/common/linux32_unistd.c:1.35 Sun Apr 10 15:48:23 2011 +++ src/sys/compat/linux32/common/linux32_unistd.c Mon Nov 18 01:35:22 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_unistd.c,v 1.35 2011/04/10 15:48:23 christos Exp $ */ +/* $NetBSD: linux32_unistd.c,v 1.36 2013/11/18 01:35:22 chs Exp $ */ /*- * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. @@ -33,7 +33,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: linux32_unistd.c,v 1.35 2011/04/10 15:48:23 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux32_unistd.c,v 1.36 2013/11/18 01:35:22 chs Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -48,6 +48,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux32_unis #include <sys/swap.h> #include <sys/kauth.h> #include <sys/filedesc.h> +#include <sys/vfs_syscalls.h> #include <machine/types.h> @@ -69,6 +70,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux32_unis #include <compat/linux32/common/linux32_types.h> #include <compat/linux32/common/linux32_signal.h> #include <compat/linux32/common/linux32_machdep.h> +#include <compat/linux32/common/linux32_sched.h> #include <compat/linux32/common/linux32_sysctl.h> #include <compat/linux32/common/linux32_socketcall.h> #include <compat/linux32/linux32_syscallargs.h> @@ -306,6 +308,66 @@ linux32_sys_dup3(struct lwp *l, const st return 0; } + +int +linux32_sys_openat(struct lwp *l, const struct linux32_sys_openat_args *uap, register_t *retval) +{ + /* { + syscallarg(int) fd; + syscallarg(const netbsd32_charp) path; + syscallarg(int) flags; + syscallarg(int) mode; + } */ + struct linux_sys_openat_args ua; + + NETBSD32TO64_UAP(fd); + NETBSD32TOP_UAP(path, const char); + NETBSD32TO64_UAP(flags); + NETBSD32TO64_UAP(mode); + + return linux_sys_openat(l, &ua, retval); +} + +int +linux32_sys_mknodat(struct lwp *l, const struct linux32_sys_mknodat_args *uap, register_t *retval) +{ + /* { + syscallarg(int) fd; + syscallarg(const netbsd32_charp) path; + syscallarg(linux_umode_t) mode; + syscallarg(unsigned) dev; + } */ + struct linux_sys_mknodat_args ua; + + NETBSD32TO64_UAP(fd); + NETBSD32TOP_UAP(path, const char); + NETBSD32TO64_UAP(mode); + NETBSD32TO64_UAP(dev); + + return linux_sys_mknodat(l, &ua, retval); +} + +int +linux32_sys_linkat(struct lwp *l, const struct linux32_sys_linkat_args *uap, register_t *retval) +{ + /* { + syscallarg(int) fd1; + syscallarg(netbsd32_charp) name1; + syscallarg(int) fd2; + syscallarg(netbsd32_charp) name2; + syscallarg(int) flags; + } */ + int fd1 = SCARG(uap, fd1); + const char *name1 = SCARG_P32(uap, name1); + int fd2 = SCARG(uap, fd2); + const char *name2 = SCARG_P32(uap, name2); + int follow; + + follow = SCARG(uap, flags) & LINUX_AT_SYMLINK_FOLLOW; + + return do_sys_linkat(l, fd1, name1, fd2, name2, follow, retval); +} + int linux32_sys_unlink(struct lwp *l, const struct linux32_sys_unlink_args *uap, register_t *retval) { @@ -315,11 +377,97 @@ linux32_sys_unlink(struct lwp *l, const struct linux_sys_unlink_args ua; NETBSD32TOP_UAP(path, const char); - + return linux_sys_unlink(l, &ua, retval); } int +linux32_sys_unlinkat(struct lwp *l, const struct linux32_sys_unlinkat_args *uap, register_t *retval) +{ + /* { + syscallarg(int) fd; + syscallarg(const netbsd32_charp) path; + syscallarg(int) flag; + } */ + struct linux_sys_unlinkat_args ua; + + NETBSD32TO64_UAP(fd); + NETBSD32TOP_UAP(path, const char); + NETBSD32TO64_UAP(flag); + + return linux_sys_unlinkat(l, &ua, retval); +} + +int +linux32_sys_fchmodat(struct lwp *l, const struct linux32_sys_fchmodat_args *uap, register_t *retval) +{ + /* { + syscallarg(int) fd; + syscallarg(netbsd_charp) path; + syscallarg(linux_umode_t) mode; + } */ + + return do_sys_chmodat(l, SCARG(uap, fd), SCARG_P32(uap, path), + SCARG(uap, mode), AT_SYMLINK_FOLLOW); +} + +int +linux32_sys_fchownat(struct lwp *l, const struct linux32_sys_fchownat_args *uap, register_t *retval) +{ + /* { + syscallarg(int) fd; + syscallarg(netbsd_charp) path; + syscallarg(uid_t) owner; + syscallarg(gid_t) group; + syscallarg(int) flag; + } */ + int flag; + + flag = linux_to_bsd_atflags(SCARG(uap, flag)); + return do_sys_chownat(l, SCARG(uap, fd), SCARG_P32(uap, path), + SCARG(uap, owner), SCARG(uap, group), flag); +} + +int +linux32_sys_faccessat(struct lwp *l, const struct linux32_sys_faccessat_args *uap, register_t *retval) +{ + /* { + syscallarg(int) fd; + syscallarg(netbsd_charp) path; + syscallarg(int) amode; + } */ + + return do_sys_accessat(l, SCARG(uap, fd), SCARG_P32(uap, path), + SCARG(uap, amode), AT_SYMLINK_FOLLOW); +} + +int +linux32_sys_utimensat(struct lwp *l, const struct linux32_sys_utimensat_args *uap, register_t *retval) +{ + /* { + syscallarg(int) fd; + syscallarg(const netbsd32_charp) path; + syscallarg(const linux32_timespecp_t) times; + syscallarg(int) flags; + } */ + int error; + struct linux32_timespec lts[2]; + struct timespec *tsp = NULL, ts[2]; + + if (SCARG_P32(uap, times)) { + error = copyin(SCARG_P32(uap, times), <s, sizeof(lts)); + if (error != 0) + return error; + linux32_to_native_timespec(&ts[0], <s[0]); + linux32_to_native_timespec(&ts[1], <s[1]); + tsp = ts; + } + + return linux_do_sys_utimensat(l, SCARG(uap, fd), SCARG_P32(uap, path), + tsp, SCARG(uap, flag), retval); +} + +int linux32_sys_creat(struct lwp *l, const struct linux32_sys_creat_args *uap, register_t *retval) { /* {