[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v6 28/49] linux-user: Split out mknod, mknodat
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH v6 28/49] linux-user: Split out mknod, mknodat |
Date: |
Sat, 19 Jan 2019 08:31:01 +1100 |
Note that mknodat is universally provided.
Signed-off-by: Richard Henderson <address@hidden>
---
linux-user/syscall-defs.h | 4 ++++
linux-user/strace.c | 39 -----------------------------------
linux-user/syscall-file.inc.c | 26 +++++++++++++++++++++++
linux-user/syscall.c | 16 --------------
linux-user/strace.list | 6 ------
5 files changed, 30 insertions(+), 61 deletions(-)
diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h
index 9950b73e76..b5951e6911 100644
--- a/linux-user/syscall-defs.h
+++ b/linux-user/syscall-defs.h
@@ -38,6 +38,10 @@ SYSCALL_DEF_ARGS(ipc, ARG_HEX, ARG_DEC, ARG_DEC, ARG_HEX,
ARG_PTR, ARG_HEX);
SYSCALL_DEF(link, ARG_STR, ARG_STR);
#endif
SYSCALL_DEF(linkat, ARG_ATDIRFD, ARG_STR, ARG_ATDIRFD, ARG_STR, ARG_ATFLAG);
+#ifdef TARGET_NR_mknod
+SYSCALL_DEF(mknod, ARG_STR, ARG_MODEFLAG, ARG_HEX);
+#endif
+SYSCALL_DEF(mknodat, ARG_ATDIRFD, ARG_STR, ARG_MODEFLAG, ARG_HEX);
SYSCALL_DEF(mlock, ARG_PTR, ARG_DEC);
SYSCALL_DEF(mlockall, ARG_HEX);
#ifdef TARGET_NR_mmap
diff --git a/linux-user/strace.c b/linux-user/strace.c
index 5133998c4f..668e6a4759 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -1911,45 +1911,6 @@ print_syslog(const struct syscallname *name,
}
#endif
-#ifdef TARGET_NR_mknod
-static void
-print_mknod(const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
-{
- int hasdev = (arg1 & (S_IFCHR|S_IFBLK));
-
- print_syscall_prologue(name);
- print_string(arg0, 0);
- print_file_mode(arg1, (hasdev == 0));
- if (hasdev) {
- print_raw_param("makedev(%d", major(arg2), 0);
- print_raw_param("%d)", minor(arg2), 1);
- }
- print_syscall_epilogue(name);
-}
-#endif
-
-#ifdef TARGET_NR_mknodat
-static void
-print_mknodat(const struct syscallname *name,
- abi_long arg0, abi_long arg1, abi_long arg2,
- abi_long arg3, abi_long arg4, abi_long arg5)
-{
- int hasdev = (arg2 & (S_IFCHR|S_IFBLK));
-
- print_syscall_prologue(name);
- print_at_dirfd(arg0, 0);
- print_string(arg1, 0);
- print_file_mode(arg2, (hasdev == 0));
- if (hasdev) {
- print_raw_param("makedev(%d", major(arg3), 0);
- print_raw_param("%d)", minor(arg3), 1);
- }
- print_syscall_epilogue(name);
-}
-#endif
-
#ifdef TARGET_NR_mq_open
static void
print_mq_open(const struct syscallname *name,
diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c
index 7a4751d460..3b5a79fe74 100644
--- a/linux-user/syscall-file.inc.c
+++ b/linux-user/syscall-file.inc.c
@@ -82,6 +82,32 @@ SYSCALL_IMPL(linkat)
return do_linkat(arg1, arg2, arg3, arg4, arg5);
}
+static abi_long do_mknodat(int dirfd, abi_ulong target_path,
+ mode_t mode, dev_t dev)
+{
+ char *p = lock_user_string(target_path);
+ abi_long ret;
+
+ if (!p) {
+ return -TARGET_EFAULT;
+ }
+ ret = get_errno(mknodat(dirfd, p, mode, dev));
+ unlock_user(p, target_path, 0);
+ return ret;
+}
+
+#ifdef TARGET_NR_mknod
+SYSCALL_IMPL(mknod)
+{
+ return do_mknodat(AT_FDCWD, arg1, arg2, arg3);
+}
+#endif
+
+SYSCALL_IMPL(mknodat)
+{
+ return do_mknodat(arg1, arg2, arg3, arg4);
+}
+
/*
* Helpers for do_openat, manipulating /proc/self/foo.
*/
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index cc5360ae43..d46b4df677 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -5331,22 +5331,6 @@ static abi_long do_syscall1(void *cpu_env, int num,
abi_long arg1,
void *p;
switch(num) {
-#ifdef TARGET_NR_mknod
- case TARGET_NR_mknod:
- if (!(p = lock_user_string(arg1)))
- return -TARGET_EFAULT;
- ret = get_errno(mknod(p, arg2, arg3));
- unlock_user(p, arg1, 0);
- return ret;
-#endif
-#if defined(TARGET_NR_mknodat)
- case TARGET_NR_mknodat:
- if (!(p = lock_user_string(arg2)))
- return -TARGET_EFAULT;
- ret = get_errno(mknodat(arg1, p, arg3, arg4));
- unlock_user(p, arg2, 0);
- return ret;
-#endif
#ifdef TARGET_NR_chmod
case TARGET_NR_chmod:
if (!(p = lock_user_string(arg1)))
diff --git a/linux-user/strace.list b/linux-user/strace.list
index 3505014501..adf8955278 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -518,12 +518,6 @@
#ifdef TARGET_NR_mkdirat
{ TARGET_NR_mkdirat, "mkdirat" , NULL, print_mkdirat, NULL },
#endif
-#ifdef TARGET_NR_mknod
-{ TARGET_NR_mknod, "mknod" , NULL, print_mknod, NULL },
-#endif
-#ifdef TARGET_NR_mknodat
-{ TARGET_NR_mknodat, "mknodat" , NULL, print_mknodat, NULL },
-#endif
#ifdef TARGET_NR_modify_ldt
{ TARGET_NR_modify_ldt, "modify_ldt" , NULL, NULL, NULL },
#endif
--
2.17.2
- [Qemu-devel] [PATCH v6 16/49] linux-user: Split out exit, (continued)
- [Qemu-devel] [PATCH v6 16/49] linux-user: Split out exit, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 17/49] linux-user: Split out brk, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 14/49] linux-user: Split out ipc syscalls, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 18/49] linux-user: Split out clone, fork, vfork, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 19/49] linux-user: Split out wait4, waitid, waitpid, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 20/49] linux-user: Implement rusage argument to waitid, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 21/49] linux-user: Split out creat, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 26/49] linux-user: Split out chdir, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 22/49] linux-user: Split out link, linkat, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 24/49] linux-user: Split out execve, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 28/49] linux-user: Split out mknod, mknodat,
Richard Henderson <=
- [Qemu-devel] [PATCH v6 25/49] linux-user: Implement execveat, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 23/49] linux-user: Split out unlink, unlinkat, rmdir, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 27/49] linux-user: Split out time, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 29/49] linux-user: Split out chmod, fchmod, fchmodat, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 30/49] linux-user: Split out lseek, llseek, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 31/49] linux-user: Split out getpid, getppid, getxpid, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 33/49] linux-user: Split out umount, umount2, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 34/49] linux-user: Split out stime, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 32/49] linux-user: Split out mount, Richard Henderson, 2019/01/18
- [Qemu-devel] [PATCH v6 35/49] linux-user: Split out alarm, pause, Richard Henderson, 2019/01/18