From nobody Mon Nov 10 22:32:25 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.47; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1559908219; cv=none; d=zoho.com; s=zohoarc; b=JFsnzOUb4IK0cfgBHcKvfzvXu2/SxtBCDeQzHctEfD2tMfZ7+1v7NP1bthpP+M+aD5HuRAhi5IXv6kAZCuAGzyEeX1Cety2JD681hEudO1pVxtenKFEmnMWdnngTr+N046FzDb94yk7skktz8v2LkvlPHjFAhUVThzR5X0tgI6w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559908219; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=2KvmS6EHruJqD1zWQ25K3GvzUqn5hHI23YpJPqhoDNQ=; b=FiyvOPQ/zXX5s0Lu8UF2NvxZrBJuMFveDD9eJDnF9rit28TJMCUlJP7aRZTHw8KI6D0jlbSB86HJVKICWlX54YL6yfS+IO2Z0z5N66NCklozHjJ5iNFjJlMfp5C0La1q+tG2Oi5kXhpDfXLZC5lfqT0sdyGu34xnAvlgbRMFX5g= ARC-Authentication-Results: i=1; mx.zoho.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (209.51.188.47 [209.51.188.47]) by mx.zohomail.com with SMTPS id 1559908219954590.3084998509574; Fri, 7 Jun 2019 04:50:19 -0700 (PDT) Received: from localhost ([::1]:48832 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZDNk-00066J-If for importer@patchew.org; Fri, 07 Jun 2019 07:50:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39938) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZCE4-0001Am-0p for qemu-devel@nongnu.org; Fri, 07 Jun 2019 06:36:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZCE3-0001Kn-04 for qemu-devel@nongnu.org; Fri, 07 Jun 2019 06:35:59 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:41716 helo=mail.rt-rk.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hZCE2-0000B6-PY for qemu-devel@nongnu.org; Fri, 07 Jun 2019 06:35:58 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 0FBAF1A1CD1; Fri, 7 Jun 2019 12:35:43 +0200 (CEST) Received: from rtrkw774-lin.domain.local (rtrkw774-lin.domain.local [10.10.13.43]) by mail.rt-rk.com (Postfix) with ESMTPSA id DE26E1A1D97; Fri, 7 Jun 2019 12:35:42 +0200 (CEST) X-Virus-Scanned: amavisd-new at rt-rk.com From: Aleksandar Markovic To: qemu-devel@nongnu.org Date: Fri, 7 Jun 2019 12:35:17 +0200 Message-Id: <1559903719-7162-2-git-send-email-aleksandar.markovic@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1559903719-7162-1-git-send-email-aleksandar.markovic@rt-rk.com> References: <1559903719-7162-1-git-send-email-aleksandar.markovic@rt-rk.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 89.216.37.149 Subject: [Qemu-devel] [PATCH v10 1/3] linux-user: Add support for setsockopt() options IPV6__MEMBERSHIP X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, Neng Chen , amarkovic@wavecomp.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Neng Chen Add support for options IPV6_ADD_MEMBERSHIP and IPV6_DROP_MEMPEMBERSHIP of the syscall setsockopt(). These options control membership in multicast groups. Their argument is a pointer to a struct ipv6_mreq, which is in turn defined in IP v6 header netinet/in.h as: struct ipv6_mreq { /* IPv6 multicast address of group */ struct in6_addr ipv6mr_multiaddr; /* local IPv6 address of interface */ int ipv6mr_interface; }; ...whereas its definition in kernel's include/uapi/linux/in6.h is: #if __UAPI_DEF_IPV6_MREQ struct ipv6_mreq { /* IPv6 multicast address of group */ struct in6_addr ipv6mr_multiaddr; /* local IPv6 address of interface */ int ipv6mr_ifindex; }; #endif The first field of ipv6_mreq has the same name ("ipv6mr_multiaddr") and type ("in6_addr") in both cases. Moreover, the in6_addr structure consists of fields that are always big-endian (on host of any endian), therefore the ipv6_mreq's field ipv6mr_multiaddr doesn't need any endian conversion. The second field of ipv6_mreq may, however, depending on the build environment, have different names. This is the reason why the lines "#if __UAPI_DEF_IPV6_MREQ" and "#if defined(__UAPI_DEF_IPV6_MREQ)" are used in this patch - to establish the right choice for the field name. Also, endian conversion is needed for this field, since it is of type "int". Signed-off-by: Neng Chen Signed-off-by: Aleksandar Markovic --- linux-user/syscall.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 5e29e67..dde6889 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1921,6 +1921,33 @@ static abi_long do_setsockopt(int sockfd, int level,= int optname, &pki, sizeof(pki))); break; } + case IPV6_ADD_MEMBERSHIP: + case IPV6_DROP_MEMBERSHIP: + { + struct ipv6_mreq ipv6mreq; + + if (optlen < sizeof(ipv6mreq)) { + return -TARGET_EINVAL; + } + + if (copy_from_user(&ipv6mreq, optval_addr, sizeof(ipv6mreq))) { + return -TARGET_EFAULT; + } + +#if defined(__UAPI_DEF_IPV6_MREQ) +#if __UAPI_DEF_IPV6_MREQ + ipv6mreq.ipv6mr_ifindex =3D tswap32(ipv6mreq.ipv6mr_ifindex); +#else + ipv6mreq.ipv6mr_interface =3D tswap32(ipv6mreq.ipv6mr_interfac= e); +#endif /* __UAPI_DEF_IVP6_MREQ */ +#else + ipv6mreq.ipv6mr_interface =3D tswap32(ipv6mreq.ipv6mr_interfac= e); +#endif /* defined (__UAPI_DEF_IPV6_MREQ) */ + + ret =3D get_errno(setsockopt(sockfd, level, optname, + &ipv6mreq, sizeof(ipv6mreq))); + break; + } default: goto unimplemented; } --=20 2.7.4 From nobody Mon Nov 10 22:32:25 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.47 as permitted sender) client-ip=209.51.188.47; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.47 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1559907452; cv=none; d=zoho.com; s=zohoarc; b=OWljn9AfMd2jVbPxhnr2aU/Aixh1tXe4PeOk02g9s2unCgNAxsp5hBdmI/WzaC/WWXEMG0yMiUKnQDhMaqLuyjEqJ63/2KCAv8LtPPfxkG5L+vdwuY+ONfCPnOq1RvirULdA6KQz7foa0gUduVXmFKSrlza8lsVraK/vmdlnK1A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559907452; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=GIMeZ6bMRsF2R5xRdhq1mYff7LXEOP7cLVaV/15fAxw=; b=AeIX46ZmRV2CbYnihSy0XGyX+N6pNUaeAHOKjWIKrV6R/f853IcnwHIAeFY548DXr7dfnDp0bAG6qdpODJR8s2PA6sUr6O2jXRu2B5VOD6qGxZW/ubUb1HOEd73jfBHzxQlYnDljggUhDVkgr494L2bkdpb1PAT45xlQEUjmjmM= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.47 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (209.51.188.47 [209.51.188.47]) by mx.zohomail.com with SMTPS id 1559907452188228.58524558958436; Fri, 7 Jun 2019 04:37:32 -0700 (PDT) Received: from localhost ([::1]:48706 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZDBW-0006PS-1E for importer@patchew.org; Fri, 07 Jun 2019 07:37:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39917) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZCE2-000179-Pr for qemu-devel@nongnu.org; Fri, 07 Jun 2019 06:35:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZCE0-00015n-Jr for qemu-devel@nongnu.org; Fri, 07 Jun 2019 06:35:57 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:41784 helo=mail.rt-rk.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hZCDx-0000VN-In for qemu-devel@nongnu.org; Fri, 07 Jun 2019 06:35:54 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 92A211A1D0E; Fri, 7 Jun 2019 12:35:47 +0200 (CEST) Received: from rtrkw774-lin.domain.local (rtrkw774-lin.domain.local [10.10.13.43]) by mail.rt-rk.com (Postfix) with ESMTPSA id 78BEB1A1D0B; Fri, 7 Jun 2019 12:35:47 +0200 (CEST) X-Virus-Scanned: amavisd-new at rt-rk.com From: Aleksandar Markovic To: qemu-devel@nongnu.org Date: Fri, 7 Jun 2019 12:35:18 +0200 Message-Id: <1559903719-7162-3-git-send-email-aleksandar.markovic@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1559903719-7162-1-git-send-email-aleksandar.markovic@rt-rk.com> References: <1559903719-7162-1-git-send-email-aleksandar.markovic@rt-rk.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 89.216.37.149 Subject: [Qemu-devel] [PATCH v10 2/3] linux-user: Add support for setsockopt() option SOL_ALG X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, Yunqiang Su , amarkovic@wavecomp.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Yunqiang Su Add support for options SOL_ALG of the syscall setsockopt(). This option is used in relation to Linux kernel Crypto API, and allows a user to set additional information for the cipher operation via syscall setsockopt(). The field "optname" must be one of the following: - ALG_SET_KEY =E2=80=93 seting the key - ALG_SET_AEAD_AUTHSIZE =E2=80=93 set the authentication tag size SOL_ALG is relatively newer setsockopt() option. Therefore, the code that handles SOL_ALG is enclosed in "ifdef" so that the build does not fail for older kernels that do not contain support for SOL_ALG. "ifdef" also contains check if ALG_SET_KEY and ALG_SET_AEAD_AUTHSIZE are defined. Signed-off-by: Yunqiang Su Signed-off-by: Aleksandar Markovic Reviewed-by: Laurent Vivier --- linux-user/syscall.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index dde6889..82c08b6 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -103,6 +103,7 @@ #include #include #include +#include #include "linux_loop.h" #include "uname.h" =20 @@ -1998,6 +1999,36 @@ static abi_long do_setsockopt(int sockfd, int level,= int optname, goto unimplemented; } break; +#if defined(SOL_ALG) && defined(ALG_SET_KEY) && defined(ALG_SET_AEAD_AUTHS= IZE) + case SOL_ALG: + switch (optname) { + case ALG_SET_KEY: + { + char *alg_key =3D g_malloc(optlen); + + if (!alg_key) { + return -TARGET_ENOMEM; + } + if (copy_from_user(alg_key, optval_addr, optlen)) { + g_free(alg_key); + return -TARGET_EFAULT; + } + ret =3D get_errno(setsockopt(sockfd, level, optname, + alg_key, optlen)); + g_free(alg_key); + break; + } + case ALG_SET_AEAD_AUTHSIZE: + { + ret =3D get_errno(setsockopt(sockfd, level, optname, + NULL, optlen)); + break; + } + default: + goto unimplemented; + } + break; +#endif case TARGET_SOL_SOCKET: switch (optname) { case TARGET_SO_RCVTIMEO: --=20 2.7.4 From nobody Mon Nov 10 22:32:25 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.47; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1559907880; cv=none; d=zoho.com; s=zohoarc; b=XM++UPfYxOCGaV4kZExPQUzwvrlL2wWkc6JVC5WUjWehzv0+Vq5J4+icdamolGWU227lj0Tx+iQZ+GKWv01pFHV1K045EjQ4HHypAHSoCgbpbYggg90lz5wrw5tav8MztRbFAj3jrUIJvUYmKwUDYYHpy4w+Pae/Y11uEUgGuCY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559907880; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=dXUJWD3BFJYlVOV6rrzNR3g9ZOgmJtRzMLs1wW8PY6I=; b=EzizdFlYZjDmdcSB3jBlIqDkFc798NoCOkHwQ1V2V/0CbXrjpns73CvGfMNbhpM9WNWHOjjLq602ZF6BuZc2VrKzTrMttOqL4tFJMYELWt8OpP6D50Fui4o+ybZCV1k+vFT26vsCd++SvCsGUkklF3EZ8GXj+9+uEB/4sYfIYiM= ARC-Authentication-Results: i=1; mx.zoho.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (209.51.188.47 [209.51.188.47]) by mx.zohomail.com with SMTPS id 1559907880343860.491420404702; Fri, 7 Jun 2019 04:44:40 -0700 (PDT) Received: from localhost ([::1]:48742 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZDIG-0001gw-Mh for importer@patchew.org; Fri, 07 Jun 2019 07:44:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39960) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZCE5-0001DW-1A for qemu-devel@nongnu.org; Fri, 07 Jun 2019 06:36:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZCE3-0001M7-6l for qemu-devel@nongnu.org; Fri, 07 Jun 2019 06:36:00 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:41820 helo=mail.rt-rk.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hZCE2-0000lq-SB for qemu-devel@nongnu.org; Fri, 07 Jun 2019 06:35:59 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 4D69C1A1D0B; Fri, 7 Jun 2019 12:35:51 +0200 (CEST) Received: from rtrkw774-lin.domain.local (rtrkw774-lin.domain.local [10.10.13.43]) by mail.rt-rk.com (Postfix) with ESMTPSA id 2DAAF1A118B; Fri, 7 Jun 2019 12:35:51 +0200 (CEST) X-Virus-Scanned: amavisd-new at rt-rk.com From: Aleksandar Markovic To: qemu-devel@nongnu.org Date: Fri, 7 Jun 2019 12:35:19 +0200 Message-Id: <1559903719-7162-4-git-send-email-aleksandar.markovic@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1559903719-7162-1-git-send-email-aleksandar.markovic@rt-rk.com> References: <1559903719-7162-1-git-send-email-aleksandar.markovic@rt-rk.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 89.216.37.149 Subject: [Qemu-devel] [PATCH v10 3/3] linux-user: Add support for statx() syscall X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, Aleksandar Rikalo , amarkovic@wavecomp.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Aleksandar Rikalo Implement support for translation of system call statx(). The implementation is based on "best effort" approach: if host is capable of executing statx(), host statx() is used. If not, the implementation includes invoking other (more mature) system calls (from the same 'stat' family) on the host side to achieve as close as possible functionality. Support for statx() in kernel and glibc was, however, introduced at different points of time (the difference is more than a year): - kernel: Linux 4.11 (30 April 2017) - glibc: glibc 2.28 (1 Aug 2018) In this patch, the availability of statx() support is established via __NR_statx (if it is defined, statx() is considered available). This coincedes with statx() introduction in kernel. However, the structure statx definition may not be available for hosts with glibc older than 2.28 (it is, by design, to be defined in one of glibc headers), even though the full statx() functionality may be supported in kernel, if the kernel is not older than 4.11. Hence, a structure "target_statx" is defined in this patch, to remove that dependency on glibc headers, and to use statx() functionality as soon as the host kernel is capable of supporting it. Such structure statx definition is used for both target and host structures statx (of course, this doesn't mean the endian arrangement is the same on target and host, and endian conversion is done in all necessary cases). Signed-off-by: Aleksandar Rikalo Signed-off-by: Aleksandar Markovic --- linux-user/syscall.c | 135 ++++++++++++++++++++++++++++++++++++++++++= +++- linux-user/syscall_defs.h | 37 +++++++++++++ 2 files changed, 171 insertions(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 82c08b6..b78ed45 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -6526,6 +6527,48 @@ static inline abi_long host_to_target_stat64(void *c= pu_env, } #endif =20 +#if defined(TARGET_NR_statx) && defined(__NR_statx) +static inline abi_long host_to_target_statx(struct target_statx *host_stx, + abi_ulong target_addr) +{ + struct target_statx *target_stx; + + if (!lock_user_struct(VERIFY_WRITE, target_stx, target_addr, 0)) { + return -TARGET_EFAULT; + } + memset(target_stx, 0, sizeof(*target_stx)); + + __put_user(host_stx->stx_mask, &target_stx->stx_mask); + __put_user(host_stx->stx_blksize, &target_stx->stx_blksize); + __put_user(host_stx->stx_attributes, &target_stx->stx_attributes); + __put_user(host_stx->stx_nlink, &target_stx->stx_nlink); + __put_user(host_stx->stx_uid, &target_stx->stx_uid); + __put_user(host_stx->stx_gid, &target_stx->stx_gid); + __put_user(host_stx->stx_mode, &target_stx->stx_mode); + __put_user(host_stx->stx_ino, &target_stx->stx_ino); + __put_user(host_stx->stx_size, &target_stx->stx_size); + __put_user(host_stx->stx_blocks, &target_stx->stx_blocks); + __put_user(host_stx->stx_attributes_mask, &target_stx->stx_attributes_= mask); + __put_user(host_stx->stx_atime.tv_sec, &target_stx->stx_atime.tv_sec); + __put_user(host_stx->stx_atime.tv_nsec, &target_stx->stx_atime.tv_nsec= ); + __put_user(host_stx->stx_btime.tv_sec, &target_stx->stx_atime.tv_sec); + __put_user(host_stx->stx_btime.tv_nsec, &target_stx->stx_atime.tv_nsec= ); + __put_user(host_stx->stx_ctime.tv_sec, &target_stx->stx_atime.tv_sec); + __put_user(host_stx->stx_ctime.tv_nsec, &target_stx->stx_atime.tv_nsec= ); + __put_user(host_stx->stx_mtime.tv_sec, &target_stx->stx_atime.tv_sec); + __put_user(host_stx->stx_mtime.tv_nsec, &target_stx->stx_atime.tv_nsec= ); + __put_user(host_stx->stx_rdev_major, &target_stx->stx_rdev_major); + __put_user(host_stx->stx_rdev_minor, &target_stx->stx_rdev_minor); + __put_user(host_stx->stx_dev_major, &target_stx->stx_dev_major); + __put_user(host_stx->stx_dev_minor, &target_stx->stx_dev_minor); + + unlock_user_struct(target_stx, target_addr, 1); + + return 0; +} +#endif + + /* ??? Using host futex calls even when target atomic operations are not really atomic probably breaks things. However implementing futexes locally would make futexes shared between multiple processes @@ -7104,7 +7147,8 @@ static abi_long do_syscall1(void *cpu_env, int num, a= bi_long arg1, abi_long ret; #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) \ || defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64) \ - || defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64) + || defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64) \ + || defined(TARGET_NR_statx) struct stat st; #endif #if defined(TARGET_NR_statfs) || defined(TARGET_NR_statfs64) \ @@ -10182,6 +10226,95 @@ static abi_long do_syscall1(void *cpu_env, int num= , abi_long arg1, ret =3D host_to_target_stat64(cpu_env, arg3, &st); return ret; #endif +#if defined(TARGET_NR_statx) + case TARGET_NR_statx: + { + struct target_statx *target_stx; + int dirfd =3D arg1; + int flags =3D arg3; + + p =3D lock_user_string(arg2); + if (p =3D=3D NULL) { + return -TARGET_EFAULT; + } +#if defined(__NR_statx) + { + /* + * It is assumed that struct statx is arhitecture independ= ent + */ + struct target_statx host_stx; + int mask =3D arg4; + + ret =3D get_errno(syscall(__NR_statx, dirfd, p, flags, mas= k, + &host_stx)); + if (!is_error(ret)) { + if (host_to_target_statx(&host_stx, arg5) !=3D 0) { + unlock_user(p, arg2, 0); + return -TARGET_EFAULT; + } + } + + if (ret !=3D TARGET_ENOSYS) { + unlock_user(p, arg2, 0); + return ret; + } + } +#endif + if ((p =3D=3D NULL) || (*((char *)p) =3D=3D 0)) { + /* + * By file descriptor + */ + if (flags & AT_EMPTY_PATH) { + unlock_user(p, arg2, 0); + return -TARGET_ENOENT; + } + ret =3D get_errno(fstat(dirfd, &st)); + } else if (*((char *)p) =3D=3D '/') { + /* + * By absolute pathname + */ + ret =3D get_errno(stat(path(p), &st)); + } else { + if (dirfd =3D=3D AT_FDCWD) { + /* + * By pathname relative to the current working directo= ry + */ + ret =3D get_errno(stat(path(p), &st)); + } else { + /* + * By pathname relative to the directory referred to by + * the file descriptor 'dirfd' + */ + ret =3D get_errno(fstatat(dirfd, path(p), &st, flags)); + } + } + unlock_user(p, arg2, 0); + + if (!is_error(ret)) { + if (!lock_user_struct(VERIFY_WRITE, target_stx, arg5, 0)) { + return -TARGET_EFAULT; + } + memset(target_stx, 0, sizeof(*target_stx)); + __put_user(major(st.st_dev), &target_stx->stx_dev_major); + __put_user(minor(st.st_dev), &target_stx->stx_dev_minor); + __put_user(st.st_ino, &target_stx->stx_ino); + __put_user(st.st_mode, &target_stx->stx_mode); + __put_user(st.st_uid, &target_stx->stx_uid); + __put_user(st.st_gid, &target_stx->stx_gid); + __put_user(st.st_nlink, &target_stx->stx_nlink); + __put_user(major(st.st_rdev), &target_stx->stx_rdev_major); + __put_user(minor(st.st_rdev), &target_stx->stx_rdev_minor); + __put_user(st.st_size, &target_stx->stx_size); + __put_user(st.st_blksize, &target_stx->stx_blksize); + __put_user(st.st_blocks, &target_stx->stx_blocks); + __put_user(st.st_atime, &target_stx->stx_atime.tv_sec); + __put_user(st.st_mtime, &target_stx->stx_mtime.tv_sec); + __put_user(st.st_ctime, &target_stx->stx_ctime.tv_sec); + unlock_user_struct(target_stx, arg5, 1); + } + } + return ret; +#endif #ifdef TARGET_NR_lchown case TARGET_NR_lchown: if (!(p =3D lock_user_string(arg1))) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 7f141f6..170c4dd 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -2536,4 +2536,41 @@ struct target_user_cap_data { /* Return size of the log buffer */ #define TARGET_SYSLOG_ACTION_SIZE_BUFFER 10 =20 +struct target_statx_timestamp { + int64_t tv_sec; + uint32_t tv_nsec; + int32_t __reserved; +}; + +struct target_statx { + /* 0x00 */ + uint32_t stx_mask; /* What results were written [uncond] */ + uint32_t stx_blksize; /* Preferred general I/O size [uncond] */ + uint64_t stx_attributes; /* Flags conveying information about the file = */ + /* 0x10 */ + uint32_t stx_nlink; /* Number of hard links */ + uint32_t stx_uid; /* User ID of owner */ + uint32_t stx_gid; /* Group ID of owner */ + uint16_t stx_mode; /* File mode */ + uint16_t __spare0[1]; + /* 0x20 */ + uint64_t stx_ino; /* Inode number */ + uint64_t stx_size; /* File size */ + uint64_t stx_blocks; /* Number of 512-byte blocks allocated */ + uint64_t stx_attributes_mask; /* Mask to show what is supported */ + /* 0x40 */ + struct target_statx_timestamp stx_atime; /* Last access time */ + struct target_statx_timestamp stx_btime; /* File creation time */ + struct target_statx_timestamp stx_ctime; /* Last attribute change tim= e */ + struct target_statx_timestamp stx_mtime; /* Last data modification ti= me */ + /* 0x80 */ + uint32_t stx_rdev_major; /* Device ID of special file [if bdev/cdev] = */ + uint32_t stx_rdev_minor; + uint32_t stx_dev_major; /* ID of device containing file [uncond] */ + uint32_t stx_dev_minor; + /* 0x90 */ + uint64_t __spare2[14]; /* Spare space for future expansion */ + /* 0x100 */ +}; + #endif --=20 2.7.4