Skip to contentSkip to conversation

tst_device: add support for overlayfs

PATCH Superseded Jeff Moyer 3 participants 11 messages Feb 3, 2025 – Feb 7, 2025 Library code

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Jeff Moyer

author
#0 lore raw

cover tst_device: add support for overlayfs

When running ltp-aiodio on an overlay file system, the following error occurs:

tst_tmpdir.c:316: TINFO: Using /mnt/fstests/TEST_DIR/ovl-mnt/ltp-hSHEHy5M0s/LTP_aio4q4GMW as tmpdir (overlayfs filesystem) tst_test.c:1888: TINFO: LTP version: 20220121-2271-g91a10df22
tst_test.c:1892: TINFO: Tested kernel: vendor kernel
tst_test.c:1723: TINFO: Timeout per run is 0h 40m 00s
aiocp.c:211: TINFO: Maximum AIO blocks: 65536
tst_device.c:551: TINFO: Use BTRFS specific strategy
tst_device.c:569: TBROK: BTRFS ioctl failed. Is . on a tmpfs?: ENOTTY (25)

The issue is that stat(2) on an overlayfs mount point will return a major device number of 0. The code assumes this is btrfs, and tries to issue a btrfs-specific ioctl. When that fails, the final message is printed that suggests this might be tmpfs.

I modified the code to use statfs(2) to get the file system type, and use that to determine which file system specific code to call. Finally, I added code to parse out the upper directory from the overlayfs mount options using libmount. libmount is part of util-linux, so it should be fairly ubiquitous. stat(2) is then called on the upper directory to get to the underlying device node.

Review of the series is greatly appreciated.

Thanks in advance!
Jeff

[PATCH 1/3] lib/tst_device.c: factor out btrfs-specific logic from [PATCH 2/3] lib/tst_device.c: check for BTRFS_SUPER_MAGIC instead of [PATCH 3/3] lib/tst_device.c: add support for overlayfs

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#1 lore raw

PATCH 1/3 lib/tst_device.c: factor out btrfs-specific logic from tst_find_backing_dev

In preparation for handling overlayfs (which also has a major device number of 0), factor out the btrfs logic.

---
 lib/tst_device.c | 104 +++++++++++++++++++++++++----------------------
 1 file changed, 55 insertions(+), 49 deletions(-)
lib/tst_device.c +55 -49
index 723f6ca06..70234a83c 100644
@@ -520,20 +520,68 @@ unsigned long tst_dev_bytes_written(const char *dev)
 	return dev_bytes_written;
 }
 
+static void btrfs_get_uevent_path(char *tmp_path, char *uevent_path)
+{
+	int fd;
+	struct btrfs_ioctl_fs_info_args args = {0};
+	char btrfs_uuid_str[UUID_STR_SZ];
+	struct dirent *d;
+	char bdev_path[PATH_MAX];
+	DIR *dir;
+
+	tst_resm(TINFO, "Use BTRFS specific strategy");
+
+	fd = SAFE_OPEN(NULL, tmp_path, O_DIRECTORY);
+	if (!ioctl(fd, BTRFS_IOC_FS_INFO, &args)) {
+		sprintf(btrfs_uuid_str,
+			UUID_FMT,
+			args.fsid[0], args.fsid[1],
+			args.fsid[2], args.fsid[3],
+			args.fsid[4], args.fsid[5],
+			args.fsid[6], args.fsid[7],
+			args.fsid[8], args.fsid[9],
+			args.fsid[10], args.fsid[11],
+			args.fsid[12], args.fsid[13],
+			args.fsid[14], args.fsid[15]);
+		sprintf(bdev_path,
+			"/sys/fs/btrfs/%s/devices", btrfs_uuid_str);
+	} else {
+		if (errno == ENOTTY)
+			tst_brkm(TBROK | TERRNO, NULL, "BTRFS ioctl failed. Is %s on a tmpfs?", tmp_path);
+
+		tst_brkm(TBROK | TERRNO, NULL, "BTRFS ioctl on %s failed.", tmp_path);
+	}
+	SAFE_CLOSE(NULL, fd);
+
+	dir = SAFE_OPENDIR(NULL, bdev_path);
+	while ((d = SAFE_READDIR(NULL, dir))) {
+		if (d->d_name[0] != '.')
+			break;
+	}
+
+	uevent_path[0] = '\0';
+
+	if (d) {
+		sprintf(uevent_path, "%s/%s/uevent",
+			bdev_path, d->d_name);
+	} else {
+		tst_brkm(TBROK | TERRNO, NULL, "No backing device found while looking in %s.", bdev_path);
+	}
+
+	if (SAFE_READDIR(NULL, dir))
+		tst_resm(TINFO, "Warning: used first of multiple backing device.");
+
+	SAFE_CLOSEDIR(NULL, dir);
+}
+
 __attribute__((nonnull))
 void tst_find_backing_dev(const char *path, char *dev, size_t dev_size)
 {
 	struct stat buf;
-	struct btrfs_ioctl_fs_info_args args = {0};
-	struct dirent *d;
 	char uevent_path[PATH_MAX+PATH_MAX+10]; //10 is for the static uevent path
 	char dev_name[NAME_MAX];
-	char bdev_path[PATH_MAX];
 	char tmp_path[PATH_MAX];
-	char btrfs_uuid_str[UUID_STR_SZ];
-	DIR *dir;
 	unsigned int dev_major, dev_minor;
-	int fd;
 
 	if (stat(path, &buf) < 0)
 		tst_brkm(TWARN | TERRNO, NULL, "stat() failed");
@@ -548,49 +596,7 @@ void tst_find_backing_dev(const char *path, char *dev, size_t dev_size)
 	*dev = '\0';
 
 	if (dev_major == 0) {
-		tst_resm(TINFO, "Use BTRFS specific strategy");
-
-		fd = SAFE_OPEN(NULL, tmp_path, O_DIRECTORY);
-		if (!ioctl(fd, BTRFS_IOC_FS_INFO, &args)) {
-			sprintf(btrfs_uuid_str,
-				UUID_FMT,
-				args.fsid[0], args.fsid[1],
-				args.fsid[2], args.fsid[3],
-				args.fsid[4], args.fsid[5],
-				args.fsid[6], args.fsid[7],
-				args.fsid[8], args.fsid[9],
-				args.fsid[10], args.fsid[11],
-				args.fsid[12], args.fsid[13],
-				args.fsid[14], args.fsid[15]);
-			sprintf(bdev_path,
-				"/sys/fs/btrfs/%s/devices", btrfs_uuid_str);
-		} else {
-			if (errno == ENOTTY)
-				tst_brkm(TBROK | TERRNO, NULL, "BTRFS ioctl failed. Is %s on a tmpfs?", path);
-
-			tst_brkm(TBROK | TERRNO, NULL, "BTRFS ioctl on %s failed.", tmp_path);
-		}
-		SAFE_CLOSE(NULL, fd);
-
-		dir = SAFE_OPENDIR(NULL, bdev_path);
-		while ((d = SAFE_READDIR(NULL, dir))) {
-			if (d->d_name[0] != '.')
-				break;
-		}
-
-		uevent_path[0] = '\0';
-
-		if (d) {
-			sprintf(uevent_path, "%s/%s/uevent",
-				bdev_path, d->d_name);
-		} else {
-			tst_brkm(TBROK | TERRNO, NULL, "No backing device found while looking in %s.", bdev_path);
-		}
-
-		if (SAFE_READDIR(NULL, dir))
-			tst_resm(TINFO, "Warning: used first of multiple backing device.");
-
-		SAFE_CLOSEDIR(NULL, dir);
+		btrfs_get_uevent_path(tmp_path, uevent_path);
 	} else {
 		tst_resm(TINFO, "Use uevent strategy");
 		sprintf(uevent_path,
Signature · 5 lines
2.43.5


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#2 lore raw

PATCH 2/3 lib/tst_device.c: check for BTRFS_SUPER_MAGIC instead of device major of 0

In reply to Jeff Moyer

stat() may return a major number of 0 in st_dev for any number of pseudo file systems. Check for the exact file system instead. There should be no change in behavior with this patch.

---
 lib/tst_device.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
lib/tst_device.c +9 -4
index 70234a83c..744e08a68 100644
@@ -17,6 +17,8 @@
 #include <sys/sysmacros.h>
 #include <linux/btrfs.h>
 #include <linux/limits.h>
+#include <sys/vfs.h>
+#include <linux/magic.h>
 #include "lapi/syscalls.h"
 #include "test.h"
 #include "safe_macros.h"
@@ -546,9 +548,6 @@ static void btrfs_get_uevent_path(char *tmp_path, char *uevent_path)
 		sprintf(bdev_path,
 			"/sys/fs/btrfs/%s/devices", btrfs_uuid_str);
 	} else {
-		if (errno == ENOTTY)
-			tst_brkm(TBROK | TERRNO, NULL, "BTRFS ioctl failed. Is %s on a tmpfs?", tmp_path);
-
 		tst_brkm(TBROK | TERRNO, NULL, "BTRFS ioctl on %s failed.", tmp_path);
 	}
 	SAFE_CLOSE(NULL, fd);
@@ -578,6 +577,7 @@ __attribute__((nonnull))
 void tst_find_backing_dev(const char *path, char *dev, size_t dev_size)
 {
 	struct stat buf;
+	struct statfs fsbuf;
 	char uevent_path[PATH_MAX+PATH_MAX+10]; //10 is for the static uevent path
 	char dev_name[NAME_MAX];
 	char tmp_path[PATH_MAX];
@@ -595,8 +595,13 @@ void tst_find_backing_dev(const char *path, char *dev, size_t dev_size)
 	dev_minor = minor(buf.st_dev);
 	*dev = '\0';
 
-	if (dev_major == 0) {
+	if (statfs(path, &fsbuf) < 0)
+		tst_brkm(TWARN | TERRNO, NULL, "statfs() failed");
+
+	if (fsbuf.f_type == BTRFS_SUPER_MAGIC) {
 		btrfs_get_uevent_path(tmp_path, uevent_path);
+	} else if (dev_major == 0) {
+		tst_brkm(TBROK, NULL, "%s resides on an unsupported pseudo-file system.", path);
 	} else {
 		tst_resm(TINFO, "Use uevent strategy");
 		sprintf(uevent_path,
Signature · 5 lines
2.43.5


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#3 lore raw

PATCH 3/3 lib/tst_device.c: add support for overlayfs

In reply to Jeff Moyer

Add checks for overlayfs in tst_find_backing_dev. As with btrfs, only a single device is checked (the upper one) and returned from tst_find_backing_dev().

---
 .gitignore       |  1 +
 INSTALL          |  6 ++---
 lib/Makefile     |  2 +-
 lib/libltp.a     |  1 +
 lib/tst_device.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 68 insertions(+), 4 deletions(-)
 create mode 100644 lib/libltp.a
.gitignore +1 -0
index 24f4a4ea8..38bf1fab9 100644
@@ -9,6 +9,7 @@ core
 .gdb_history
 .gdbinit
 lib*.a
+!libltp.a
 .cache.mk
 *.dwo
 *.mod
INSTALL +3 -3
index ad43514d4..557cf4abc 100644
@@ -6,15 +6,15 @@ package in any Linux distribution (no specific version is required).
 
 Debian / Ubuntu
 
-	# apt install gcc git make pkgconf autoconf automake bison flex m4 linux-headers-$(uname -r) libc6-dev
+	# apt install gcc git make pkgconf autoconf automake bison flex m4 linux-headers-$(uname -r) libc6-dev libmount-dev
 
 openSUSE / SLES
 
-	# zypper install gcc git make pkg-config autoconf automake bison flex m4 linux-glibc-devel glibc-devel
+	# zypper install gcc git make pkg-config autoconf automake bison flex m4 linux-glibc-devel glibc-devel libmount-devel
 
 Fedora / CentOS / RHEL
 
-	# yum install gcc git make pkgconf autoconf automake bison flex m4 kernel-headers glibc-headers
+	# yum install gcc git make pkgconf autoconf automake bison flex m4 kernel-headers glibc-headers libmount-devel
 
 These are minimal build requirements for git compilation. Some tests require
 extra development files of some libraries, see ci/*.sh. There is also
lib/Makefile +1 -1
index 67169f149..2f180405e 100644
@@ -14,7 +14,7 @@ else
 FILTER_OUT_LIBSRCS	+= tlibio.c tst_safe_sysv_ipc.c
 endif
 
-INTERNAL_LIB		:= libltp.a
+INTERNAL_LIB		:= libltp_internal.a
 
 pc_file			:= $(DESTDIR)/$(datarootdir)/pkgconfig/ltp.pc
 
lib/libltp.a new file +1 -0
new file mode 100644
index 000000000..006f3557e
@@ -0,0 +1 @@
+INPUT (libltp_internal.a -lmount)
lib/tst_device.c +62 -0

80 lines not on this page · raw message

Signature · 5 lines
2.43.5


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw

Re: [LTP] [PATCH 3/3] lib/tst_device.c: add support for overlayfs

Hi Jeff,

Quoted 3 lines

Add checks for overlayfs in tst_find_backing_dev. As with btrfs, only a single device is checked (the upper one) and returned from tst_find_backing_dev().

...

Quoted 7 lines

+++ b/INSTALL

(quoted diff) +1 -1
@@ -6,15 +6,15 @@ package in any Linux distribution (no specific version is required).
 
 Debian / Ubuntu
 
-	# apt install gcc git make pkgconf autoconf automake bison flex m4 linux-headers-$(uname -r) libc6-dev
+	# apt install gcc git make pkgconf autoconf automake bison flex m4 linux-headers-$(uname -r) libc6-dev libmount-dev

Review package in any Linux distribution (no specific version is required). · line 17

Quoted 10 lines
(quoted diff) +2 -2
 
 openSUSE / SLES
 
-	# zypper install gcc git make pkg-config autoconf automake bison flex m4 linux-glibc-devel glibc-devel
+	# zypper install gcc git make pkg-config autoconf automake bison flex m4 linux-glibc-devel glibc-devel libmount-devel
 
 Fedora / CentOS / RHEL
 
-	# yum install gcc git make pkgconf autoconf automake bison flex m4 kernel-headers glibc-headers
+	# yum install gcc git make pkgconf autoconf automake bison flex m4 kernel-headers glibc-headers libmount-devel

FYI it's good to update docs, but this is not enough.
You need to add libmount devel packages to ci/*.sh scripts otherwise it fails, see [1].

We have note about ci/*.sh in INSTALL, maybe we should explicitly state that build dependencies must be updated there.

I updated it for you (see diff below or use branch jmoyer/tst_device-overlayfs.fixes in my fork [2]), but it still not enough [3].

It is reproducible even locally:

$ make autotools && ./configure
$ cd lib && make
AR libltp_internal.a
RANLIB libltp_internal.a
/usr/bin/ld: cannot find -lltp: No such file or directory
collect2: error: ld returned 1 exit status
make[1]: *** [../../include/mk/rules.mk:48: test01] Error 1
make[1]: *** Waiting for unfinished jobs....
/usr/bin/ld: cannot find -lltp: No such file or directory
collect2: error: ld returned 1 exit status
make[1]: *** [../../include/mk/rules.mk:48: test02] Error 1
/usr/bin/ld: cannot find -lltp: No such file or directory
collect2: error: ld returned 1 exit status
make[1]: *** [../../include/mk/rules.mk:48: test04] Error 1
/usr/bin/ld: cannot find -lltp: No such file or directory
collect2: error: ld returned 1 exit status
make[1]: *** [../../include/mk/rules.mk:48: test03] Error 1
make: *** [../include/mk/generic_trunk_target.inc:92: all] Error 2

lib/libltp.a line 1

Quoted 4 lines
lib/libltp.a new file +1 -0
@@ -0,0 +1 @@
+INPUT (libltp_internal.a -lmount)

'rm -fv lib/libltp.a' is required to apply the patchset.

Kind regards,
Petr

[1] https://github.com/pevik/ltp/actions/runs/13198563478
[2] https://github.com/pevik/ltp/tree/refs/heads/jmoyer/tst_device-overlayfs.fixes
[3] https://github.com/pevik/ltp/actions/runs/13198676398/job/36845555749

Fix CI for missing packages.

alpine.sh +2 -1
index 93acd6267b..26a3775ac6 100755
@@ -26,7 +26,8 @@ apk add \
 	numactl-dev \
 	openssl-dev \
 	perl-json \
-	pkgconfig
+	pkgconfig \
+	util-linux-dev
 
 cat /etc/os-release
 
debian.cross-compile.sh +1 -0
index 95cf11da22..18ee44ef58 100755
@@ -21,4 +21,5 @@ apt install -y --no-install-recommends \
 	gcc-${gcc_arch}-linux-gnu \
 	libc6-dev-${ARCH}-cross \
 	libmnl-dev:$ARCH \
+	libmount-dev:$ARCH \
 	libtirpc-dev:$ARCH
debian.i386.sh +1 -0
index 2846053098..b0f916d05f 100755
@@ -14,6 +14,7 @@ apt install -y --no-install-recommends \
 	libc6-dev-i386 \
 	libc6:i386 \
 	libkeyutils-dev:i386 \
+	libmount-dev:i386 \
 	libnuma-dev:i386 \
 	libssl-dev:i386 \
 	libtirpc-dev:i386 \
debian.sh +1 -0
index fc1c1b3ec6..5fe1bf18da 100755
@@ -27,6 +27,7 @@ pkg_minimal="
 	git
 	iproute2
 	libc6-dev
+	libmount-dev
 	libtirpc-dev
 	linux-libc-dev
 	lsb-release
fedora.sh +1 -0
index 623dbb5cb6..244e2dae37 100755
@@ -15,6 +15,7 @@ $yum \
 	findutils \
 	iproute \
 	numactl-devel \
+	libmount-devel \
 	libtirpc \
 	libtirpc-devel \
 	perl-JSON \
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw
In reply to Jeff Moyer

Hi Jeff, all,

NOTE: 'rm -fv lib/libltp.a' is required to apply the patchset.

Besides it, it does not compile yet:
/usr/bin/ld: cannot find -lltp: No such file or directory
https://lore.kernel.org/ltp/20250207112353.GA1739723@pevik/

Quoted 16 lines

When running ltp-aiodio on an overlay file system, the following error occurs:

tst_tmpdir.c:316: TINFO: Using /mnt/fstests/TEST_DIR/ovl-mnt/ltp-hSHEHy5M0s/LTP_aio4q4GMW as tmpdir (overlayfs filesystem) tst_test.c:1888: TINFO: LTP version: 20220121-2271-g91a10df22
tst_test.c:1892: TINFO: Tested kernel: vendor kernel
tst_test.c:1723: TINFO: Timeout per run is 0h 40m 00s
aiocp.c:211: TINFO: Maximum AIO blocks: 65536
tst_device.c:551: TINFO: Use BTRFS specific strategy
tst_device.c:569: TBROK: BTRFS ioctl failed. Is . on a tmpfs?: ENOTTY (25)

The issue is that stat(2) on an overlayfs mount point will return a major device number of 0. The code assumes this is btrfs, and tries to issue a btrfs-specific ioctl. When that fails, the final message is printed that suggests this might be tmpfs.

Quoted 4 lines

I modified the code to use statfs(2) to get the file system type, and use that to determine which file system specific code to call. Finally, I added code to parse out the upper directory from the overlayfs mount options using libmount. libmount is part of util-linux, so it should be fairly

We try to avoid external libraries to help testing kernel on some minimal embedded devices. @Cyril: is it ok to drag libmount-devel?

@Jeff: would it be too hard to parse /proc/self/mountinfo (I suppose /proc/self/mounts is not enough)? I'm looking into libmount code E.e. mnt_fs_get_option() [1]. Or do you think it would be too fragile to parse it without libmount?

Kind regards,
Petr

[1] https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/tree/libmount/src/fs.c#n1568

Quoted 7 lines

ubiquitous. stat(2) is then called on the upper directory to get to the underlying device node.

Review of the series is greatly appreciated.

Thanks in advance!
Jeff

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#6 lore raw

Hi!

Quoted 13 lines
Quoted 12 lines

tst_tmpdir.c:316: TINFO: Using /mnt/fstests/TEST_DIR/ovl-mnt/ltp-hSHEHy5M0s/LTP_aio4q4GMW as tmpdir (overlayfs filesystem) tst_test.c:1888: TINFO: LTP version: 20220121-2271-g91a10df22
tst_test.c:1892: TINFO: Tested kernel: vendor kernel
tst_test.c:1723: TINFO: Timeout per run is 0h 40m 00s
aiocp.c:211: TINFO: Maximum AIO blocks: 65536
tst_device.c:551: TINFO: Use BTRFS specific strategy
tst_device.c:569: TBROK: BTRFS ioctl failed. Is . on a tmpfs?: ENOTTY (25)

The issue is that stat(2) on an overlayfs mount point will return a major device number of 0. The code assumes this is btrfs, and tries to issue a btrfs-specific ioctl. When that fails, the final message is printed that suggests this might be tmpfs.

Quoted 7 lines
Quoted 4 lines

I modified the code to use statfs(2) to get the file system type, and use that to determine which file system specific code to call. Finally, I added code to parse out the upper directory from the overlayfs mount options using libmount. libmount is part of util-linux, so it should be fairly

We try to avoid external libraries to help testing kernel on some minimal embedded devices. @Cyril: is it ok to drag libmount-devel?

For the base LTP library? I would say no.

Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#7 lore raw

Hi, Cyril,

Quoted 21 lines · Cyril Hrubis

Hi!

Quoted 20 lines
Quoted 19 lines

tst_tmpdir.c:316: TINFO: Using /mnt/fstests/TEST_DIR/ovl-mnt/ltp-hSHEHy5M0s/LTP_aio4q4GMW as tmpdir (overlayfs filesystem)
tst_test.c:1888: TINFO: LTP version: 20220121-2271-g91a10df22 tst_test.c:1892: TINFO: Tested kernel: vendor kernel tst_test.c:1723: TINFO: Timeout per run is 0h 40m 00s aiocp.c:211: TINFO: Maximum AIO blocks: 65536 tst_device.c:551: TINFO: Use BTRFS specific strategy tst_device.c:569: TBROK: BTRFS ioctl failed. Is . on a tmpfs?: ENOTTY (25)

The issue is that stat(2) on an overlayfs mount point will return a major device number of 0. The code assumes this is btrfs, and tries to issue a btrfs-specific ioctl. When that fails, the final message is printed that suggests this might be tmpfs.

I modified the code to use statfs(2) to get the file system type, and use that to determine which file system specific code to call. Finally, I added code to parse out the upper directory from the overlayfs mount options using libmount. libmount is part of util-linux, so it should be fairly

Quoted 4 lines
Quoted 2 lines

We try to avoid external libraries to help testing kernel on some minimal embedded devices. @Cyril: is it ok to drag libmount-devel?

For the base LTP library? I would say no.

OK, I'll spin a version with custom parsing code.

Thanks for taking a look!

-Jeff

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#8 lore raw
In reply to Petr Vorel

Hi, Petr,

Quoted 3 lines · Petr Vorel

Hi Jeff, all,

NOTE: 'rm -fv lib/libltp.a' is required to apply the patchset.

Right, sorry for not mentioning that.

Quoted 3 lines

Besides it, it does not compile yet:
/usr/bin/ld: cannot find -lltp: No such file or directory
https://lore.kernel.org/ltp/20250207112353.GA1739723@pevik/

It compiled for me, so that's surprising. I would help track it down, but it sounds like Cyril would prefer we didn't add a dependency.

Quoted 24 lines
Quoted 19 lines

When running ltp-aiodio on an overlay file system, the following error occurs:

tst_tmpdir.c:316: TINFO: Using /mnt/fstests/TEST_DIR/ovl-mnt/ltp-hSHEHy5M0s/LTP_aio4q4GMW as tmpdir (overlayfs filesystem)
tst_test.c:1888: TINFO: LTP version: 20220121-2271-g91a10df22 tst_test.c:1892: TINFO: Tested kernel: vendor kernel tst_test.c:1723: TINFO: Timeout per run is 0h 40m 00s aiocp.c:211: TINFO: Maximum AIO blocks: 65536 tst_device.c:551: TINFO: Use BTRFS specific strategy tst_device.c:569: TBROK: BTRFS ioctl failed. Is . on a tmpfs?: ENOTTY (25)

The issue is that stat(2) on an overlayfs mount point will return a major device number of 0. The code assumes this is btrfs, and tries to issue a btrfs-specific ioctl. When that fails, the final message is printed that suggests this might be tmpfs.

Quoted 4 lines

I modified the code to use statfs(2) to get the file system type, and use that to determine which file system specific code to call. Finally, I added code to parse out the upper directory from the overlayfs mount options using libmount. libmount is part of util-linux, so it should be fairly

Quoted 7 lines

We try to avoid external libraries to help testing kernel on some minimal embedded devices. @Cyril: is it ok to drag libmount-devel?

@Jeff: would it be too hard to parse /proc/self/mountinfo (I suppose /proc/self/mounts is not enough)? I'm looking into libmount code E.e. mnt_fs_get_option() [1]. Or do you think it would be too fragile to parse it without libmount?

I thought about it, but I typically avoid string parsing whenever possible. There are just too many corner cases. Looking through the libmount code convinced me I did not want to wade into those waters. :) It is, of course, possible to parse it directly. There may be some added maintenance burden, but it should be managable. I'll purue that route.

Thanks for taking a look!

-Jeff

Quoted 14 lines

Kind regards,
Petr

[1]
https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/tree/libmount/src/fs.c#n1568

Quoted 7 lines

ubiquitous. stat(2) is then called on the upper directory to get to the underlying device node.

Review of the series is greatly appreciated.

Thanks in advance!
Jeff

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#9 lore raw
In reply to Petr Vorel
Quoted 2 lines · Petr Vorel

@Jeff: would it be too hard to parse /proc/self/mountinfo (I suppose /proc/self/mounts is not enough)? I'm looking into libmount code E.e.

Looking more closely, I think /proc/self/mounts will work just fine. I was pointed to mountinfo originally and didn't consider mounts. Thanks for the suggestion, that will make this much easier!

Cheers,
Jeff

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#10 lore raw

Hi Jeff,

Quoted 8 lines
Quoted 2 lines · Petr Vorel

@Jeff: would it be too hard to parse /proc/self/mountinfo (I suppose /proc/self/mounts is not enough)? I'm looking into libmount code E.e.

Looking more closely, I think /proc/self/mounts will work just fine. I was pointed to mountinfo originally and didn't consider mounts. Thanks for the suggestion, that will make this much easier!

Great, thank you! Not dragging libmount as a hard dependency for base library helps us a lot.

Kind regards,
Petr

Quoted 2 lines

Cheers,
Jeff

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp