[PATCH] selftests/mount_setattr: build with a 64-bit off_t

From: Sasha Levin

Date: Tue Nov 03 2026 - 13:08:17 EST


With glibc on 32-bit architectures, off_t is 32 bits unless
_FILE_OFFSET_BITS=64 is defined, so the 2 GB ftruncate() of the ext4
image gets a negative length and the test fails:

mount_setattr_test.c:1048:30: warning: implicit conversion from 'long long' to '__off_t' (aka 'long') changes value from 2147483648 to -2147483648 [-Wconstant-conversion]

Build the test with -D_FILE_OFFSET_BITS=64.

Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
Found with 32-bit builds of the selftests (gcc 16 and clang 21 with
-m32, with and without -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64);
KernelCI's 32-bit arm builds show the same warnings. The changed files
build without them now, and the x86_64 builds don't change.

tools/testing/selftests/mount_setattr/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/mount_setattr/Makefile b/tools/testing/selftests/mount_setattr/Makefile
index 4d4f810cdf2c1..2e5b16fcdf10c 100644
--- a/tools/testing/selftests/mount_setattr/Makefile
+++ b/tools/testing/selftests/mount_setattr/Makefile
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
# Makefile for mount selftests.
-CFLAGS = -g $(KHDR_INCLUDES) -Wall -O2 -pthread
+CFLAGS = -g $(KHDR_INCLUDES) -Wall -O2 -pthread -D_FILE_OFFSET_BITS=64

LOCAL_HDRS += ../filesystems/wrappers.h

--
2.53.0