From patchwork Fri Jun 1 07:30:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 137477 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp614904lji; Fri, 1 Jun 2018 00:46:40 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJvoWRzAY10Sawr/FV9I9D2RurWIhUotVckU/LIBY7oaxh57VTxNSW0vEU0mN4SSSfMdYHq X-Received: by 2002:a37:cbc8:: with SMTP id u69-v6mr9342674qkl.242.1527839200257; Fri, 01 Jun 2018 00:46:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527839200; cv=none; d=google.com; s=arc-20160816; b=wC9x27D6lHk+0evT36r5q+BwRD0iPFtVDdNt6DOg7rgHNA1FpN6NIhl7UitYFFv7zL 6hSAFmu+YAZBTQR+PYLcWWHYC/oFGa84+17gWVbKMKnvAC1YTo1+W7nqerCn/GTT7MsU 2Jpzxb5LxJiJ3dM1WbTNP0puANWwNDHmxCtHAVTMJIzvMXhRj6+ZK0O8R6BukH/4279Y WYYVNVGoHn3gTZ9qe4MYlwVDu+21Og4EupPlI0YkhU3hZfqNqgFv80czZ11I7g5BkVwa l+iVNKN9qk6qdJbCG08Wi6GJVgTxGZtiTyLt5MN9+oht5BX+FBL1Gv9oKtJsso38UpTR ab7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=tC4DvAB14lOIqJsL1xleYuXscQUSfYhJROofvlBpgL4=; b=MN4f18IWP45TBQPcvFGitDvRGwjetrveH2TWA6ZPP7cCaJKvUB7mtciEU3c+abW9QJ xJJPYYpU9URHs+7LK0MkdZDZkFDcvkeV27zYFckqdIi0Dm/P4YJBGEitOumd2LxM2nst dLmG+dBsmsoHRwpQNaMHB9BfY35RCxtxEcGr9i9NvoeqN7JFaJ72tIAMsIgEYTU+Wj55 PgIivBF6nEuff581BnQ28WIFFzH74/86uZJPl7ZpkW63qgVOHSyimjD7NbeNCO9HSakO RdTOftCyMMLygOSXjIZxGKcF2uKu1NEuMp7y/B7LEqha2hVn3YwjJ1I46GJnWBa2FB1E b2HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Az+jrVuo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 17-v6si6123033qkq.37.2018.06.01.00.46.40 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:46:40 -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; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Az+jrVuo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47890 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOelh-0008CN-U5 for patch@linaro.org; Fri, 01 Jun 2018 03:46:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57503) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeWs-0005a5-Mt for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWo-0000U0-Vz for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:18 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:35167) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWo-0000TL-PE for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:14 -0400 Received: by mail-pg0-x242.google.com with SMTP id 15-v6so10552596pge.2 for ; Fri, 01 Jun 2018 00:31:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tC4DvAB14lOIqJsL1xleYuXscQUSfYhJROofvlBpgL4=; b=Az+jrVuo/ifL+QonxFPHxGp+Wms1EY5W+TY9x9yiwR2FPa7+JlO1enAfyVF3/Cl08S M+sGaJCvGyfzN/5R8QD+kznfBdsRhJJK8ukX1p8IQ/wqvIjUIxCjAWigpAnE7KsNOaUz EFZzdomra3nOcep2SczqiRYpKJeRyArZvfa9k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tC4DvAB14lOIqJsL1xleYuXscQUSfYhJROofvlBpgL4=; b=CA5wvv5dxhGphQB2TC+MUGYm2kt6hogj8MEI7rByprk0k9w4u/XeXQCpOFEesBWqh3 HL3hrssm1nxTxhjKzlj7ZldhcIfnHrLQf6iFu+xXh7nqBh4XURhaDLnEOWc9w66TfRIx aYuolTNVzvcxrSMRhSL1s2jDxa3c6NKe/RYojDVxUWpPGWNmUxPu/KG1WPxI0e2JNPAc sBMemCoP3xBO+HrwxN6lXR78FfOjjwscNBCNuetHYWe95oF0mIhMGVx+cHBFzLdrNn6w c3TZcwcWU+Ppwxa1MDUbg09iU+bvkEUP79Yuqru358BrlyZ5eh4+lcUjpGd2B/TaoX/n GBPQ== X-Gm-Message-State: ALKqPwfqPQR+IDv9qiitNq32CvTTZWyhPdH5cNAL6qA9SEo/yz5H7WXt 4eQVB0Tz766LAqn2eCzk85cdncTj/mw= X-Received: by 2002:a63:a00a:: with SMTP id r10-v6mr8078620pge.222.1527838273488; Fri, 01 Jun 2018 00:31:13 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id c4-v6sm4431782pgv.86.2018.06.01.00.31.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:31 -0700 Message-Id: <20180601073050.8054-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601073050.8054-1-richard.henderson@linaro.org> References: <20180601073050.8054-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::242 Subject: [Qemu-devel] [PATCH 14/33] linux-user: Split out open_to_handle_at X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" At the same time, merge do_open_to_handle_at into the new function. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 84 ++++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 42 deletions(-) -- 2.17.0 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, };