[LTP] [PATCH v3 1/2] fallocate01: Convert to new API

Cyril Hrubis chrubis@suse.cz
Wed Aug 26 17:23:35 CEST 2026


Hi!
> -void populate_files(int fd)
> -{
> -	char buf[buf_size + 1];
> -	int index;
> -	int blocks;
> -	int data;
> +	TEST(fallocate(fd, 0, 0, block_size));
> +	if (TST_RET != 0) {
> +		if (TST_ERR == EOPNOTSUPP || TST_ERR == ENOSYS)
> +			tst_brk(TCONF, "fallocate() not supported");

Sigh, looks like we need separate checks for fallocate() with and
without FALLOC_FL_KEEP_SIZE:

tst_test.c:1986: TINFO: === Testing on exfat ===
tst_test.c:1291: TINFO: Formatting /dev/loop0 with exfat opts='' extra opts=''
tst_test.c:1303: TINFO: Mounting /dev/loop0 to /tmp/LTP_falpgaoah/mntpoint fstyp=exfat flags=0
fallocate01.c:92: TPASS: fallocate(DEFAULT_MODE, 393216, 32768) passed
fallocate01.c:97: TPASS: file_stat.st_size == expected_size (425984)
fallocate01.c:101: TPASS: pos == offset + write_offset (409600)
fallocate01.c:103: TPASS: write into the newly allocated region returned 1
fallocate01.c:92: TFAIL: fallocate(FALLOC_FL_KEEP_SIZE, 393216, 32768) failed: EOPNOTSUPP (95)
fallocate01.c:97: TPASS: file_stat.st_size == expected_size (393216)
fallocate01.c:101: TPASS: pos == offset + write_offset (409600)
fallocate01.c:103: TPASS: write into the newly allocated region returned 1


I guess that the easiest solution is to use
TST_EXP_PASS_OR_FAIL(..., EOPNOTSUPP, ...) in the run() function
instead.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list