[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v7 27/74] linux-user: Split out mknod, mknodat
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH v7 27/74] linux-user: Split out mknod, mknodat |
Date: |
Sun, 19 May 2019 13:36:39 -0700 |
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 b234274034..c70c06d965 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -1923,45 +1923,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 76637fe71b..3adb629124 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 ea89734706..18163f558c 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -5384,22 +5384,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 95706a696b..f56d9acf76 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.1
- [Qemu-devel] [PATCH v7 18/74] linux-user: Split out wait4, waitid, waitpid, (continued)
- [Qemu-devel] [PATCH v7 18/74] linux-user: Split out wait4, waitid, waitpid, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 19/74] linux-user: Implement rusage argument to waitid, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 17/74] linux-user: Split out clone, fork, vfork, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 22/74] linux-user: Split out unlink, unlinkat, rmdir, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 21/74] linux-user: Split out link, linkat, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 13/74] linux-user: Split out ipc syscalls, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 23/74] linux-user: Split out execve, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 20/74] linux-user: Split out creat, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 24/74] linux-user: Implement execveat, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 26/74] linux-user: Split out time, Richard Henderson, 2019/05/19
- [Qemu-devel] [PATCH v7 27/74] linux-user: Split out mknod, mknodat,
Richard Henderson <=
- [Qemu-devel] [PATCH v7 30/74] linux-user: Split out getpid, getppid, getxpid, Richard Henderson, 2019/05/19
- [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