@@ -16,6 +16,9 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#ifdef TARGET_NR_access
+SYSCALL_DEF(access, ARG_STR, ARG_ACCESSFLAG);
+#endif
#ifdef TARGET_NR_alarm
SYSCALL_DEF(alarm, ARG_DEC);
#endif
@@ -34,6 +37,7 @@ SYSCALL_DEF(creat, ARG_STR, ARG_MODEFLAG);
SYSCALL_DEF(exit, ARG_DEC);
SYSCALL_DEF(execve, ARG_STR, ARG_PTR, ARG_PTR);
SYSCALL_DEF(execveat, ARG_ATDIRFD, ARG_STR, ARG_PTR, ARG_PTR, ARG_ATFLAG);
+SYSCALL_DEF(faccessat, ARG_ATDIRFD, ARG_STR, ARG_ACCESSFLAG);
SYSCALL_DEF(fchmod, ARG_DEC, ARG_MODEFLAG);
SYSCALL_DEF(fchmodat, ARG_ATDIRFD, ARG_STR, ARG_MODEFLAG);
#ifdef TARGET_NR_futimesat
@@ -57,6 +57,7 @@ typedef enum {
/* These print as sets of flags. */
ARG_ATDIRFD,
+ ARG_ACCESSFLAG,
ARG_ATFLAG,
ARG_CLONEFLAG,
ARG_MMAPFLAG,
@@ -634,7 +634,7 @@ print_syscall_ret_adjtimex(const struct syscallname *name, abi_long ret)
gemu_log("\n");
}
-UNUSED static struct flags access_flags[] = {
+static struct flags const access_flags[] = {
FLAG_GENERIC(F_OK),
FLAG_GENERIC(R_OK),
FLAG_GENERIC(W_OK),
@@ -1114,19 +1114,6 @@ print_accept(const struct syscallname *name,
}
#endif
-#ifdef TARGET_NR_access
-static void
-print_access(const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
-{
- print_syscall_prologue(name);
- print_string(arg0, 0);
- print_flags(access_flags, arg1, 1);
- print_syscall_epilogue(name);
-}
-#endif
-
#ifdef TARGET_NR_chroot
static void
print_chroot(const struct syscallname *name,
@@ -1165,21 +1152,6 @@ print_execv(const struct syscallname *name,
}
#endif
-#ifdef TARGET_NR_faccessat
-static void
-print_faccessat(const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
-{
- print_syscall_prologue(name);
- print_at_dirfd(arg0, 0);
- print_string(arg1, 0);
- print_flags(access_flags, arg2, 0);
- print_flags(at_file_flags, arg3, 1);
- print_syscall_epilogue(name);
-}
-#endif
-
#ifdef TARGET_NR_fchownat
static void
print_fchownat(const struct syscallname *name,
@@ -2218,6 +2190,9 @@ static void print_syscall_def1(const SyscallDef *def, int64_t args[6])
case ARG_ATDIRFD:
len = add_atdirfd(b, rest, arg);
break;
+ case ARG_ACCESSFLAG:
+ len = add_flags(b, rest, access_flags, arg, false);
+ break;
case ARG_ATFLAG:
len = add_flags(b, rest, at_file_flags, arg, false);
break;
@@ -16,6 +16,26 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+static abi_long do_faccessat(int dirfd, abi_ulong target_path, int mode)
+{
+ char *p = lock_user_string(target_path);
+ abi_long ret;
+
+ if (!p) {
+ return -TARGET_EFAULT;
+ }
+ ret = get_errno(faccessat(dirfd, p, mode, 0));
+ unlock_user(p, target_path, 0);
+ return ret;
+}
+
+#ifdef TARGET_NR_access
+SYSCALL_IMPL(access)
+{
+ return do_faccessat(AT_FDCWD, arg1, arg2);
+}
+#endif
+
SYSCALL_IMPL(chdir)
{
abi_ulong target_path = arg1;
@@ -74,6 +94,11 @@ SYSCALL_IMPL(creat)
}
#endif
+SYSCALL_IMPL(faccessat)
+{
+ return do_faccessat(arg1, arg2, arg3);
+}
+
SYSCALL_IMPL(fchmod)
{
return get_errno(fchmod(arg1, arg2));
@@ -5380,24 +5380,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
void *p;
switch(num) {
-#ifdef TARGET_NR_access
- case TARGET_NR_access:
- if (!(p = lock_user_string(arg1))) {
- return -TARGET_EFAULT;
- }
- ret = get_errno(access(path(p), arg2));
- unlock_user(p, arg1, 0);
- return ret;
-#endif
-#if defined(TARGET_NR_faccessat) && defined(__NR_faccessat)
- case TARGET_NR_faccessat:
- if (!(p = lock_user_string(arg2))) {
- return -TARGET_EFAULT;
- }
- ret = get_errno(faccessat(arg1, p, arg3, 0));
- unlock_user(p, arg2, 0);
- return ret;
-#endif
#ifdef TARGET_NR_nice /* not on alpha */
case TARGET_NR_nice:
return get_errno(nice(arg1));
@@ -9,9 +9,6 @@
#ifdef TARGET_NR_accept4
{ TARGET_NR_accept4, "accept4" , NULL, NULL, NULL },
#endif
-#ifdef TARGET_NR_access
-{ TARGET_NR_access, "access" , NULL, print_access, NULL },
-#endif
#ifdef TARGET_NR_acct
{ TARGET_NR_acct, "acct" , NULL, NULL, NULL },
#endif
@@ -142,9 +139,6 @@
#ifdef TARGET_NR_exit_group
{ TARGET_NR_exit_group, "exit_group" , "%s(%d)\n", NULL, NULL },
#endif
-#ifdef TARGET_NR_faccessat
-{ TARGET_NR_faccessat, "faccessat" , NULL, print_faccessat, NULL },
-#endif
#ifdef TARGET_NR_fadvise64
{ TARGET_NR_fadvise64, "fadvise64" , NULL, NULL, NULL },
#endif
Note that faccessat is unconditionally available. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- linux-user/syscall-defs.h | 4 ++++ linux-user/syscall.h | 1 + linux-user/strace.c | 33 ++++----------------------------- linux-user/syscall-file.inc.c | 25 +++++++++++++++++++++++++ linux-user/syscall.c | 18 ------------------ linux-user/strace.list | 6 ------ 6 files changed, 34 insertions(+), 53 deletions(-)