[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 013/108] linux-user: Split out name_to_handle_at
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH v2 013/108] linux-user: Split out name_to_handle_at |
Date: |
Sat, 9 Jun 2018 17:00:45 -1000 |
At the same time, merge do_name_to_handle_at into the new function.
All targets define this syscall; remove one of the two ifdefs.
Signed-off-by: Richard Henderson <address@hidden>
---
linux-user/syscall.c | 116 +++++++++++++++++++++----------------------
1 file changed, 58 insertions(+), 58 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index a4d0f2720f..90341f4254 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7361,59 +7361,6 @@ static int do_futex(target_ulong uaddr, int op, int val,
target_ulong timeout,
return -TARGET_ENOSYS;
}
}
-#if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
-static abi_long do_name_to_handle_at(abi_long dirfd, abi_long pathname,
- abi_long handle, abi_long mount_id,
- abi_long flags)
-{
- struct file_handle *target_fh;
- struct file_handle *fh;
- int mid = 0;
- abi_long ret;
- char *name;
- unsigned int size, total_size;
-
- if (get_user_s32(size, handle)) {
- return -TARGET_EFAULT;
- }
-
- name = lock_user_string(pathname);
- if (!name) {
- return -TARGET_EFAULT;
- }
-
- total_size = sizeof(struct file_handle) + size;
- target_fh = lock_user(VERIFY_WRITE, handle, total_size, 0);
- if (!target_fh) {
- unlock_user(name, pathname, 0);
- return -TARGET_EFAULT;
- }
-
- fh = g_malloc0(total_size);
- fh->handle_bytes = size;
-
- ret = get_errno(name_to_handle_at(dirfd, path(name), fh, &mid, flags));
- unlock_user(name, pathname, 0);
-
- /* man name_to_handle_at(2):
- * Other than the use of the handle_bytes field, the caller should treat
- * the file_handle structure as an opaque data type
- */
-
- memcpy(target_fh, fh, total_size);
- target_fh->handle_bytes = tswap32(fh->handle_bytes);
- target_fh->handle_type = tswap32(fh->handle_type);
- g_free(fh);
- unlock_user(target_fh, handle, total_size);
-
- if (put_user_s32(mid, mount_id)) {
- return -TARGET_EFAULT;
- }
-
- return ret;
-
-}
-#endif
#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,
@@ -8116,6 +8063,61 @@ IMPL(exit)
g_assert_not_reached();
}
+#ifdef CONFIG_OPEN_BY_HANDLE
+IMPL(name_to_handle_at)
+{
+ abi_long dirfd = arg1;
+ abi_long pathname = arg2;
+ abi_long handle = arg3;
+ abi_long mount_id = arg4;
+ abi_long flags = arg5;
+ struct file_handle *target_fh;
+ struct file_handle *fh;
+ int mid = 0;
+ abi_long ret;
+ char *name;
+ unsigned int size, total_size;
+
+ if (get_user_s32(size, handle)) {
+ return -TARGET_EFAULT;
+ }
+
+ name = lock_user_string(pathname);
+ if (!name) {
+ return -TARGET_EFAULT;
+ }
+
+ total_size = sizeof(struct file_handle) + size;
+ target_fh = lock_user(VERIFY_WRITE, handle, total_size, 0);
+ if (!target_fh) {
+ unlock_user(name, pathname, 0);
+ return -TARGET_EFAULT;
+ }
+
+ fh = g_malloc0(total_size);
+ fh->handle_bytes = size;
+
+ ret = get_errno(name_to_handle_at(dirfd, path(name), fh, &mid, flags));
+ unlock_user(name, pathname, 0);
+
+ /* man name_to_handle_at(2):
+ * Other than the use of the handle_bytes field, the caller should treat
+ * the file_handle structure as an opaque data type
+ */
+
+ memcpy(target_fh, fh, total_size);
+ target_fh->handle_bytes = tswap32(fh->handle_bytes);
+ target_fh->handle_type = tswap32(fh->handle_type);
+ g_free(fh);
+ unlock_user(target_fh, handle, total_size);
+
+ if (put_user_s32(mid, mount_id)) {
+ return -TARGET_EFAULT;
+ }
+ return ret;
+}
+#endif
+
#ifdef TARGET_NR_open
IMPL(open)
{
@@ -8211,11 +8213,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num,
abi_long arg1,
void *p;
switch(num) {
-#if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
- case TARGET_NR_name_to_handle_at:
- ret = do_name_to_handle_at(arg1, arg2, arg3, arg4, arg5);
- return ret;
-#endif
#if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
case TARGET_NR_open_by_handle_at:
ret = do_open_by_handle_at(arg1, arg2, arg3);
@@ -12491,6 +12488,9 @@ static impl_fn *syscall_table(unsigned num)
SYSCALL(close);
SYSCALL(execve);
SYSCALL(exit);
+#ifdef CONFIG_OPEN_BY_HANDLE
+ SYSCALL(name_to_handle_at);
+#endif
#ifdef TARGET_NR_open
SYSCALL(open);
#endif
--
2.17.1
- [Qemu-devel] [PATCH v2 005/108] linux-user: Propagate goto unimplemented_nowarn to return, (continued)
- [Qemu-devel] [PATCH v2 005/108] linux-user: Propagate goto unimplemented_nowarn to return, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 006/108] linux-user: Propagate goto unimplemented to default, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 007/108] linux-user: Propagate goto fail to return, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 004/108] linux-user: Propagate goto efault to return, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 008/108] linux-user: Make syscall number unsigned, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 009/108] linux-user: Set up infrastructure for table-izing syscalls, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 010/108] linux-user: Split out brk, close, exit, read, write, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 003/108] linux-user: Relax single exit from "break", Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 011/108] linux-user: Split out execve, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 012/108] linux-user: Split out open, openat, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 013/108] linux-user: Split out name_to_handle_at,
Richard Henderson <=
- [Qemu-devel] [PATCH v2 014/108] linux-user: Split out open_to_handle_at, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 016/108] linux-user: Split out link, linkat, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 015/108] linux-user: Split out creat, fork, waitid, waitpid, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 017/108] linux-user: Split out unlink, unlinkat, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 018/108] linux-user: Split out chdir, mknod, mknodat, time, chmod, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 019/108] linux-user: Split out getpid, getxpid, lseek, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 020/108] linux-user: Split out mount, umount, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 021/108] linux-user: Split out alarm, pause, stime, utime, utimes, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 022/108] linux-user: Split out access, faccessat, futimesat, kill, nice, sync, syncfs, Richard Henderson, 2018/06/09
- [Qemu-devel] [PATCH v2 023/108] linux-user: Split out rename, renameat, renameat2, Richard Henderson, 2018/06/09