From patchwork Fri Aug 15 11:01:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 35432 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f199.google.com (mail-pd0-f199.google.com [209.85.192.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3B13E203C5 for ; Fri, 15 Aug 2014 11:05:15 +0000 (UTC) Received: by mail-pd0-f199.google.com with SMTP id v10sf16115111pde.2 for ; Fri, 15 Aug 2014 04:05:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=phsCNdpzkfccTTkWWNh2bake2OOvGKtraI2WRZXZrto=; b=bdqWgxICAKqG/GOh0ze5PJdc2waQqCys0XawgjgXo1bBNc0ckYsM/d5FFCYRAU6ceS kZXPRICqaQn/mGkE3dHD2Ml8W3zYax1q5tRrntx1hc3ibiEhDnDDGcSo1KRmPVo6wbhx d3gbK819pEu2ZJLJrgcMARpsXK00qgLJhAA9rMw6p6oCxtxuhkzOksCrAl9xdP76BdLw /EFdeSocS1sd0YJsARU98s9fOheJ5G1TibTdz1yROjAqvNZQQ1cpGxDSKUCd3zds7LGH 2UQrgxed9/4s7Mi0tdm9Cy1bgyGGz0W1FEM0v8wNQg4GEYL2A6OzDZfbn+YdWWcCoJ6V 2S8A== X-Gm-Message-State: ALoCoQk5UmifjePWv2eorJcITtsli6XF153WkL9lz7weQqv1x6xFOIhY5kzvE01BxZ9pUKlAKwue X-Received: by 10.66.161.7 with SMTP id xo7mr9091690pab.14.1408100710623; Fri, 15 Aug 2014 04:05:10 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.95.182 with SMTP id i51ls1300683qge.20.gmail; Fri, 15 Aug 2014 04:05:10 -0700 (PDT) X-Received: by 10.229.212.138 with SMTP id gs10mr1142461qcb.7.1408100710503; Fri, 15 Aug 2014 04:05:10 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id p2si11332899qcp.36.2014.08.15.04.05.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 15 Aug 2014 04:05:10 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id la4so2753378vcb.37 for ; Fri, 15 Aug 2014 04:05:10 -0700 (PDT) X-Received: by 10.53.12.225 with SMTP id et1mr12874621vdd.5.1408100710248; Fri, 15 Aug 2014 04:05:10 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp104114vcb; Fri, 15 Aug 2014 04:05:09 -0700 (PDT) X-Received: by 10.140.102.162 with SMTP id w31mr24730778qge.67.1408100709668; Fri, 15 Aug 2014 04:05:09 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id l9si11317710qac.103.2014.08.15.04.05.09 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 15 Aug 2014 04:05:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:58552 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIFJl-0001EH-47 for patch@linaro.org; Fri, 15 Aug 2014 07:05:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39373) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIFGb-0004wy-KU for qemu-devel@nongnu.org; Fri, 15 Aug 2014 07:02:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XIFGU-000722-M5 for qemu-devel@nongnu.org; Fri, 15 Aug 2014 07:01:53 -0400 Received: from [2001:4b98:dc0:45:216:3eff:fe3d:166f] (port=44496 helo=afflict.kos.to) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIFGU-00071S-Db for qemu-devel@nongnu.org; Fri, 15 Aug 2014 07:01:46 -0400 Received: from afflict.kos.to (afflict [92.243.29.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by afflict.kos.to (Postfix) with ESMTPSA id B87AA26595; Fri, 15 Aug 2014 13:01:44 +0200 (CEST) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Fri, 15 Aug 2014 14:01:27 +0300 Message-Id: X-Mailer: git-send-email 1.7.10.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 2001:4b98:dc0:45:216:3eff:fe3d:166f Cc: Peter Maydell , Riku Voipio Subject: [Qemu-devel] [PULL 09/24] linux-user: support {name_to, open_by}_handle_at syscalls X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: riku.voipio@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Riku Voipio Implement support for the name_to_handle_at and open_by_handle_at syscalls, allowing their use by the target program. Modified by Riku - move syscalls to functions and put behind the already existing CONFIG_OPEN_BY_HANDLE to avoid build failure with old glibc's. Signed-off-by: Paul Burton Signed-off-by: Riku Voipio --- linux-user/strace.c | 30 ++++++++++++++++++++++ linux-user/strace.list | 6 +++++ linux-user/syscall.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+) diff --git a/linux-user/strace.c b/linux-user/strace.c index ea6c1d2..c20ddf1 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1552,6 +1552,36 @@ print_kill(const struct syscallname *name, } #endif +#ifdef TARGET_NR_name_to_handle_at +static void +print_name_to_handle_at(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_at_dirfd(arg0, 0); + print_string(arg1, 0); + print_pointer(arg2, 0); + print_pointer(arg3, 0); + print_raw_param("0x%x", arg4, 1); + print_syscall_epilogue(name); +} +#endif + +#ifdef TARGET_NR_open_by_handle_at +static void +print_open_by_handle_at(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_raw_param("%d", arg0, 0); + print_pointer(arg2, 0); + print_open_flags(arg3, 1); + print_syscall_epilogue(name); +} +#endif + /* * An array of all of the syscalls we know about */ diff --git a/linux-user/strace.list b/linux-user/strace.list index 8de972a..147f579 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -582,6 +582,9 @@ #ifdef TARGET_NR_munmap { TARGET_NR_munmap, "munmap" , NULL, print_munmap, NULL }, #endif +#ifdef TARGET_NR_name_to_handle_at +{ TARGET_NR_name_to_handle_at, "name_to_handle_at" , NULL, print_name_to_handle_at, NULL }, +#endif #ifdef TARGET_NR_nanosleep { TARGET_NR_nanosleep, "nanosleep" , NULL, NULL, NULL }, #endif @@ -624,6 +627,9 @@ #ifdef TARGET_NR_openat { TARGET_NR_openat, "openat" , NULL, print_openat, NULL }, #endif +#ifdef TARGET_NR_open_by_handle_at +{ TARGET_NR_open_by_handle_at, "open_by_handle_at" , NULL, print_open_by_handle_at, NULL }, +#endif #ifdef TARGET_NR_osf_adjtime { TARGET_NR_osf_adjtime, "osf_adjtime" , NULL, NULL, NULL }, #endif diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f1c182b..74c5d49 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5362,6 +5362,66 @@ static int do_openat(void *cpu_env, int dirfd, const char *pathname, int flags, return get_errno(sys_openat(dirfd, path(pathname), flags, mode)); } +#if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) +static abi_long do_name_to_handle_at(abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + struct file_handle *fh; + uint32_t sz; + int mount_id; + abi_long ret; + char *p; + + if (get_user_u32(sz, arg3)) { + return -TARGET_EFAULT; + } + + p = lock_user_string(arg2); + if (!p) { + return -TARGET_EFAULT; + } + + fh = lock_user(VERIFY_WRITE, arg3, sizeof(*fh) + sz, 1); + if (!fh) { + unlock_user(p, arg2, 0); + return -TARGET_EFAULT; + } + + ret = get_errno(name_to_handle_at(arg1, path(p), fh, &mount_id, arg5)); + unlock_user(p, arg2, 0); + unlock_user(p, arg3, sizeof(*fh) + sz); + + if (put_user_s32(mount_id, arg4)) { + 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 arg1, abi_long arg2, abi_long arg3) +{ + struct file_handle *fh; + uint32_t sz; + abi_long ret; + char *p; + + if (get_user_u32(sz, arg2)) { + return -TARGET_EFAULT; + } + + fh = lock_user(VERIFY_WRITE, arg2, sizeof(*fh) + sz, 1); + if (!fh) { + return -TARGET_EFAULT; + } + + ret = get_errno(open_by_handle_at(arg1, fh, + target_to_host_bitmask(arg3, fcntl_flags_tbl))); + + unlock_user(p, arg2, sizeof(*fh) + sz); + return ret; +} +#endif /* do_syscall() should always have a single exit point at the end so that actions, such as logging of syscall results, can be performed. @@ -5448,6 +5508,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, arg4)); unlock_user(p, arg2, 0); break; +#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); + break; +#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); + break; +#endif case TARGET_NR_close: ret = get_errno(close(arg1)); break;