tests/sys/posixshm/posixshm_test.c::accounting fix after st_size changes

st_blksize is defined by POSIX as the 'preferred I/O block size for this
object.' It is wrong to use st_blksize as the unit for st_blocks and
expect it to be equal to the object size regardless of the change of
st_blksize.

Fixes:	3a1bf59d19 ("shmfd: consistently return size in 512 byte blocks for fstat(2) st_blocks")
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D59014
This commit is contained in:
Konstantin Belousov committed 2026-08-21 04:31:50 +03:00
1 parent f0778a6f9b
commit a1aa26b7db
1 file changed
+6 -2
+6 -2
View File
@@ -1189,7 +1189,9 @@ ATF_TC_BODY(accounting, tc)
ATF_REQUIRE(shm_fill(fd, 0, shm_sz) == 0);
ATF_REQUIRE(fstat(fd, &st) == 0);
ATF_REQUIRE(st.st_blksize * st.st_blocks == (blkcnt_t)shm_sz);
printf("blocks %jd shm_sz %jd\n", (uintmax_t)st.st_blocks,
(uintmax_t)shm_sz);
ATF_CHECK_EQ(DEV_BSIZE * st.st_blocks, (blkcnt_t)shm_sz);
range.r_offset = page_size;
range.r_len = len = (shm_max_pages - 1) * page_size -
@@ -1197,7 +1199,9 @@ ATF_TC_BODY(accounting, tc)
ATF_CHECK_MSG(fspacectl(fd, SPACECTL_DEALLOC, &range, 0, &range) == 0,
"SPACECTL_DEALLOC failed; errno=%d", errno);
ATF_REQUIRE(fstat(fd, &st) == 0);
ATF_REQUIRE(st.st_blksize * st.st_blocks == (blkcnt_t)(shm_sz - len));
printf("blocks %jd shm_sz %jd len %jd\n", (uintmax_t)st.st_blocks,
(uintmax_t)shm_sz, (uintmax_t)len);
ATF_CHECK_EQ(DEV_BSIZE * st.st_blocks, (blkcnt_t)(shm_sz - len));
ATF_REQUIRE(close(fd) == 0);
}