[LTP] [PATCH v2 1/2] Fix unlink09 test

Petr Vorel pvorel@suse.cz
Wed Jun 19 17:50:13 CEST 2024


Hi Andrea,

> This patch will fix unlink09 test by checking for filesystems which
> are not supporting inode attributes. At the same time, it removes the
> read-only filesystem unlink() check in order to add .all_filesystems
> support.

...
> -	TST_EXP_FAIL(unlink(tc->filename), tc->expected_errno, "%s", tc->desc);
> +	TST_EXP_FAIL(unlink(tc->filename), EPERM, "%s", tc->desc);

>  	/* If unlink() succeeded unexpectedly, test file should be restored. */
>  	if (!TST_RET) {
> -		if (tc->fd) {
> -			*(tc->fd) = SAFE_OPEN(tc->filename, O_CREAT, 0600);
> -			if (tc->flag) {
> -				SAFE_IOCTL(*(tc->fd), FS_IOC_GETFLAGS, &attr);
> -				attr |= tc->flag;
> -				SAFE_IOCTL(*(tc->fd), FS_IOC_SETFLAGS, &attr);
> -			}
> -		} else {
> -			SAFE_TOUCH(tc->filename, 0600, 0);
> -		}
> +		*(tc->fd) = SAFE_CREAT(tc->filename, 0600);

FYI, when forcing NTFS, we get EINVAL, reported by Avinesh:

LTP_SINGLE_FS_TYPE=ntfs ./unlink09
tst_test.c:1120: TINFO: Mounting /dev/loop2 to /tmp/LTP_unlqPsIkB/mnt fstyp=ntfs flags=0
tst_test.c:1120: TINFO: Trying FUSE...
unlink09.c:73: TBROK: ioctl(3,((((1U) << (((0+8)+8)+14)) | ((('f')) << (0+8)) | (((2)) << 0) | ((((sizeof(long)))) << ((0+8)+8)))),...) failed: EINVAL (22)
unlink09.c:42: TWARN: ioctl(3,((((2U) << (((0+8)+8)+14)) | ((('f')) << (0+8)) | (((1)) << 0) | ((((sizeof(long)))) << ((0+8)+8)))),...) failed: EINVAL (22)
unlink09.c:49: TWARN: ioctl(3,((((1U) << (((0+8)+8)+14)) | ((('f')) << (0+8)) | (((2)) << 0) | ((((sizeof(long)))) << ((0+8)+8)))),...) failed: EINVAL (22)

I tried SAFE_OPEN with O_RDWR | O_CREAT (patch from Avinesh), but it did not help.
https://lore.kernel.org/ltp/20240603124653.31967-1-akumar@suse.de/
https://patchwork.ozlabs.org/project/ltp/patch/20240601195149.17570-1-akumar@suse.de/

It's not ENOTTY, thus it's not checked by inode attributes check.

> +		setup_inode_flag(*(tc->fd), tc->flag, 0);
>  	}
>  }

> @@ -96,7 +101,8 @@ static struct tst_test test = {
>  	.tcnt = ARRAY_SIZE(tcases),
>  	.cleanup = cleanup,
>  	.test = verify_unlink,
> -	.needs_rofs = 1,
> -	.mntpoint = DIR_EROFS,
> +	.mntpoint = MNTPOINT,
>  	.needs_root = 1,
> +	.all_filesystems = 1,
> +	.format_device = 1,

Test fails on exfat (on various kernel versions):

tst_test.c:1694: TINFO: === Testing on exfat ===
tst_test.c:1107: TINFO: Formatting /dev/loop0 with exfat opts='' extra opts=''
tst_test.c:1121: TINFO: Mounting /dev/loop0 to /tmp/LTP_unl7cHxvL/mnt fstyp=exfat flags=0
unlink09.c:69: TBROK: Inode attributes not supported by 'exfat'

i.e. different error than on ntfs, but the same as on vfat (which is also
disabled). I wonder why NTFS is different. Or is it fuse relevant?

With added exfat LGTM (I can change this before merge.
Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr


More information about the ltp mailing list