From nobody Tue Feb 10 11:15:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15278388637371020.2119045828514; Fri, 1 Jun 2018 00:41:03 -0700 (PDT) Received: from localhost ([::1]:47856 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fOegI-00049y-Gn for importer@patchew.org; Fri, 01 Jun 2018 03:41:02 -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) 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) 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-Google-Smtp-Source: ADUXVKInIJlGwlzgCz8OLoFieHfi49XOon4EYi8LTcWZguJFgFmjqK4aqqYC+9c9rKG00pQRRvFdVg== X-Received: by 2002:a63:a557:: with SMTP id r23-v6mr7994953pgu.336.1527838271987; Fri, 01 Jun 2018 00:31:11 -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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(-) 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 =3D 0; - abi_long ret; - char *name; - unsigned int size, total_size; - - if (get_user_s32(size, handle)) { - return -TARGET_EFAULT; - } - - name =3D lock_user_string(pathname); - if (!name) { - return -TARGET_EFAULT; - } - - total_size =3D sizeof(struct file_handle) + size; - target_fh =3D lock_user(VERIFY_WRITE, handle, total_size, 0); - if (!target_fh) { - unlock_user(name, pathname, 0); - return -TARGET_EFAULT; - } - - fh =3D g_malloc0(total_size); - fh->handle_bytes =3D size; - - TRY_INTERP_FD(ret, name, - name_to_handle_at(interp_dirfd, name + 1, fh, &mid, flag= s), - name_to_handle_at(dirfd, name, fh, &mid, flags)); - ret =3D 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 tre= at - * the file_handle structure as an opaque data type - */ - - memcpy(target_fh, fh, total_size); - target_fh->handle_bytes =3D tswap32(fh->handle_bytes); - target_fh->handle_type =3D 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(); } =20 +#if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) +IMPL(name_to_handle_at) +{ + abi_long dirfd =3D arg1; + abi_long pathname =3D arg2; + abi_long handle =3D arg3; + abi_long mount_id =3D arg4; + abi_long flags =3D arg5; + struct file_handle *target_fh; + struct file_handle *fh; + int mid =3D 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 =3D lock_user_string(pathname); + if (!name) { + return -TARGET_EFAULT; + } + + total_size =3D sizeof(struct file_handle) + size; + target_fh =3D lock_user(VERIFY_WRITE, handle, total_size, 0); + if (!target_fh) { + unlock_user(name, pathname, 0); + return -TARGET_EFAULT; + } + + fh =3D g_malloc0(total_size); + fh->handle_bytes =3D size; + + TRY_INTERP_FD(ret, name, + name_to_handle_at(interp_dirfd, name + 1, fh, &mid, flag= s), + name_to_handle_at(dirfd, name, fh, &mid, flags)); + ret =3D 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 tre= at + * the file_handle structure as an opaque data type + */ + + memcpy(target_fh, fh, total_size); + target_fh->handle_bytes =3D tswap32(fh->handle_bytes); + target_fh->handle_type =3D 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; =20 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 =3D 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[] =3D { [TARGET_NR_close] =3D impl_close, [TARGET_NR_execve] =3D impl_execve, [TARGET_NR_exit] =3D impl_exit, +#if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE) + [TARGET_NR_name_to_handle_at] =3D impl_name_to_handle_at, +#endif #ifdef TARGET_NR_open [TARGET_NR_open] =3D impl_open, #endif --=20 2.17.0