[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 14/33] linux-user: Split out open_to_handle_at
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH 14/33] linux-user: Split out open_to_handle_at |
Date: |
Fri, 1 Jun 2018 00:30:31 -0700 |
At the same time, merge do_open_to_handle_at into the new function.
Signed-off-by: Richard Henderson <address@hidden>
---
linux-user/syscall.c | 84 ++++++++++++++++++++++----------------------
1 file changed, 42 insertions(+), 42 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 4afc22c20c..48bb1c0231 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7369,39 +7369,6 @@ static int do_futex(target_ulong uaddr, int op, int val,
target_ulong timeout,
return -TARGET_ENOSYS;
}
}
-#if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
-static abi_long do_open_by_handle_at(abi_long mount_fd, abi_long handle,
- abi_long flags)
-{
- struct file_handle *target_fh;
- struct file_handle *fh;
- unsigned int size, total_size;
- abi_long ret;
-
- if (get_user_s32(size, handle)) {
- return -TARGET_EFAULT;
- }
-
- total_size = sizeof(struct file_handle) + size;
- target_fh = lock_user(VERIFY_READ, handle, total_size, 1);
- if (!target_fh) {
- return -TARGET_EFAULT;
- }
-
- fh = g_memdup(target_fh, total_size);
- fh->handle_bytes = size;
- fh->handle_type = tswap32(target_fh->handle_type);
-
- ret = get_errno(open_by_handle_at(mount_fd, fh,
- target_to_host_bitmask(flags, fcntl_flags_tbl)));
-
- g_free(fh);
-
- unlock_user(target_fh, handle, total_size);
-
- return ret;
-}
-#endif
#if defined(TARGET_NR_signalfd) || defined(TARGET_NR_signalfd4)
@@ -8187,6 +8154,45 @@ IMPL(openat)
return ret;
}
+#if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
+IMPL(open_by_handle_at)
+{
+ abi_long mount_fd = arg1;
+ abi_long handle = arg2;
+ abi_long flags = arg3;
+ struct file_handle *target_fh;
+ struct file_handle *fh;
+ unsigned int size, total_size;
+ abi_long ret;
+
+ if (is_hostfd(mount_fd)) {
+ return -TARGET_EBADF;
+ }
+ if (get_user_s32(size, handle)) {
+ return -TARGET_EFAULT;
+ }
+
+ total_size = sizeof(struct file_handle) + size;
+ target_fh = lock_user(VERIFY_READ, handle, total_size, 1);
+ if (!target_fh) {
+ return -TARGET_EFAULT;
+ }
+
+ fh = g_memdup(target_fh, total_size);
+ fh->handle_bytes = size;
+ fh->handle_type = tswap32(target_fh->handle_type);
+
+ ret = get_errno(open_by_handle_at(mount_fd, fh,
+ target_to_host_bitmask(flags, fcntl_flags_tbl)));
+
+ g_free(fh);
+ unlock_user(target_fh, handle, total_size);
+
+ fd_trans_unregister(ret);
+ return ret;
+}
+#endif
+
IMPL(read)
{
abi_long ret;
@@ -8252,15 +8258,6 @@ IMPL(everything_else)
char *fn;
switch(num) {
-#if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
- case TARGET_NR_open_by_handle_at:
- if (is_hostfd(arg1)) {
- return -TARGET_EBADF;
- }
- ret = do_open_by_handle_at(arg1, arg2, arg3);
- fd_trans_unregister(ret);
- return ret;
-#endif
#ifdef TARGET_NR_fork
case TARGET_NR_fork:
return get_errno(do_fork(cpu_env, TARGET_SIGCHLD, 0, 0, 0, 0));
@@ -12944,6 +12941,9 @@ static impl_fn * const syscall_table[] = {
[TARGET_NR_open] = impl_open,
#endif
[TARGET_NR_openat] = impl_openat,
+#if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
+ [TARGET_NR_open_by_handle_at] = impl_open_by_handle_at,
+#endif
[TARGET_NR_read] = impl_read,
[TARGET_NR_write] = impl_write,
};
--
2.17.0
- Re: [Qemu-devel] [PATCH 04/33] linux-user: Propagate goto efault to return, (continued)
- [Qemu-devel] [PATCH 12/33] linux-user: Split out open, openat, Richard Henderson, 2018/06/01
- [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 <=
- [Qemu-devel] [PATCH 15/33] linux-user: Split out creat, fork, waitid, waitpid, Richard Henderson, 2018/06/01
- [Qemu-devel] [PATCH 13/33] linux-user: Split out name_to_handle_at, Richard Henderson, 2018/06/01
- [Qemu-devel] [PATCH 16/33] linux-user: Split out link, linkat, Richard Henderson, 2018/06/01
- [Qemu-devel] [PATCH 17/33] linux-user: Split out unlink, unlinkat, Richard Henderson, 2018/06/01
- [Qemu-devel] [PATCH 18/33] linux-user: Split out chdir, mknod, mknodat, time, chmod, Richard Henderson, 2018/06/01
- [Qemu-devel] [PATCH 19/33] linux-user: Remove all unimplemented entries, Richard Henderson, 2018/06/01
- [Qemu-devel] [PATCH 20/33] linux-user: Split out getpid, getxpid, lseek, Richard Henderson, 2018/06/01
- [Qemu-devel] [PATCH 21/33] linux-user: Split out mount, umount, Richard Henderson, 2018/06/01
- [Qemu-devel] [PATCH 22/33] linux-user: Split out alarm, pause, stime, utime, utimes, Richard Henderson, 2018/06/01
- [Qemu-devel] [PATCH 23/33] linux-user: Split out access, faccessat, futimesat, kill, nice, sync, syncfs, Richard Henderson, 2018/06/01