[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v7 38/74] linux-user: Split out sync, syncfs
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH v7 38/74] linux-user: Split out sync, syncfs |
Date: |
Sun, 19 May 2019 13:36:50 -0700 |
Note that syncfs is universally available.
If !CONFIG_SYNCFS, provide our own syscall replacement.
Signed-off-by: Richard Henderson <address@hidden>
---
linux-user/syscall-defs.h | 2 ++
linux-user/syscall-file.inc.c | 11 +++++++++++
linux-user/syscall.c | 20 ++++++++++++--------
linux-user/strace.list | 6 ------
4 files changed, 25 insertions(+), 14 deletions(-)
diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h
index 860754aaca..497fbdba66 100644
--- a/linux-user/syscall-defs.h
+++ b/linux-user/syscall-defs.h
@@ -171,6 +171,8 @@ SYSCALL_DEF(shmget, ARG_DEC, ARG_DEC, ARG_HEX);
#ifdef TARGET_NR_stime
SYSCALL_DEF(stime, ARG_PTR);
#endif
+SYSCALL_DEF(sync);
+SYSCALL_DEF(syncfs, ARG_DEC);
#ifdef TARGET_NR_time
SYSCALL_DEF(time, ARG_PTR);
#endif
diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c
index 5e276d13bc..9f3cf7221a 100644
--- a/linux-user/syscall-file.inc.c
+++ b/linux-user/syscall-file.inc.c
@@ -873,6 +873,17 @@ SYSCALL_IMPL(readlinkat)
}
#endif
+SYSCALL_IMPL(sync)
+{
+ sync();
+ return 0;
+}
+
+SYSCALL_IMPL(syncfs)
+{
+ return get_errno(syncfs(arg1));
+}
+
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 6d30e8ff2f..d612dade23 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -199,6 +199,15 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4
arg4,type5 arg5, \
#define __NR_sys_gettid __NR_gettid
_syscall0(int, sys_gettid)
+/*
+ * These definitions produce an ENOSYS from the host kernel.
+ * Performing a bogus syscall is easier than boilerplating
+ * the replacement functions here in C.
+ */
+#ifndef __NR_syncfs
+#define __NR_syncfs -1
+#endif
+
/* For the 64-bit guest on 32-bit host case we must emulate
* getdents using getdents64, because otherwise the host
* might hand us back more dirent records than we can fit
@@ -254,11 +263,13 @@ _syscall3(int, ioprio_set, int, which, int, who, int,
ioprio)
#if defined(TARGET_NR_getrandom) && defined(__NR_getrandom)
_syscall3(int, getrandom, void *, buf, size_t, buflen, unsigned int, flags)
#endif
-
#if defined(TARGET_NR_kcmp) && defined(__NR_kcmp)
_syscall5(int, kcmp, pid_t, pid1, pid_t, pid2, int, type,
unsigned long, idx1, unsigned long, idx2)
#endif
+#ifndef CONFIG_SYNCFS
+_syscall1(int, syncfs, int, fd)
+#endif
static bitmask_transtbl fcntl_flags_tbl[] = {
{ TARGET_O_ACCMODE, TARGET_O_WRONLY, O_ACCMODE, O_WRONLY, },
@@ -5380,13 +5391,6 @@ static abi_long do_syscall1(void *cpu_env, int num,
abi_long arg1,
void *p;
switch(num) {
- case TARGET_NR_sync:
- sync();
- return 0;
-#if defined(TARGET_NR_syncfs) && defined(CONFIG_SYNCFS)
- case TARGET_NR_syncfs:
- return get_errno(syncfs(arg1));
-#endif
case TARGET_NR_kill:
return get_errno(safe_kill(arg1, target_to_host_signal(arg2)));
#ifdef TARGET_NR_rename
diff --git a/linux-user/strace.list b/linux-user/strace.list
index 3161546afc..749bdce638 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -1260,12 +1260,6 @@
#ifdef TARGET_NR_symlinkat
{ TARGET_NR_symlinkat, "symlinkat", NULL, print_symlinkat, NULL },
#endif
-#ifdef TARGET_NR_sync
-{ TARGET_NR_sync, "sync" , NULL, NULL, NULL },
-#endif
-#ifdef TARGET_NR_syncfs
-{ TARGET_NR_syncfs, "syncfs" , "%s(%d)", NULL, NULL },
-#endif
#ifdef TARGET_NR_syscall
{ TARGET_NR_syscall, "syscall" , NULL, NULL, NULL },
#endif
--
2.17.1
- [Qemu-devel] [PATCH v7 28/74] linux-user: Split out chmod, fchmod, fchmodat, (continued)
- [Qemu-devel] [PATCH v7 28/74] linux-user: Split out chmod, fchmod, fchmodat, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 25/74] linux-user: Split out chdir, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 33/74] linux-user: Split out stime, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 32/74] linux-user: Split out umount, umount2, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 29/74] linux-user: Split out lseek, llseek, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 31/74] linux-user: Split out mount, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 34/74] linux-user: Split out alarm, pause, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 35/74] linux-user: Split out utime, utimes, futimesat, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 36/74] linux-user: Split out access, faccessat, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 37/74] linux-user: Split out nice, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 38/74] linux-user: Split out sync, syncfs,
Richard Henderson <=
- [Qemu-devel] [PATCH v7 42/74] linux-user: Split out dup, dup2, dup3, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 40/74] linux-user: Split out rename, renameat, renameat2, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 41/74] linux-user: Split out mkdir, mkdirat, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 45/74] linux-user: Split out acct, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 39/74] linux-user: Split out kill, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 46/74] linux-user: Move syscall_init to the end, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 44/74] linux-user: Split out times, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 43/74] linux-user: Split out pipe, pipe2, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 48/74] linux-user: Fix types in ioctl logging, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 49/74] linux-user: Remove sentinel from ioctl_entries, Richard Henderson, 2019/05/19