Re: [LTP] [PATCH v5 2/2] ioctl_fiemap01: New test for fiemap ioctl()

Wei Gao via ltp
2025-04-10T05:32:30Z

On Thu, Feb 27, 2025 at 05:43:38PM +0100, Petr Vorel wrote:
> Hi Wei,
>
> ...
>
> > +
> > + ret = ioctl(fd, FS_IOC_FIEMAP, fiemap);
> > + if (ret == -1) {
> > + if (errno == ENOTTY)
> > + tst_res(TCONF, "ioctl(FS_IOC_FIEMAP) not implemented");
> I wonder if it's safe to put errno == ENOTTY check into SAFE_IOCTL().
> We have similar checks in safe_socket() and other.
>
> e.g.:
> #define TTYPE (errno == ENOTTY ? TCONF : TBROK)
>
> Maybe it's not safe, ENOTTY might be caused by some test error which deserves
> TBROK:
>
> ENOTTY fd is not associated with a character special device.
>
> ENOTTY The specified operation does not apply to the kind of object that the file descriptor fd references.
>
I remove this code in next version, i have done quick test on our old build such as 12-sp5 , result is pass

susetest:~ # cat /etc/os-release
NAME="SLES"
VERSION="12-SP5"
VERSION_ID="12.5"
PRETTY_NAME="SUSE Linux Enterprise Server 12 SP5"
ID="sles"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:suse:sles:12:sp5"
susetest:~ # uname
uname uname26
susetest:~ # uname -r
4.12.14-122.231-default

> > +
> > +static struct tst_test test = {
> > + .mount_device = 1,
> > + .mntpoint = MNTPOINT,
> > + .all_filesystems = 1,
> > + .skip_filesystems = (const char *const[]) {
> > + "exfat", "vfat", "ntfs", "tmpfs", NULL
>
> Is the function unimplemented on these (even on tmpfs)? I would expect that but
tmpfs is an in-memory filesystem and does not store any file into real disk, so it
not suppose to support it.
> better to explain in the commit message why it's skipped.
I have done some check on other filesystems such as exfat/vfat/ntfs, it show unsupport
error, still need further investigation if we want figure out root cause, just for
safe reason i skip those filesystem in this case currently.

attach test log:
cat /etc/os-release
NAME="openSUSE Leap"
VERSION="15.5"
ID="opensuse-leap"
ID_LIKE="suse opensuse"
VERSION_ID="15.5"
PRETTY_NAME="openSUSE Leap 15.5"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:opensuse:leap:15.5"
BUG_REPORT_URL="https://bugs.opensuse.org"
HOME_URL="https://www.opensuse.org/"
DOCUMENTATION_URL="https://en.opensuse.org/Portal:Leap"
LOGO="distributor-logo-Leap"

tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
tst_kconfig.c:678: TINFO: CONFIG_FAULT_INJECTION kernel option detected which might slow the execution
tst_test.c:1724: TINFO: Overall timeout per run is 0h 02m 00s
tst_supported_fs_types.c:97: TINFO: Kernel supports ext2
tst_supported_fs_types.c:62: TINFO: mkfs.ext2 does exist
tst_supported_fs_types.c:97: TINFO: Kernel supports ext3
tst_supported_fs_types.c:62: TINFO: mkfs.ext3 does exist
tst_supported_fs_types.c:97: TINFO: Kernel supports ext4
tst_supported_fs_types.c:62: TINFO: mkfs.ext4 does exist
tst_supported_fs_types.c:97: TINFO: Kernel supports xfs
tst_supported_fs_types.c:62: TINFO: mkfs.xfs does exist
tst_supported_fs_types.c:97: TINFO: Kernel supports btrfs
tst_supported_fs_types.c:62: TINFO: mkfs.btrfs does exist
tst_supported_fs_types.c:105: TINFO: Skipping bcachefs because of FUSE blacklist
tst_supported_fs_types.c:170: TINFO: Skipping vfat as requested by the test
tst_supported_fs_types.c:170: TINFO: Skipping exfat as requested by the test
tst_supported_fs_types.c:132: TINFO: FUSE does support ntfs
tst_supported_fs_types.c:62: TINFO: mkfs.ntfs does exist
tst_supported_fs_types.c:97: TINFO: Kernel supports tmpfs
tst_supported_fs_types.c:49: TINFO: mkfs is not needed for tmpfs

tst_test.c:1833: TINFO: === Testing on vfat ===
tst_test.c:1170: TINFO: Formatting /dev/loop0 with vfat opts='' extra opts=''
tst_test.c:1183: TINFO: Mounting /dev/loop0 to /tmp/LTP_iocNjlayn/mntpoint fstyp=vfat flags=0
ioctl_fiemap01.c:87: TFAIL: ioctl(fd, FS_IOC_FIEMAP, fiemap) expected EBADR: EOPNOTSUPP (95)
ioctl_fiemap01.c:90: TFAIL: ioctl(fd, FS_IOC_FIEMAP, fiemap) failed: EOPNOTSUPP (95)
tst_test.c:1797: TBROK: Test killed by SIGSEGV!

tst_test.c:1833: TINFO: === Testing on exfat ===
tst_test.c:1170: TINFO: Formatting /dev/loop0 with exfat opts='' extra opts=''
tst_test.c:1183: TINFO: Mounting /dev/loop0 to /tmp/LTP_ioclNusF7/mntpoint fstyp=exfat flags=0
ioctl_fiemap01.c:87: TFAIL: ioctl(fd, FS_IOC_FIEMAP, fiemap) expected EBADR: EOPNOTSUPP (95)
ioctl_fiemap01.c:90: TFAIL: ioctl(fd, FS_IOC_FIEMAP, fiemap) failed: EOPNOTSUPP (95)
tst_test.c:1797: TBROK: Test killed by SIGSEGV!

tst_test.c:1833: TINFO: === Testing on ntfs ===
tst_test.c:1170: TINFO: Formatting /dev/loop0 with ntfs opts='' extra opts=''
The partition start sector was not specified for /dev/loop0 and it could not be obtained automatically. It has been set to 0.
The number of sectors per track was not specified for /dev/loop0 and it could not be obtained automatically. It has been set to 0.
The number of heads was not specified for /dev/loop0 and it could not be obtained automatically. It has been set to 0.
To boot from a device, Windows needs the 'partition start sector', the 'sectors per track' and the 'number of heads' to be set.
Windows will not be able to boot from this device.
tst_test.c:1183: TINFO: Mounting /dev/loop0 to /tmp/LTP_iocGtgwCr/mntpoint fstyp=ntfs flags=0
tst_test.c:1183: TINFO: Trying FUSE...
ioctl_fiemap01.c:87: TFAIL: ioctl(fd, FS_IOC_FIEMAP, fiemap) expected EBADR: EOPNOTSUPP (95)
ioctl_fiemap01.c:90: TFAIL: ioctl(fd, FS_IOC_FIEMAP, fiemap) failed: EOPNOTSUPP (95)
tst_test.c:1797: TBROK: Test killed by SIGSEGV!

tst_test.c:1833: TINFO: === Testing on tmpfs ===
tst_test.c:1170: TINFO: Skipping mkfs for TMPFS filesystem
tst_test.c:1146: TINFO: Limiting tmpfs size to 32MB
tst_test.c:1183: TINFO: Mounting ltp-tmpfs to /tmp/LTP_iocUtSP0X/mntpoint fstyp=tmpfs flags=0
ioctl_fiemap01.c:87: TFAIL: ioctl(fd, FS_IOC_FIEMAP, fiemap) expected EBADR: EOPNOTSUPP (95)
ioctl_fiemap01.c:90: TFAIL: ioctl(fd, FS_IOC_FIEMAP, fiemap) failed: EOPNOTSUPP (95)
tst_test.c:1797: TBROK: Test killed by SIGSEGV!

>
> Kind regards,
> Petr