[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 12/33] linux-user: Split out open, openat
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH 12/33] linux-user: Split out open, openat |
Date: |
Fri, 1 Jun 2018 00:30:29 -0700 |
Signed-off-by: Richard Henderson <address@hidden>
---
linux-user/syscall.c | 65 ++++++++++++++++++++++++++++----------------
1 file changed, 42 insertions(+), 23 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index a9b59a8658..fb1a8a4e7e 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8145,6 +8145,44 @@ IMPL(exit)
g_assert_not_reached();
}
+#ifdef TARGET_NR_open
+IMPL(open)
+{
+ char *fn = lock_user_string(arg1);
+ abi_long ret;
+
+ if (!fn) {
+ return -TARGET_EFAULT;
+ }
+ ret = get_errno(do_openat(cpu_env, AT_FDCWD, fn,
+ target_to_host_bitmask(arg2, fcntl_flags_tbl),
+ arg3));
+ fd_trans_unregister(ret);
+ unlock_user(fn, arg1, 0);
+ return ret;
+}
+#endif
+
+IMPL(openat)
+{
+ char *fn;
+ abi_long ret;
+
+ if (is_hostfd(arg1)) {
+ return -TARGET_EBADF;
+ }
+ fn = lock_user_string(arg2);
+ if (!fn) {
+ return -TARGET_EFAULT;
+ }
+ ret = get_errno(do_openat(cpu_env, arg1, fn,
+ target_to_host_bitmask(arg3, fcntl_flags_tbl),
+ arg4));
+ fd_trans_unregister(ret);
+ unlock_user(fn, arg2, 0);
+ return ret;
+}
+
IMPL(read)
{
abi_long ret;
@@ -8210,29 +8248,6 @@ IMPL(everything_else)
char *fn;
switch(num) {
-#ifdef TARGET_NR_open
- case TARGET_NR_open:
- if (!(p = lock_user_string(arg1)))
- return -TARGET_EFAULT;
- ret = get_errno(do_openat(cpu_env, AT_FDCWD, p,
- target_to_host_bitmask(arg2,
fcntl_flags_tbl),
- arg3));
- fd_trans_unregister(ret);
- unlock_user(p, arg1, 0);
- return ret;
-#endif
- case TARGET_NR_openat:
- if (is_hostfd(arg1)) {
- return -TARGET_EBADF;
- }
- if (!(p = lock_user_string(arg2)))
- return -TARGET_EFAULT;
- ret = get_errno(do_openat(cpu_env, arg1, p,
- target_to_host_bitmask(arg3,
fcntl_flags_tbl),
- arg4));
- fd_trans_unregister(ret);
- unlock_user(p, arg2, 0);
- return ret;
#if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
case TARGET_NR_name_to_handle_at:
if (is_hostfd(arg1)) {
@@ -12926,6 +12941,10 @@ static impl_fn * const syscall_table[] = {
[TARGET_NR_close] = impl_close,
[TARGET_NR_execve] = impl_execve,
[TARGET_NR_exit] = impl_exit,
+#ifdef TARGET_NR_open
+ [TARGET_NR_open] = impl_open,
+#endif
+ [TARGET_NR_openat] = impl_openat,
[TARGET_NR_read] = impl_read,
[TARGET_NR_write] = impl_write,
};
--
2.17.0
- [Qemu-devel] [PATCH 05/33] linux-user: Propagate goto unimplemented_nowarn to return, (continued)
- [Qemu-devel] [PATCH 05/33] linux-user: Propagate goto unimplemented_nowarn to return, Richard Henderson, 2018/06/01
- [Qemu-devel] [PATCH 08/33] linux-user: Make syscall number unsigned, Richard Henderson, 2018/06/01
- [Qemu-devel] [PATCH 06/33] linux-user: Split out goto unimplemented to do_unimplemented, Richard Henderson, 2018/06/01
- [Qemu-devel] [PATCH 07/33] linux-user: Propagate goto fail to return, Richard Henderson, 2018/06/01
- [Qemu-devel] [PATCH 04/33] linux-user: Propagate goto efault to return, Richard Henderson, 2018/06/01
- [Qemu-devel] [PATCH 12/33] linux-user: Split out open, openat,
Richard Henderson <=
- [Qemu-devel] [PATCH 09/33] linux-user: Set up infrastructure for table-izing syscalls, Richard Henderson, 2018/06/01
- [Qemu-devel] [PATCH 10/33] linux-user: Split out brk, close, exit, read, write, Richard Henderson, 2018/06/01
- [Qemu-devel] [PATCH 02/33] linux-user: Relax single exit from "break", Richard Henderson, 2018/06/01
- [Qemu-devel] [PATCH 11/33] linux-user: Split out execve, Richard Henderson, 2018/06/01
- [Qemu-devel] [PATCH 14/33] linux-user: Split out open_to_handle_at, Richard Henderson, 2018/06/01
- [Qemu-devel] [PATCH 15/33] linux-user: Split out creat, fork, waitid, waitpid, Richard Henderson, 2018/06/01