From patchwork Mon Jun 23 13:26:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 32361 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f71.google.com (mail-pa0-f71.google.com [209.85.220.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E364320540 for ; Mon, 23 Jun 2014 13:34:43 +0000 (UTC) Received: by mail-pa0-f71.google.com with SMTP id eu11sf26725674pac.2 for ; Mon, 23 Jun 2014 06:34:43 -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=saPd7ixvC9mAigWeEa+LP91nb0zKvD02MkFC++R+W4I=; b=gsncpG7B16HFLTp3VSI7xrxmmpmHMInj5cf7jbzQGb2EUl+ijwD2wL81ovrC8C4HVp tlcBAll3cECHRkdSCVO0hIy7AUWyKFhhoZ4lXaqcuDnon0AkkxuMIk/5dMi0bef+0suq 43Lpp3O30+O/KSQjJRCxSojDIc5f1/D7uP3qLmKLrWyeuPaCAgSq9oC/keGBY8JRs47C zy0oAo6lQxQw+Lwo1Y8YXV4DsMxo9g+CaCAEL12ZKU8FlolEl7eCP2f2F7FndycfAK3B BAu8P7GPdbHNegrn/aJhpAKkGmraapGAv5cBtYkyQyeiu09vU4BGBqft1VEmK4l4brbO IZxw== X-Gm-Message-State: ALoCoQlnbsriUvFOpef3ygPas3P2Jm+h7Cse7eikwN+QlZvJl227b4RcHMnN24DJ8oZdlEI6MO6U X-Received: by 10.66.164.167 with SMTP id yr7mr9453241pab.15.1403530483252; Mon, 23 Jun 2014 06:34:43 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.49.193 with SMTP id q59ls1168225qga.91.gmail; Mon, 23 Jun 2014 06:34:43 -0700 (PDT) X-Received: by 10.221.68.135 with SMTP id xy7mr484636vcb.65.1403530483148; Mon, 23 Jun 2014 06:34:43 -0700 (PDT) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id py4si8997246vcb.49.2014.06.23.06.34.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 23 Jun 2014 06:34:43 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.173 as permitted sender) client-ip=209.85.128.173; Received: by mail-ve0-f173.google.com with SMTP id db11so6135780veb.18 for ; Mon, 23 Jun 2014 06:34:43 -0700 (PDT) X-Received: by 10.52.88.44 with SMTP id bd12mr399525vdb.86.1403530483062; Mon, 23 Jun 2014 06:34:43 -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 tc5csp131157vcb; Mon, 23 Jun 2014 06:34:42 -0700 (PDT) X-Received: by 10.224.137.193 with SMTP id x1mr33311978qat.0.1403530482580; Mon, 23 Jun 2014 06:34:42 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id mg8si22461517qcb.30.2014.06.23.06.34.42 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 23 Jun 2014 06:34:42 -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]:53564 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wz4OQ-0005gP-6d for patch@linaro.org; Mon, 23 Jun 2014 09:34:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55703) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wz4Gn-0003iU-Lx for qemu-devel@nongnu.org; Mon, 23 Jun 2014 09:26:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wz4Ge-0001CU-Eh for qemu-devel@nongnu.org; Mon, 23 Jun 2014 09:26:49 -0400 Received: from afflict.kos.to ([92.243.29.197]:50469) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wz4Ge-0001Bt-1X for qemu-devel@nongnu.org; Mon, 23 Jun 2014 09:26:40 -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 A187C265B0; Mon, 23 Jun 2014 15:26:36 +0200 (CEST) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Mon, 23 Jun 2014 16:26:30 +0300 Message-Id: <2532e672a1a29dbc23fc52a5d6b8dc3fc29df846.1403529801.git.riku.voipio@linaro.org> 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: 92.243.29.197 Cc: Paul Burton Subject: [Qemu-devel] [PULL 15/19] 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.128.173 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: Paul Burton Implement support for the name_to_handle_at and open_by_handle_at syscalls, allowing their use by the target program. Signed-off-by: Paul Burton Signed-off-by: Riku Voipio --- linux-user/strace.c | 30 ++++++++++++++++++++++++++ linux-user/strace.list | 6 ++++++ linux-user/syscall.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 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 c70b3b0..3fd0974 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5399,6 +5399,63 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, unlock_user(p, arg2, 0); break; #endif +#ifdef TARGET_NR_name_to_handle_at + case TARGET_NR_name_to_handle_at: + { + struct file_handle *fh; + uint32_t sz; + int mount_id; + + p = lock_user_string(arg2); + if (!p) { + goto efault; + } + + if (get_user_u32(sz, arg3)) { + unlock_user(p, arg2, 0); + goto efault; + } + + fh = lock_user(VERIFY_WRITE, arg3, sizeof(*fh) + sz, 1); + if (!fh) { + unlock_user(p, arg2, 0); + goto 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)) { + goto efault; + } + } + break; +#endif +#ifdef TARGET_NR_open_by_handle_at + case TARGET_NR_open_by_handle_at: + { + struct file_handle *fh; + uint32_t sz; + + if (get_user_u32(sz, arg2)) { + goto efault; + } + + fh = lock_user(VERIFY_WRITE, arg2, sizeof(*fh) + sz, 1); + if (!fh) { + goto 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); + } + break; +#endif case TARGET_NR_close: ret = get_errno(close(arg1)); break;