From patchwork Sun Jun 10 03:00:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138087 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2578724lji; Sat, 9 Jun 2018 20:11:33 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKjMQsmQ2uIVWuNw3LCvl6H2Alm7LA8PfkTl74tAWcQYn9/mF5JIWL1mU9iamrcL+wKbOl5 X-Received: by 2002:a0c:997b:: with SMTP id i56-v6mr11007518qvd.122.1528600293428; Sat, 09 Jun 2018 20:11:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600293; cv=none; d=google.com; s=arc-20160816; b=jQtJi+V+9Aphwir9UK+fxenQxuRP/SC0VFQhzNFIKM/Cwgvp33fJyimPwLCf4xjOse ObUU3J7txFgKndBlcqYJW5Z8JK0DJM/Mxwpk1UnMFVeSbgodHbOLsDLkWijnxwvs7fWa 7yFdzOW23wz1zKAizP7/2cTVlzCZUjs9twQzdmcLXZbLa66Trk+LTZ+Er++xb3YNhDN7 BCKFbCUfJofhmo5zihNUxBn1g8VGRZ5bEyYW/LCZxSIq5VSuEIMSW0bAKm2iIOS47joe jccEGTBOumsMLCkk2cpX0U+I3kFjas3+AHJiRPu9U/KD+2DFBsit7bQvn9duYhPUVLdd N5DA== 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=EZGrOUeL2270UIqGs54DWaac5GI5eD4C8UaLdVxq94M=; b=Q4obBuihNv6UzDhFzZo2sD6m5HdCkTlzCQ5OzwOP1Ae2Xt4X0wIaePbfwc1yACXqJX UoDsf0XtTnrS6cv5PNjUk/uMAU4ZQqtzVXPLsZaOb5ZUlLZb/2TGkcK2lnLU/HmmKWXI /MW+I+3Srf+NgOCuARwU6kzk3hW4vT4fPuAf2304CpJSU/eLWAqkPtbMHhpg0qqgWOyp 5vXJr2Yvhy7GVnEXI5nFcDB/MqzZjBpQWb9SdsaCCDNvUnxM1BpT6S833kRYb9NgNda9 KAcvv5YMV759EszWS7kjpOGbSoVhk8EZnF50h6thYCzgBHynrnLFlvsuM/pyceawxc7H Boyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Cnrj15P5; 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 f2-v6si84180qta.209.2018.06.09.20.11.33 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:11:33 -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=Cnrj15P5; 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]:42220 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqlQ-0000zl-Pp for patch@linaro.org; Sat, 09 Jun 2018 23:11:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40220) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqd9-0001t2-Ea for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqd6-0003Fw-Nm for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:59 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:37244) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqd6-0003FU-IX for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:56 -0400 Received: by mail-pf0-x243.google.com with SMTP id y5-v6so7582990pfn.4 for ; Sat, 09 Jun 2018 20:02:56 -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=EZGrOUeL2270UIqGs54DWaac5GI5eD4C8UaLdVxq94M=; b=Cnrj15P5+1/qa/W8hSdLaIRMXJUK4WTQopVnIT4fyfnak0uNua5w+AMulmOM2rnExc mlwB6SkfIR4l0mKombsBffKgnSzgD+0kXZ4qmaR09os7ws5L/N+S3py5WRU/6QoARAmO Tcy3aWnDTWFBVcRfV3fjW1EVtVR2p1ncXb2IU= 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=EZGrOUeL2270UIqGs54DWaac5GI5eD4C8UaLdVxq94M=; b=DYpjrzL0fCjDkoSUVd0IuscE2cCUlSc90xWpt1Z4LFg9tTo6kfT8FpepBicVJDsTyF +8O0CGhi3qGoH8XQ0oUPfwoox7CIRrDYSVBoWl4TS0L4+7wZGbyuO1vl9TLVlcQ0kxjn uFIybMX56F+Nteeqm44SIsH2GR8uDG2/yaAYLGe8o6PU1HtzqArYNKgfo3PF3s9rJFMT ljn8DmMY/X9oM0RgjJJgfXcuE9oxpF/A1UtbqaNEoHA60TOFu6lu2+reiOIRcFlzEReX 77aesiNSHjzOJCqy8lNsu8iYU7mzTb8rW7axZzNPxFA4F81b2oa+aeolj8vmNlOgWBvx DLOA== X-Gm-Message-State: APt69E2FqYHWXBmmItEy7soCAhuPO9xuF1UwIvshkddcTEfeSVqRNeAY 9HoN73wZKxU+cORqVEG6VG+WEs4kIA4= X-Received: by 2002:a62:da59:: with SMTP id w25-v6mr12158258pfl.161.1528599775330; Sat, 09 Jun 2018 20:02:55 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.02.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:02:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:46 -1000 Message-Id: <20180610030220.3777-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-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:c00::243 Subject: [Qemu-devel] [PATCH v2 014/108] 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. All targets define this syscall; remove one of the two ifdefs. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 79 ++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 40 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 90341f4254..f51cc7e937 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7362,40 +7362,6 @@ static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout, } } -#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) /* signalfd siginfo conversion */ @@ -8152,6 +8118,42 @@ IMPL(openat) return ret; } +#ifdef 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 (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); + + flags = target_to_host_bitmask(flags, fcntl_flags_tbl); + ret = get_errno(open_by_handle_at(mount_fd, fh, flags)); + + g_free(fh); + unlock_user(target_fh, handle, total_size); + + fd_trans_unregister(ret); + return ret; +} +#endif + IMPL(read) { abi_long ret; @@ -8213,12 +8215,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#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); - 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)); @@ -12495,6 +12491,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(open); #endif SYSCALL(openat); +#ifdef CONFIG_OPEN_BY_HANDLE + SYSCALL(open_by_handle_at); +#endif SYSCALL(read); SYSCALL(write); }