From nobody Wed Aug 19 14:47:19 2026 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 4hQ8YN0mkqz6p7wR for ; Wed, 19 Aug 2026 14:47:20 +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 "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hQ8YM5x4vz3sgX for ; Wed, 19 Aug 2026 14:47:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1787150839; 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=vTFyHncI6rs4FnWxV6+JZxxx/h4L0bsFGcBAzqMkbgs=; b=kN4cxazfA9IXKKrqvRxOcigZwhIsrb7J8uqV26Sa7FlvzusqSAS5xoZQ7USc53oeH6W2Uw xvqpmg1Rpy3HZ+bktOADcuqnGKb6n6ix3N7ncXcTAnwdzhn9zZt64d1PzqWwuRjzL/sfBZ mcL1uzFR8Hqu376CNhIhlwG2BtmWG1fyxjDsceLTlqvlaATR8MBquiAX4QG963eBRqolrd gxArZOBFfYMIyX5emSrm0ygDxOauSSgNoHl58PQQq9PAvAliW+cOcwvPF5EwpWfKjC2hNZ GaAHQltqimWaSKqUa2G5I1QsfxHsmjlAYeT/CRAA6CvRbT8itLjmRIZNKQaeoQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1787150839; a=rsa-sha256; cv=none; b=ZBTLdcubIUMOR4aELMEc01sWwJbkQyu713WEd5K/fJ6ZQYUw570O1O3L0UF/3b9pAlXL6r jjpBsH2whls4rQYTMJ8xyPQCF4tUOMjLzHODaS5Ap4se+TzZ0RFFzizFTvXVbZaO6gb2xj pXF/U2KQS8ru0Gz+lJ3Ptue0SRyp0kh3VovSP8WPs2p//OJia5JcnXenCQFrGN942e3Oq/ 8g8AKv1b13es76byzxd94IFyQllieCvc1mZthf/zo1KhM5IOzFN7TW7OFjFU3QSTZVkP5H Sfnpk6fji3HovCjmXQ31vGKC280tnpmiMEW40W/BGAwj/M5ijvpDjeOzWtni9w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1787150839; 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=vTFyHncI6rs4FnWxV6+JZxxx/h4L0bsFGcBAzqMkbgs=; b=v7Yc6VZQLud/3IG8f+LW3yH5DYHhj5Mcwis42UZphbchp9OexaszK7XdtD1dmDnsTwTnh8 kMTpeB+6effjhy3uan2F0D5oALbrpQGb/1NKuJ+LxTzZ2AQmxYnTXLFM8sgSvwCUOR8AKN WTvLHQp2n8CJHissoEoB7UwbBdzEvZoJp4fqMmNMZi08rQjeEdSy/STED0nmY7fNtJc5Fy KfNI1Vbleos3yUHdl7IKCV1wvbRneKClnsLFoPQuKmVpwpJFV/HJsCQSyWghmkA1ZxuimV g/hOdAd8NFZhaKJlJZ6ePu9QuDSoHA0gog6nDYD/VOmJrrlXN7L1zIGjLYqVDw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hQ8YM3r88zbQ1 for ; Wed, 19 Aug 2026 14:47:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3119d by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 19 Aug 2026 14:47:19 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 3a1bf59d195c - main - shmfd: consistently return size in 512 byte blocks for fstat(2) st_blocks 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3a1bf59d195ced99c0f69774969d7090d21f6097 Auto-Submitted: auto-generated Date: Wed, 19 Aug 2026 14:47:19 +0000 Message-Id: <6a85c1f7.3119d.64f40c1e@gitrepo.freebsd.org> The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=3a1bf59d195ced99c0f69774969d7090d21f6097 commit 3a1bf59d195ced99c0f69774969d7090d21f6097 Author: Konstantin Belousov AuthorDate: 2026-08-19 02:27:46 +0000 Commit: Konstantin Belousov CommitDate: 2026-08-19 14:46:34 +0000 shmfd: consistently return size in 512 byte blocks for fstat(2) st_blocks This is ABI-breaking change that could be considered as the bug fix. Requested by: David Timber Reviewed by: emaste, markj Sponsored by: The FreeBSD Foundation Relnotes: yes MFC after: 1 week Differential revision: https://reviews.freebsd.org/D58942 --- lib/libsys/stat.2 | 8 ++++++-- sys/kern/uipc_shm.c | 8 ++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/libsys/stat.2 b/lib/libsys/stat.2 index c16af32a340d..bbec876da1fd 100644 --- a/lib/libsys/stat.2 +++ b/lib/libsys/stat.2 @@ -271,10 +271,14 @@ be zero. .Pp For file descriptors referencing specific non-file objects, the field is type-specific. +.Pp For POSIX shared memory segments .Pq see Xr shm_open 2 , -the block size is equal to -the platform page size +the block size is 512 bytes. +For older versions of +.Fx +.Pq before 15.2 and 16.0 +the block size was equal to the platform page size .Pq Xr getpagesize 2 . .El .Pp diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c index 8341364f4d16..04b6f4f6e07a 100644 --- a/sys/kern/uipc_shm.c +++ b/sys/kern/uipc_shm.c @@ -658,12 +658,8 @@ shm_stat(struct file *fp, struct stat *sb, struct ucred *active_cred) sb->st_dev = shm_dev_ino; sb->st_ino = shmfd->shm_ino; sb->st_nlink = shmfd->shm_object->ref_count; - if (shm_largepage(shmfd)) { - sb->st_blocks = shmfd->shm_object->size / - (pagesizes[shmfd->shm_lp_psind] >> PAGE_SHIFT); - } else { - sb->st_blocks = shmfd->shm_pages; - } + sb->st_blocks = ptoa(shm_largepage(shmfd) ? shmfd->shm_object->size : + shmfd->shm_pages) / DEV_BSIZE; return (0); }