[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v7 73/74] linux-user: Split out truncate, truncate64
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH v7 73/74] linux-user: Split out truncate, truncate64, ftruncate, ftruncate64 |
Date: |
Sun, 19 May 2019 13:37:25 -0700 |
Signed-off-by: Richard Henderson <address@hidden>
---
linux-user/syscall-defs.h | 16 +++++++++++++++
linux-user/syscall-file.inc.c | 32 +++++++++++++++++++++++++++++
linux-user/syscall.c | 38 -----------------------------------
linux-user/strace.list | 12 -----------
4 files changed, 48 insertions(+), 50 deletions(-)
diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h
index 67c908448d..8b2d95d19e 100644
--- a/linux-user/syscall-defs.h
+++ b/linux-user/syscall-defs.h
@@ -59,6 +59,14 @@ SYSCALL_DEF(futimesat, ARG_ATDIRFD, ARG_STR, ARG_PTR);
#ifdef TARGET_NR_fork
SYSCALL_DEF(fork);
#endif
+#ifdef TARGET_NR_ftruncate
+SYSCALL_DEF(ftruncate, ARG_DEC, ARG_DEC);
+#endif
+#ifdef TARGET_NR_ftruncate64
+SYSCALL_DEF_FULL(ftruncate64, .impl = impl_ftruncate,
+ .args = args_ftruncate64_truncate64,
+ .arg_type = { ARG_DEC, ARG_DEC64 });
+#endif
#ifdef TARGET_NR_gethostname
SYSCALL_DEF(gethostname, ARG_PTR, ARG_DEC);
#endif
@@ -292,6 +300,14 @@ SYSCALL_DEF(syncfs, ARG_DEC);
SYSCALL_DEF(time, ARG_PTR);
#endif
SYSCALL_DEF(times, ARG_PTR);
+#ifdef TARGET_NR_truncate
+SYSCALL_DEF(truncate, ARG_STR, ARG_DEC);
+#endif
+#ifdef TARGET_NR_truncate64
+SYSCALL_DEF_FULL(truncate64, .impl = impl_truncate,
+ .args = args_ftruncate64_truncate64,
+ .arg_type = { ARG_STR, ARG_DEC64 });
+#endif
SYSCALL_DEF(umask, ARG_OCT);
#ifdef TARGET_NR_umount
SYSCALL_DEF(umount, ARG_STR);
diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c
index bdf42ad437..7697cb304a 100644
--- a/linux-user/syscall-file.inc.c
+++ b/linux-user/syscall-file.inc.c
@@ -182,6 +182,25 @@ SYSCALL_IMPL(fchmodat)
return do_fchmodat(arg1, arg2, arg3);
}
+#ifdef TARGET_NR_ftruncate64
+# if TARGET_ABI_BITS == 32
+SYSCALL_ARGS(ftruncate64_truncate64)
+{
+ /* We have already assigned out[0]. */
+ int off = regpairs_aligned(cpu_env, TARGET_NR_ftruncate64);
+ out[1] = target_offset64(in[1 + off], in[2 + off]);
+ return def;
+}
+# else
+# define args_ftruncate64_truncate64 NULL
+# endif
+#endif
+
+SYSCALL_IMPL(ftruncate)
+{
+ return get_errno(ftruncate(arg1, arg2));
+}
+
#ifdef TARGET_NR_futimesat
SYSCALL_IMPL(futimesat)
{
@@ -1319,6 +1338,19 @@ SYSCALL_IMPL(syncfs)
return get_errno(syncfs(arg1));
}
+SYSCALL_IMPL(truncate)
+{
+ char *p = lock_user_string(arg1);
+ abi_long ret;
+
+ if (!p) {
+ return -TARGET_EFAULT;
+ }
+ ret = get_errno(truncate(p, arg2));
+ unlock_user(p, arg1, 0);
+ return ret;
+}
+
static abi_long do_umount2(abi_ulong target_path, int flags)
{
char *p = lock_user_string(target_path);
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 80e8b360a9..1b1d44bf32 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -3721,20 +3721,6 @@ static inline abi_long target_truncate64(void *cpu_env,
const char *arg1,
}
#endif
-#ifdef TARGET_NR_ftruncate64
-static inline abi_long target_ftruncate64(void *cpu_env, abi_long arg1,
- abi_long arg2,
- abi_long arg3,
- abi_long arg4)
-{
- if (regpairs_aligned(cpu_env, TARGET_NR_ftruncate64)) {
- arg2 = arg3;
- arg3 = arg4;
- }
- return get_errno(ftruncate64(arg1, target_offset64(arg2, arg3)));
-}
-#endif
-
static inline abi_long target_to_host_timespec(struct timespec *host_ts,
abi_ulong target_addr)
{
@@ -4158,18 +4144,6 @@ static abi_long do_syscall1(void *cpu_env, int num,
abi_long arg1,
void *p;
switch(num) {
-#ifdef TARGET_NR_truncate
- case TARGET_NR_truncate:
- if (!(p = lock_user_string(arg1)))
- return -TARGET_EFAULT;
- ret = get_errno(truncate(p, arg2));
- unlock_user(p, arg1, 0);
- return ret;
-#endif
-#ifdef TARGET_NR_ftruncate
- case TARGET_NR_ftruncate:
- return get_errno(ftruncate(arg1, arg2));
-#endif
case TARGET_NR_getpriority:
/* Note that negative values are valid for getpriority, so we must
differentiate based on errno settings. */
@@ -5371,18 +5345,6 @@ static abi_long do_syscall1(void *cpu_env, int num,
abi_long arg1,
return ret;
}
#endif
-#ifdef TARGET_NR_truncate64
- case TARGET_NR_truncate64:
- if (!(p = lock_user_string(arg1)))
- return -TARGET_EFAULT;
- ret = target_truncate64(cpu_env, p, arg2, arg3, arg4);
- unlock_user(p, arg1, 0);
- return ret;
-#endif
-#ifdef TARGET_NR_ftruncate64
- case TARGET_NR_ftruncate64:
- return target_ftruncate64(cpu_env, arg1, arg2, arg3, arg4);
-#endif
#ifdef TARGET_NR_stat64
case TARGET_NR_stat64:
if (!(p = lock_user_string(arg1))) {
diff --git a/linux-user/strace.list b/linux-user/strace.list
index 3326541f17..55b617239c 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -193,12 +193,6 @@
#ifdef TARGET_NR_ftime
{ TARGET_NR_ftime, "ftime" , NULL, NULL, NULL },
#endif
-#ifdef TARGET_NR_ftruncate
-{ TARGET_NR_ftruncate, "ftruncate" , NULL, NULL, NULL },
-#endif
-#ifdef TARGET_NR_ftruncate64
-{ TARGET_NR_ftruncate64, "ftruncate64" , NULL, NULL, NULL },
-#endif
#ifdef TARGET_NR_futex
{ TARGET_NR_futex, "futex" , NULL, print_futex, NULL },
#endif
@@ -1173,12 +1167,6 @@
#ifdef TARGET_NR_tkill
{ TARGET_NR_tkill, "tkill" , NULL, print_tkill, NULL },
#endif
-#ifdef TARGET_NR_truncate
-{ TARGET_NR_truncate, "truncate" , NULL, NULL, NULL },
-#endif
-#ifdef TARGET_NR_truncate64
-{ TARGET_NR_truncate64, "truncate64" , NULL, NULL, NULL },
-#endif
#ifdef TARGET_NR_tuxcall
{ TARGET_NR_tuxcall, "tuxcall" , NULL, NULL, NULL },
#endif
--
2.17.1
- [Qemu-devel] [PATCH v7 62/74] linux-user: Split out rt_sigqueueinfo, rt_tgsigqueueinfo, (continued)
- [Qemu-devel] [PATCH v7 62/74] linux-user: Split out rt_sigqueueinfo, rt_tgsigqueueinfo, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 63/74] linux-user: Split out sigreturn, rt_sigreturn, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 66/74] linux-user: Split out getrusage, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 67/74] linux-user: Split out gettimeofday, settimeofday, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 69/74] linux-user: Split out pselect6, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 68/74] linux-user: Split out select, _newselect, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 70/74] linux-user: Split out symlink, symlinkat, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 71/74] linux-user: Split out swapon, swapoff, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 72/74] linux-user: Split out reboot, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 73/74] linux-user: Split out truncate, truncate64, ftruncate, ftruncate64,
Richard Henderson <=
- [Qemu-devel] [PATCH v7 74/74] linux-user: Split out getpriority, setpriority, Richard Henderson, 2019/05/19
- Re: [Qemu-devel] [PATCH v7 00/74] linux-user: Split do_syscall, Laurent Vivier, 2019/05/20
- Re: [Qemu-devel] [PATCH v7 00/74] linux-user: Split do_syscall, Peter Maydell, 2019/05/20
- Re: [Qemu-devel] [PATCH v7 00/74] linux-user: Split do_syscall, Aleksandar Markovic, 2019/05/22