From nobody Mon Feb 06 19:07:39 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4P9bP72brnz3n4Kt; Mon, 6 Feb 2023 19:07:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4P9bP7255bz3PKy; Mon, 6 Feb 2023 19:07:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675710459; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=GdVu49rYOgKGVAUXxiGS46B52SUmBmdwh953/V5oNz8=; b=ul5VORRqf5AnfCd6x+Pn7ocFzlKMKW38rcnl+dpsu9IAveSP2qX9DkK67YZbYa4tkX015J hScbumNn2Dil3UVuRiF7Om8ydYmi8Putkga14BqWCBj/Dkbic2ChWKhmy5GTGEo6hT22K3 Hkt/LATE+q6sJQd/VHvjumimPtuB52UDNrFfkt38OF11uoDwTcoL1EuVxxqCGINO1Co20D hejt6nE1zyB4iO55fc/WbdSR61vcQMoHbvdWA4LsqCd3AXpLgYSmRL7Ah11Ta9h8nQeEG8 4kN2ONFGr76iU0UlJY9jy6Wta7CoDS8u3+gMkgkJ58MsNxOXxnl3370aum+O7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675710459; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=GdVu49rYOgKGVAUXxiGS46B52SUmBmdwh953/V5oNz8=; b=vK0ppTSFlki01fyCsxxm9zKcfxCMKO4HXTdugNO9630bMktYOSrzYUJ8ismilk6U3d91fh KAEYNuXDVYGSol881I0h4TztJiwXlJjbZKGpDoL2jxNZLOB9DMGXhM+s0Wb1ShTnzQ8QxC 3Ska5dCBcDR4JfYUskz/EuAwwmxNF2M0aKwWqE36LnouBKk0+Hogs/Ln7Uk4p/y4NQCbF5 zao9BYQjNb1A0P0VaHbiLVPd8VgU2Q77ItRiqvXHtSE7iLfb+4+nR6FCipNmQJLAoKf2fb xvqf+upFDj8D5T/c1GFDe6H35MOosdB7AmGhPNy14O/cnvF1CARIj4FV7lhvVw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675710459; a=rsa-sha256; cv=none; b=ivJaLDyYbzCH38OC56J5Sujx+texZY/qLsNGixJ8reQC9ap9HkA2oporTHPyfxh856A5H0 F26Fbw678Ox2xCldbZTbwJWvozph5LELD/Flc5DhR63Sx0SBGET1/EKdPAAn3CZu3eZEvv 9aK/mLjNMC7U1GBXdXvYW/f8AEDuTbsg2z/h47RAfeYZzbaxrv2RAJtEn0Pj6Zq4XaWFv1 YfnIOFEQaT5TbFS0yZqhBTxa4M6Er4mR73XouwEO4ouYJN0XwNfgkUeGcNWL/F0cxNqhlm ei9PQQZob7a2oigDmUkejet0BUCHvVLnXZzO4pDu/XHL+hIpLzZ2qKEVUNm9uA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4P9bP70pVQzm2r; Mon, 6 Feb 2023 19:07:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 316J7dns076753; Mon, 6 Feb 2023 19:07:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 316J7dmY076752; Mon, 6 Feb 2023 19:07:39 GMT (envelope-from git) Date: Mon, 6 Feb 2023 19:07:39 GMT Message-Id: <202302061907.316J7dmY076752@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dmitry Chagin Subject: git: 3e60d3d3c4b3 - stable/13 - linux(4): Rework statfs conversion routine. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3e60d3d3c4b3e9690c0f1a77fa163e3d07c9b245 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=3e60d3d3c4b3e9690c0f1a77fa163e3d07c9b245 commit 3e60d3d3c4b3e9690c0f1a77fa163e3d07c9b245 Author: Dmitry Chagin AuthorDate: 2023-01-28 10:19:41 +0000 Commit: Dmitry Chagin CommitDate: 2023-02-06 19:06:29 +0000 linux(4): Rework statfs conversion routine. Rework the routines to convert a native statfs structure (with fixed-size 64-bit counters) to a Linux statfs structure (with long-sized counters) for 32-bit apps. Instead of following Linux and return an EOVERFLOW error from statfs() family of syscalls when actual fs stat value(s) are large enough to not fit into 32 bits, apply scale logics used by FreeBSD to convert a 5.x statfs structure to a 4.x statfs structure. For more details see cc479dda. Tested by: glebius MFC after: 1 week (cherry picked from commit 953688e823a67c3e9c0096252c33b1e7ecf9a095) --- sys/compat/linux/linux_stats.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/sys/compat/linux/linux_stats.c b/sys/compat/linux/linux_stats.c index fb2dd2fe01ef..63a5c37e1acf 100644 --- a/sys/compat/linux/linux_stats.c +++ b/sys/compat/linux/linux_stats.c @@ -413,26 +413,22 @@ bsd_to_linux_ftype(const char *fstypename) static int bsd_to_linux_statfs(struct statfs *bsd_statfs, struct l_statfs *linux_statfs) { -#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) - uint64_t tmp; - -#define LINUX_HIBITS 0xffffffff00000000ULL - tmp = bsd_statfs->f_blocks | bsd_statfs->f_bfree | bsd_statfs->f_files | - bsd_statfs->f_bsize; - if ((bsd_statfs->f_bavail != -1 && (bsd_statfs->f_bavail & LINUX_HIBITS)) || - (bsd_statfs->f_ffree != -1 && (bsd_statfs->f_ffree & LINUX_HIBITS)) || - (tmp & LINUX_HIBITS)) - return (EOVERFLOW); -#undef LINUX_HIBITS +#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) + statfs_scale_blocks(bsd_statfs, INT32_MAX); #endif linux_statfs->f_type = bsd_to_linux_ftype(bsd_statfs->f_fstypename); linux_statfs->f_bsize = bsd_statfs->f_bsize; linux_statfs->f_blocks = bsd_statfs->f_blocks; linux_statfs->f_bfree = bsd_statfs->f_bfree; linux_statfs->f_bavail = bsd_statfs->f_bavail; +#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) + linux_statfs->f_ffree = MIN(bsd_statfs->f_ffree, INT32_MAX); + linux_statfs->f_files = MIN(bsd_statfs->f_files, INT32_MAX); +#else linux_statfs->f_ffree = bsd_statfs->f_ffree; linux_statfs->f_files = bsd_statfs->f_files; +#endif linux_statfs->f_fsid.val[0] = bsd_statfs->f_fsid.val[0]; linux_statfs->f_fsid.val[1] = bsd_statfs->f_fsid.val[1]; linux_statfs->f_namelen = MAXNAMLEN;