From patchwork Sun Jun 10 03:00:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138084 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2577795lji; Sat, 9 Jun 2018 20:09:49 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJzGe0QSGC0FWS44PKbTAuG2AKF3Y3eaWCPoJl8jNx9Lofu5QDFSh3xng//l1vhm77tmtAo X-Received: by 2002:aed:278d:: with SMTP id a13-v6mr11617843qtd.120.1528600189156; Sat, 09 Jun 2018 20:09:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528600189; cv=none; d=google.com; s=arc-20160816; b=JIn8sI+anB20qXr4dnnRemjl01cPwykayuEmE0USdM4w8W1sbmdD+mtJLAKDNwivyc gQi1+PV4HzZY/Oy+NyfWGmePtdPVSLzIozS0Ivp1jvF5BmS1UfelJZRqD2V5gNcSDWGh Yv8fCZSdzcrB1EhYeZVHNPd63c3x8jweT6nE0KpOKPXQ38UE6demWSgcZ5aLUaJgF3aE h3PVKtHWPO2UqC6O9UWt5Px+BVksT9wOHY6qnceRgsFgL2Dk6yYfPMSx5C//jYfQlLmL puJSklphSznCE2fhMcAxH7nHk7D2Tkk//ivfH3k/fomxFdSEBuL2eze3VHBO3Y6mRVmb nyYQ== 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=bIHc7CP3Y4XNh28bNwqPY50RUSkra0Ou1jU0DnfeGgc=; b=DypjylAa8uLQwql8mji713eXPCQpkBvVR2LtpUXdOvIJK/Lmk44SdhUkDyH8tz3yEf b3xFQK0v+JZwmKvV3+0GYL+2+V8COG8s3ZHdxlRaPLHuHK0+yDwJN1bfoWvrzA6SZY64 jkjtctv0TZIOnn3dH6/xS9X4RBJZM+H+nyuJ0rOdOSHEndvP0DT2Mx1vm6aK5NvzdVa/ 4P2rk3YkZt0Oozq+bjmtHqkbOwxZj4CRxY2tcuPBph2kq0TDxmCvdtqfrbE/fr4zLF9i TKqUocZWquDQEqiuJhqKr6WJowcMPPUdw59mmAiSTD0dorUIE9dc2T/SYYTTuJDSNlhi 7iQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=C5btyMAI; 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 i188-v6si2629828qka.144.2018.06.09.20.09.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:09:49 -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=C5btyMAI; 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]:42205 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqjk-0007qp-J5 for patch@linaro.org; Sat, 09 Jun 2018 23:09:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40198) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqd6-0001pp-5n for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqd5-0003FA-59 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:56 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:45641) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqd4-0003Eo-T4 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:55 -0400 Received: by mail-pf0-x244.google.com with SMTP id a22-v6so8479202pfo.12 for ; Sat, 09 Jun 2018 20:02:54 -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=bIHc7CP3Y4XNh28bNwqPY50RUSkra0Ou1jU0DnfeGgc=; b=C5btyMAILgN/wc8N5kvZuXl7yF7g3tu5O8tTOfFngt/c9GcKKJFlFubzz4OoA4yOiC PmK8eOuM8XiAiP6gZouq62/Pdc+L2PKA3EPYF+HpF+aW0c2frV+QYMs7cHxNv5+wF6OX GSftNWUrE7jpc5x/Ds10dvvgz0bpkV4VfI4zk= 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=bIHc7CP3Y4XNh28bNwqPY50RUSkra0Ou1jU0DnfeGgc=; b=kvrMMM6/9RkA3qimt9l+SVzoXOvBugl9KUrDc7bVuUW+aud8y1Xqb0WK2EtMVJmJPj GCVB7gUpm4vfovSkRqm3mV3B7QR7Ps9Q9gKXJ5ihs50DZsmJEmYDcY6K36XqM6O86YFo glQgFcFV7Fq702sIaNYaiB9SVFo1HHSiHQAKcqqWX2/Gh7IUv3RMohrEcUSZKtYXzfj4 a7mCAqaHd/mmq7RCMwr7EThrZ2Xn/D/gZiTONDbboSPtl3Kn6a7K2nn29r9XhuIyozNN IeAsPzDHUhh05WVRhqf44FY/HKpedrv5MqsiLs3sPYuiGKEP6vU+gp0xN+1PyvjCofSM 3avQ== X-Gm-Message-State: APt69E0t/T2VdiZ4JWGLNmA3YRKxxDxGkO0unyH+nCxvtuq804ciMi0g lL/6r05tKFxAu2SlfZMvjrJfClw1b3U= X-Received: by 2002:a62:e117:: with SMTP id q23-v6mr12249395pfh.75.1528599773634; Sat, 09 Jun 2018 20:02:53 -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.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:02:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:45 -1000 Message-Id: <20180610030220.3777-14-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::244 Subject: [Qemu-devel] [PATCH v2 013/108] linux-user: Split out name_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_name_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 | 116 +++++++++++++++++++++---------------------- 1 file changed, 58 insertions(+), 58 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a4d0f2720f..90341f4254 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7361,59 +7361,6 @@ static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout, return -TARGET_ENOSYS; } } -#if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) -static abi_long do_name_to_handle_at(abi_long dirfd, abi_long pathname, - abi_long handle, abi_long mount_id, - abi_long flags) -{ - struct file_handle *target_fh; - struct file_handle *fh; - int mid = 0; - abi_long ret; - char *name; - unsigned int size, total_size; - - if (get_user_s32(size, handle)) { - return -TARGET_EFAULT; - } - - name = lock_user_string(pathname); - if (!name) { - return -TARGET_EFAULT; - } - - total_size = sizeof(struct file_handle) + size; - target_fh = lock_user(VERIFY_WRITE, handle, total_size, 0); - if (!target_fh) { - unlock_user(name, pathname, 0); - return -TARGET_EFAULT; - } - - fh = g_malloc0(total_size); - fh->handle_bytes = size; - - ret = get_errno(name_to_handle_at(dirfd, path(name), fh, &mid, flags)); - unlock_user(name, pathname, 0); - - /* man name_to_handle_at(2): - * Other than the use of the handle_bytes field, the caller should treat - * the file_handle structure as an opaque data type - */ - - memcpy(target_fh, fh, total_size); - target_fh->handle_bytes = tswap32(fh->handle_bytes); - target_fh->handle_type = tswap32(fh->handle_type); - g_free(fh); - unlock_user(target_fh, handle, total_size); - - if (put_user_s32(mid, mount_id)) { - 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 mount_fd, abi_long handle, @@ -8116,6 +8063,61 @@ IMPL(exit) g_assert_not_reached(); } +#ifdef CONFIG_OPEN_BY_HANDLE +IMPL(name_to_handle_at) +{ + abi_long dirfd = arg1; + abi_long pathname = arg2; + abi_long handle = arg3; + abi_long mount_id = arg4; + abi_long flags = arg5; + struct file_handle *target_fh; + struct file_handle *fh; + int mid = 0; + abi_long ret; + char *name; + unsigned int size, total_size; + + if (get_user_s32(size, handle)) { + return -TARGET_EFAULT; + } + + name = lock_user_string(pathname); + if (!name) { + return -TARGET_EFAULT; + } + + total_size = sizeof(struct file_handle) + size; + target_fh = lock_user(VERIFY_WRITE, handle, total_size, 0); + if (!target_fh) { + unlock_user(name, pathname, 0); + return -TARGET_EFAULT; + } + + fh = g_malloc0(total_size); + fh->handle_bytes = size; + + ret = get_errno(name_to_handle_at(dirfd, path(name), fh, &mid, flags)); + unlock_user(name, pathname, 0); + + /* man name_to_handle_at(2): + * Other than the use of the handle_bytes field, the caller should treat + * the file_handle structure as an opaque data type + */ + + memcpy(target_fh, fh, total_size); + target_fh->handle_bytes = tswap32(fh->handle_bytes); + target_fh->handle_type = tswap32(fh->handle_type); + g_free(fh); + unlock_user(target_fh, handle, total_size); + + if (put_user_s32(mid, mount_id)) { + return -TARGET_EFAULT; + } + return ret; +} +#endif + #ifdef TARGET_NR_open IMPL(open) { @@ -8211,11 +8213,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#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); - return ret; -#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); @@ -12491,6 +12488,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(close); SYSCALL(execve); SYSCALL(exit); +#ifdef CONFIG_OPEN_BY_HANDLE + SYSCALL(name_to_handle_at); +#endif #ifdef TARGET_NR_open SYSCALL(open); #endif