@@ -20,6 +20,9 @@ SYSCALL_DEF_FULL(brk, .impl = impl_brk,
.print_ret = print_syscall_ptr_ret,
.arg_type = { ARG_PTR });
SYSCALL_DEF(chdir, ARG_STR);
+#ifdef TARGET_NR_chmod
+SYSCALL_DEF(chmod, ARG_STR, ARG_MODEFLAG);
+#endif
SYSCALL_DEF_ARGS(clone, ARG_CLONEFLAG, ARG_PTR, ARG_PTR, ARG_PTR, ARG_PTR);
SYSCALL_DEF(close, ARG_DEC);
#ifdef TARGET_NR_creat
@@ -28,6 +31,8 @@ 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(fchmod, ARG_DEC, ARG_MODEFLAG);
+SYSCALL_DEF(fchmodat, ARG_ATDIRFD, ARG_STR, ARG_MODEFLAG);
#ifdef TARGET_NR_fork
SYSCALL_DEF(fork);
#endif
@@ -1125,19 +1125,6 @@ print_chroot(const struct syscallname *name,
}
#endif
-#ifdef TARGET_NR_chmod
-static void
-print_chmod(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_file_mode(arg1, 1);
- print_syscall_epilogue(name);
-}
-#endif
-
#ifdef TARGET_NR_clock_adjtime
static void
print_clock_adjtime(const struct syscallname *name,
@@ -1179,21 +1166,6 @@ print_faccessat(const struct syscallname *name,
}
#endif
-#ifdef TARGET_NR_fchmodat
-static void
-print_fchmodat(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_file_mode(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,
@@ -30,6 +30,26 @@ SYSCALL_IMPL(chdir)
return ret;
}
+static abi_long do_fchmodat(int dirfd, abi_ulong target_path, mode_t mode)
+{
+ char *p = lock_user_string(target_path);
+ abi_long ret;
+
+ if (!p) {
+ return -TARGET_EFAULT;
+ }
+ ret = get_errno(fchmodat(dirfd, p, mode, 0));
+ unlock_user(p, target_path, 0);
+ return ret;
+}
+
+#ifdef TARGET_NR_chmod
+SYSCALL_IMPL(chmod)
+{
+ return do_fchmodat(AT_FDCWD, arg1, arg2);
+}
+#endif
+
SYSCALL_IMPL(close)
{
int fd = arg1;
@@ -54,6 +74,16 @@ SYSCALL_IMPL(creat)
}
#endif
+SYSCALL_IMPL(fchmod)
+{
+ return get_errno(fchmod(arg1, arg2));
+}
+
+SYSCALL_IMPL(fchmodat)
+{
+ return do_fchmodat(arg1, arg2, arg3);
+}
+
static abi_long do_linkat(int olddirfd, abi_ulong target_oldpath,
int newdirfd, abi_ulong target_newpath,
int flags)
@@ -5384,14 +5384,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
void *p;
switch(num) {
-#ifdef TARGET_NR_chmod
- case TARGET_NR_chmod:
- if (!(p = lock_user_string(arg1)))
- return -TARGET_EFAULT;
- ret = get_errno(chmod(p, arg2));
- unlock_user(p, arg1, 0);
- return ret;
-#endif
#ifdef TARGET_NR_lseek
case TARGET_NR_lseek:
return get_errno(lseek(arg1, arg2, arg3));
@@ -6463,16 +6455,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
#ifdef TARGET_NR_ftruncate
case TARGET_NR_ftruncate:
return get_errno(ftruncate(arg1, arg2));
-#endif
- case TARGET_NR_fchmod:
- return get_errno(fchmod(arg1, arg2));
-#if defined(TARGET_NR_fchmodat)
- case TARGET_NR_fchmodat:
- if (!(p = lock_user_string(arg2)))
- return -TARGET_EFAULT;
- ret = get_errno(fchmodat(arg1, p, arg3, 0));
- unlock_user(p, arg2, 0);
- return ret;
#endif
case TARGET_NR_getpriority:
/* Note that negative values are valid for getpriority, so we must
@@ -61,9 +61,6 @@
#ifdef TARGET_NR_capset
{ TARGET_NR_capset, "capset" , "%s(%p,%p)", NULL, NULL },
#endif
-#ifdef TARGET_NR_chmod
-{ TARGET_NR_chmod, "chmod" , NULL, print_chmod, NULL },
-#endif
#ifdef TARGET_NR_chown
{ TARGET_NR_chown, "chown" , NULL, NULL, NULL },
#endif
@@ -169,12 +166,6 @@
#ifdef TARGET_NR_fchdir
{ TARGET_NR_fchdir, "fchdir" , NULL, NULL, NULL },
#endif
-#ifdef TARGET_NR_fchmod
-{ TARGET_NR_fchmod, "fchmod" , "%s(%d,%#o)", NULL, NULL },
-#endif
-#ifdef TARGET_NR_fchmodat
-{ TARGET_NR_fchmodat, "fchmodat" , NULL, print_fchmodat, NULL },
-#endif
#ifdef TARGET_NR_fchown
{ TARGET_NR_fchown, "fchown" , "%s(%d,%d,%d)", NULL, NULL },
#endif
Note that fchmodat is universally provided. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- linux-user/syscall-defs.h | 5 +++++ linux-user/strace.c | 28 ---------------------------- linux-user/syscall-file.inc.c | 30 ++++++++++++++++++++++++++++++ linux-user/syscall.c | 18 ------------------ linux-user/strace.list | 9 --------- 5 files changed, 35 insertions(+), 55 deletions(-)