From nobody Sat Jan 28 10:20:46 2023 X-Original-To: dev-commits-src-main@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 4P3r7L4pHFz3brns; Sat, 28 Jan 2023 10:20:46 +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 4P3r7L4NG9z3CG9; Sat, 28 Jan 2023 10:20:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674901246; 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=/hau6f7e61YG31VH2O2D8WWF4qn5UqElzYxzY4oK4kg=; b=mZDRWSt+a1oHPMy1ecFIOJY1JEiVaVXt9UvvIQe22AOHgjvzvrk/FI2EAN5ufLuhCVW45C yBcmxoWbGnuGqNf3Zlokh4Tcsh688cWDPsvmff8AxMoX03bYa0AIERyohm+algo15NGDZg cDbOLzhtwzxWwyiwQljNEp2mqr+ZFSq2bzxWxjNYeIRRs48UMlVFzsASI3s1xeOPbGbj3Y 1drw/h9VgMJlG7pQf1V1gKULmvj3cdH/jVJiXpuVNO+nvIAcj4zksjL8PJXvMlIjlYrGSP 6c5ewgnVFIu3z11Ie1RLThBeXza+iANpMgXwRdLsBN48DrCGFC5fX+rQOpQfSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674901246; 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=/hau6f7e61YG31VH2O2D8WWF4qn5UqElzYxzY4oK4kg=; b=eaxXgPQmm3/XHYFzUnl9gVsHvg/TZCWADZR68vmrnKMrFinN8yJaEX6al8ymTYrR6lk+rJ vAtwsVrk9xrUVwlzER0KxZQu36GYezGwUqKb3RSvH1owzWNT2Eq0H6zJ2X2Ke9kePbGDGO sjJWNWlv1t4LYMo74v6A9BJJEwi7IAJbUm8fv1wgj37W6WFfvbQr/bGdfeRM8+7+iwvJ39 x0cfCmdsmivQVOC+/j8oD9opxyMkR08Cd7huiLX69aXoP/XwaiFbGelFTJ6WXpBv6A4e6N jjdI8uKIop6bSGRs1DbLNtRiN8KXxOS4vY3U8H5fseArWuIQ5v9RjaWV4JjlJw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674901246; a=rsa-sha256; cv=none; b=bG0mIgrL2a9fgmUw2zd5x8Yj7HdJ2ESKeKpviLDU8/mV8DQt2JijwtCYMK45x8DqS63eHU IA1RA4HnRzOwAjG3rLt7Z499EID2T2l1GIpIx8eNJydtdEU3wLXKTTnEdQk50N5CaHYKP/ PvZUxFBdu1Tu5bQ4mMHG5i79mh4uXxpsZzQavBokfbVEi20lROHaDe/rfL596EMTZgdS3t jV5e5isQ2mnvLdvYoID6WieScRtIis8nwnQf2xWUyMmHdQhE/Ys+nM3b2ff77pfCMiv7rE 808gw6kJMjBzT8PicgVAwboTSm35hhYV1khtZAfBevTLrhH4a9sCu20T5FtlGQ== 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 4P3r7L3Rxgzlm2; Sat, 28 Jan 2023 10:20:46 +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 30SAKkc9004494; Sat, 28 Jan 2023 10:20:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30SAKkMB004493; Sat, 28 Jan 2023 10:20:46 GMT (envelope-from git) Date: Sat, 28 Jan 2023 10:20:46 GMT Message-Id: <202301281020.30SAKkMB004493@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 953688e823a6 - main - linux(4): Rework statfs conversion routine. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 953688e823a67c3e9c0096252c33b1e7ecf9a095 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=953688e823a67c3e9c0096252c33b1e7ecf9a095 commit 953688e823a67c3e9c0096252c33b1e7ecf9a095 Author: Dmitry Chagin AuthorDate: 2023-01-28 10:19:41 +0000 Commit: Dmitry Chagin CommitDate: 2023-01-28 10:19:41 +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 --- 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;