From patchwork Fri Jun 1 07:30:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 137469 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp609592lji; Fri, 1 Jun 2018 00:39:28 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI1g+2EtsIHQF84AF3SMGSc2r6BJe3hvE+LNEvhm6Ek+TXCc3WJeKu5vS3Are1Om0x6RPg4 X-Received: by 2002:ac8:5293:: with SMTP id s19-v6mr9443421qtn.311.1527838768529; Fri, 01 Jun 2018 00:39:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527838768; cv=none; d=google.com; s=arc-20160816; b=Rm6a2SF8H13GZA6lTtSOYsENWQY0WsziD1iBlkDjrZenpiQ2g+b1x4VW0dKfthefkx PPzwpgLKUirik54Sy/qtgcBCRR9ohm65tH9CbHUNSWLUC5tIPFkm7Wf9LP4zMa6NJRay SuuEEnMdnvCnAWsC7J7kK5KyZsDL9rTDU/zCjftUEYW+qgrUFQcq6oGbOJLLE1N153VZ qK0qlFyMs80NZkfTTNfHQZNveP5fWV48wqTeSzQ9PlU4thf65Ll+AYbQeMS2oqOO8HTb ahL87muVLzLegtfi6txZ0Ai8gfwl2eaaGNpNoOQ6WYWPdLgr7jgh+yT3VIarXM7FDUfp H0rA== 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=kk3pbw60RM5oFWEwEGqSGPVEZ2Ll5xAazQA92/YvOx8=; b=Mm6ZIuEHoLphcIoXCakIeDGlxsJd6H1PB4d1b8A/nEEq4vVDwaey2bJO/9cKue0jEx e7VuoWIwBCcyS9vYFp+lvvjr2iGTQlQWE0iXjrCdSqOorFz60HQzNsS94oyYI+OB7n5k PS9br3aTJWKcmzBpYqPfpSqWzc1Wcd0SWgFlKzAjWfvB1EtSXUHvuD3I7nrlTLR7/1B3 RmGYHs22dADt2+jaDpw2DVjIeCQ9O1cj89t/BmcTOwL5ePi3YWzVpKq/XLkm7FsSDKx+ 3+EIs9XE1IwLyj9bj2t+lKtDJZ86eFd3LCMejaiYl2j02iQ/daJg9M4+PBFm9j2BeOdn hWAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XbVZmEon; 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 t3-v6si7293097qvl.124.2018.06.01.00.39.28 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Jun 2018 00:39:28 -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=XbVZmEon; 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]:47847 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeem-0002sI-0v for patch@linaro.org; Fri, 01 Jun 2018 03:39:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57471) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOeWo-0005XT-LM for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fOeWn-0000Sw-IK for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:14 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:35167) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fOeWn-0000S5-AJ for qemu-devel@nongnu.org; Fri, 01 Jun 2018 03:31:13 -0400 Received: by mail-pg0-x243.google.com with SMTP id 15-v6so10552560pge.2 for ; Fri, 01 Jun 2018 00:31:13 -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=kk3pbw60RM5oFWEwEGqSGPVEZ2Ll5xAazQA92/YvOx8=; b=XbVZmEoncRsNgTCILcWriOyY2MMIIPfKj2eCR1lDK/TjAeMo1/l10gemDoEpYNg1VG 1YxkGZzqRBmUOIF+mlOYgHN6H6CD/6BxJVFAPgTtXrRteh7uysDRnEe8RmG2PIUpy1ef GJs0qc62512LDolTZKgiNE1CLMQmUZIUPpKW0= 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=kk3pbw60RM5oFWEwEGqSGPVEZ2Ll5xAazQA92/YvOx8=; b=OadaoteZv5aXKwPrdoa58keNDVJkgjw84QzIL377PwVrbNdKzOPHNSIKQdO4YB2k1b EFBcNFnhI+toY1TYAt5XKeVBCnlydmT6rDl1rQ3P33f8WqvuieTsdDAi0u85BHUQAGEW VrW34DRBH8c2Y/N1/DcSI9nx5ZThpHqnk7vzyNVeYa0RVEyJTaOxo0Dvm+isd0HfNJoE GIQCHotmy40nwOIybOkAZxao2AFj9nGIqdg1RSDfjSE+LtIrHhcMG8CYDFMMqlFKu4N0 9le1+YUklJhow2mOlHOuF7opekX3XUgmY06u0QmWAMHYx/OmpzMpe1QHkhzid4B59G2o CnDg== X-Gm-Message-State: ALKqPweLur8sOp2IIIIpPh0Rm0UMEyA8KJPP8pg4X8nh0dJ9DjQTgL64 dBzSzJf/CMQK3M0L1X4kKfyLb7Lu+4Y= X-Received: by 2002:a63:a557:: with SMTP id r23-v6mr7994953pgu.336.1527838271987; Fri, 01 Jun 2018 00:31:11 -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.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Jun 2018 00:31:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 1 Jun 2018 00:30:30 -0700 Message-Id: <20180601073050.8054-14-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::243 Subject: [Qemu-devel] [PATCH 13/33] 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. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 129 +++++++++++++++++++++---------------------- 1 file changed, 64 insertions(+), 65 deletions(-) -- 2.17.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index fb1a8a4e7e..4afc22c20c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7369,63 +7369,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; - - TRY_INTERP_FD(ret, name, - name_to_handle_at(interp_dirfd, name + 1, fh, &mid, flags), - name_to_handle_at(dirfd, name, fh, &mid, flags)); - ret = get_errno(ret); - 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, abi_long flags) @@ -8145,6 +8088,67 @@ IMPL(exit) g_assert_not_reached(); } +#if defined(TARGET_NR_name_to_handle_at) && defined(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 (is_hostfd(dirfd)) { + return -TARGET_EBADF; + } + 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; + + TRY_INTERP_FD(ret, name, + name_to_handle_at(interp_dirfd, name + 1, fh, &mid, flags), + name_to_handle_at(dirfd, name, fh, &mid, flags)); + ret = get_errno(ret); + 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) { @@ -8248,14 +8252,6 @@ IMPL(everything_else) char *fn; switch(num) { -#if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) - case TARGET_NR_name_to_handle_at: - if (is_hostfd(arg1)) { - return -TARGET_EBADF; - } - 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: if (is_hostfd(arg1)) { @@ -12941,6 +12937,9 @@ static impl_fn * const syscall_table[] = { [TARGET_NR_close] = impl_close, [TARGET_NR_execve] = impl_execve, [TARGET_NR_exit] = impl_exit, +#if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) + [TARGET_NR_name_to_handle_at] = impl_name_to_handle_at, +#endif #ifdef TARGET_NR_open [TARGET_NR_open] = impl_open, #endif