From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:44490) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qqs4C-00065d-7y for qemu-devel@nongnu.org; Tue, 09 Aug 2011 15:34:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qqs49-0000v5-Ej for qemu-devel@nongnu.org; Tue, 09 Aug 2011 15:34:20 -0400 Received: from na3sys009aog120.obsmtp.com ([74.125.149.140]:54961) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1Qqs49-0000te-6m for qemu-devel@nongnu.org; Tue, 09 Aug 2011 15:34:17 -0400 Received: by mail-yx0-f176.google.com with SMTP id 11so315921yxl.21 for ; Tue, 09 Aug 2011 12:34:09 -0700 (PDT) Date: Tue, 9 Aug 2011 12:34:06 -0700 From: An-Cheng Huang Message-ID: <20110809193406.GD24592@debian.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] [PATCH 3/3] linux-user: Implement setxattr/getxattr/removexattr syscalls List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, riku.voipio@iki.fi This patch implements the setxattr, getxattr, and removexattr syscalls if CONFIG_ATTR is enabled. Note that since libattr uses indirect syscalls for these, this change depends on the fix for indirect syscall handling on MIPS. Signed-off-by: An-Cheng Huang --- linux-user/syscall.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 51 insertions(+), 3 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 73f9baa..afc6b5d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -70,6 +70,9 @@ int __clone2(int (*fn)(void *), void *child_stack_base, #ifdef CONFIG_EPOLL #include #endif +#ifdef CONFIG_ATTR +#include +#endif #define termios host_termios #define winsize host_winsize @@ -7633,22 +7636,67 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, #endif break; #endif +#ifdef CONFIG_ATTR #ifdef TARGET_NR_setxattr - case TARGET_NR_setxattr: case TARGET_NR_lsetxattr: case TARGET_NR_fsetxattr: - case TARGET_NR_getxattr: case TARGET_NR_lgetxattr: case TARGET_NR_fgetxattr: case TARGET_NR_listxattr: case TARGET_NR_llistxattr: case TARGET_NR_flistxattr: - case TARGET_NR_removexattr: case TARGET_NR_lremovexattr: case TARGET_NR_fremovexattr: ret = -TARGET_EOPNOTSUPP; break; + case TARGET_NR_setxattr: + { + void *p, *n, *v; + p = lock_user_string(arg1); + n = lock_user_string(arg2); + v = lock_user(VERIFY_READ, arg3, arg4, 1); + if (p && n && v) { + ret = get_errno(setxattr(p, n, v, arg4, arg5)); + } else { + ret = -TARGET_EFAULT; + } + unlock_user(p, arg1, 0); + unlock_user(n, arg2, 0); + unlock_user(v, arg3, 0); + } + break; + case TARGET_NR_getxattr: + { + void *p, *n, *v; + p = lock_user_string(arg1); + n = lock_user_string(arg2); + v = lock_user(VERIFY_WRITE, arg3, arg4, 0); + if (p && n && v) { + ret = get_errno(getxattr(p, n, v, arg4)); + } else { + ret = -TARGET_EFAULT; + } + unlock_user(p, arg1, 0); + unlock_user(n, arg2, 0); + unlock_user(v, arg3, arg4); + } + break; + case TARGET_NR_removexattr: + { + void *p, *n; + p = lock_user_string(arg1); + n = lock_user_string(arg2); + if (p && n) { + ret = get_errno(removexattr(p, n)); + } else { + ret = -TARGET_EFAULT; + } + unlock_user(p, arg1, 0); + unlock_user(n, arg2, 0); + } + break; #endif +#endif /* CONFIG_ATTR */ #ifdef TARGET_NR_set_thread_area case TARGET_NR_set_thread_area: #if defined(TARGET_MIPS) -- 1.7.2.5