[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 059/108] linux-user: Split out fchdir, getpgid, l
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH v2 059/108] linux-user: Split out fchdir, getpgid, llseek, personality |
Date: |
Sat, 9 Jun 2018 17:01:31 -1000 |
Given that we use _LARGEFILE_SOURCE and _FILEOFFSET_BITS == 64, there
is no need to special-case llseek on the host side; always use lseek.
Define _llseek in terms of llseek, rather than the other way around.
Signed-off-by: Richard Henderson <address@hidden>
---
linux-user/syscall.c | 81 +++++++++++++++++++++++---------------------
1 file changed, 42 insertions(+), 39 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 7ff05dd33c..f5f21658a8 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -240,15 +240,6 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4
arg4,type5 arg5, \
#define __NR_sys_inotify_add_watch __NR_inotify_add_watch
#define __NR_sys_inotify_rm_watch __NR_inotify_rm_watch
-#if defined(__alpha__) || defined(__x86_64__) || defined(__s390x__)
-#define __NR__llseek __NR_lseek
-#endif
-
-/* Newer kernel ports have llseek() instead of _llseek() */
-#if defined(TARGET_NR_llseek) && !defined(TARGET_NR__llseek)
-#define TARGET_NR__llseek TARGET_NR_llseek
-#endif
-
/* These definitions produce an ENOSYS from the host kernel.
* Performing a bogus syscall is lazier than boilerplating
* the replacement functions here in C.
@@ -280,10 +271,6 @@ _syscall3(int, sys_getdents, uint, fd, struct linux_dirent
*, dirp, uint, count)
(defined(TARGET_NR_getdents64) && defined(__NR_getdents64))
_syscall3(int, sys_getdents64, uint, fd, struct linux_dirent64 *, dirp, uint,
count);
#endif
-#if defined(TARGET_NR__llseek) && defined(__NR_llseek)
-_syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo,
- loff_t *, res, uint, wh);
-#endif
_syscall3(int, sys_rt_sigqueueinfo, pid_t, pid, int, sig, siginfo_t *, uinfo)
_syscall4(int, sys_rt_tgsigqueueinfo, pid_t, pid, pid_t, tid, int, sig,
siginfo_t *, uinfo)
@@ -8026,6 +8013,11 @@ IMPL(faccessat)
return ret;
}
+IMPL(fchdir)
+{
+ return get_errno(fchdir(arg1));
+}
+
IMPL(fchmod)
{
return get_errno(fchmod(arg1, arg2));
@@ -8150,6 +8142,11 @@ IMPL(getpeername)
}
#endif
+IMPL(getpgid)
+{
+ return get_errno(getpgid(arg1));
+}
+
#ifdef TARGET_NR_getpgrp
IMPL(getpgrp)
{
@@ -8484,6 +8481,27 @@ IMPL(listen)
}
#endif
+/* Older kernel ports have _llseek() instead of llseek() */
+#if defined(TARGET_NR__llseek) && !defined(TARGET_NR_llseek)
+#define TARGET_NR_llseek TARGET_NR__llseek
+#endif
+
+#ifdef TARGET_NR_llseek
+IMPL(llseek)
+{
+ off_t res;
+
+ res = lseek(arg1, ((uint64_t)arg2 << 32) | (abi_ulong)arg3, arg5);
+ if (res == -1) {
+ return -host_to_target_errno(errno);
+ }
+ if (put_user_s64(res, arg4)) {
+ return -TARGET_EFAULT;
+ }
+ return 0;
+}
+#endif
+
IMPL(lseek)
{
return get_errno(lseek(arg1, arg2, arg3));
@@ -8901,6 +8919,11 @@ IMPL(pause)
}
#endif
+IMPL(personality)
+{
+ return get_errno(personality(arg1));
+}
+
#ifdef TARGET_NR_pipe
IMPL(pipe)
{
@@ -10462,32 +10485,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned
num, abi_long arg1,
void *p;
switch(num) {
- case TARGET_NR_getpgid:
- return get_errno(getpgid(arg1));
- case TARGET_NR_fchdir:
- return get_errno(fchdir(arg1));
- case TARGET_NR_personality:
- return get_errno(personality(arg1));
-#ifdef TARGET_NR__llseek /* Not on alpha */
- case TARGET_NR__llseek:
- {
- int64_t res;
-#if !defined(__NR_llseek)
- res = lseek(arg1, ((uint64_t)arg2 << 32) | (abi_ulong)arg3, arg5);
- if (res == -1) {
- ret = get_errno(res);
- } else {
- ret = 0;
- }
-#else
- ret = get_errno(_llseek(arg1, arg2, arg3, &res, arg5));
-#endif
- if ((ret == 0) && put_user_s64(res, arg4)) {
- return -TARGET_EFAULT;
- }
- }
- return ret;
-#endif
#ifdef TARGET_NR_getdents
case TARGET_NR_getdents:
#ifdef EMULATE_GETDENTS_WITH_GETDENTS
@@ -12924,6 +12921,7 @@ static impl_fn *syscall_table(unsigned num)
SYSCALL_WITH(exit_group, enosys);
#endif
SYSCALL(faccessat);
+ SYSCALL(fchdir);
SYSCALL(fchmod);
SYSCALL(fchmodat);
#ifdef TARGET_NR_fcntl
@@ -12946,6 +12944,7 @@ static impl_fn *syscall_table(unsigned num)
#ifdef TARGET_NR_getpeername
SYSCALL(getpeername);
#endif
+ SYSCALL(getpgid);
#ifdef TARGET_NR_getpgrp
SYSCALL(getpgrp);
#endif
@@ -12980,6 +12979,9 @@ static impl_fn *syscall_table(unsigned num)
SYSCALL(linkat);
#ifdef TARGET_NR_listen
SYSCALL(listen);
+#endif
+#ifdef TARGET_NR_llseek
+ SYSCALL(llseek);
#endif
SYSCALL(lseek);
#ifdef TARGET_NR_lstat
@@ -13042,6 +13044,7 @@ static impl_fn *syscall_table(unsigned num)
#ifdef TARGET_NR_pause
SYSCALL(pause);
#endif
+ SYSCALL(personality);
#ifdef TARGET_NR_pipe
SYSCALL(pipe);
#endif
--
2.17.1
- [Qemu-devel] [PATCH v2 049/108] linux-user: Fix stub gettid, (continued)
- [Qemu-devel] [PATCH v2 049/108] linux-user: Fix stub gettid, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 050/108] linux-user: Split out getitimer, setitimer, syslog, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 051/108] linux-user: Split out fstat, lstat, stat, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 052/108] linux-user: Unwrap TARGET_NR_syscall early, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 053/108] linux-user: Split out swapoff, sysinfo, vhangup, wait4, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 054/108] linux-user: Split out ipc, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 055/108] linux-user: Split out ipc syscalls, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 056/108] linux-user: Split out clone, exit_group, fsync, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 057/108] linux-user: Split out modify_ldt, setdomainname, uname, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 058/108] linux-user: Split out adjtimex, clock_adjtime, vm86, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 059/108] linux-user: Split out fchdir, getpgid, llseek, personality,
Richard Henderson <=
- [Qemu-devel] [PATCH v2 060/108] linux-user: Split out getdents, getdents64, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 061/108] linux-user: Split out poll, ppoll, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 062/108] linux-user: Split out flock, preadv, pwritev, readv, writev, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 063/108] linux-user: Split out fdatasync, getsid, _sysctl, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 065/108] linux-user: Split out getcpu, nanosleep, prctl, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 064/108] linux-user: Split out sched syscalls, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 066/108] linux-user: Split out arch_prctl, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 067/108] linux-user: Split out getcwd, pread64, pwrite64, sigaltstack, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 068/108] linux-user: Split out capget, capset, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 070/108] linux-user: Split out ftruncate64, truncate64, ugetrlimit, vfork, Richard Henderson, 2018/06/09