]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: (lsfd::mkfds-inotify) use findmnt(1) instead of stat(1) to get bdev numbers
authorMasatake YAMATO <yamato@redhat.com>
Fri, 5 Jan 2024 08:54:36 +0000 (17:54 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Fri, 5 Jan 2024 09:00:48 +0000 (18:00 +0900)
Close #2349

stat(2) on some filesystems including btrfs reports a block device
number (bdev number) with a offset. On the other hand, "inotify wd"
field of /proc/$pid/fdinfo/$fd for an inotify file reports bdev
numbers without offsets.

The offset caused the failure of lsfd::mkfds-inotify test case on
btrfs.  Unlike stat(2), findmnt can report bdev numbers without
offsets.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
tests/ts/lsfd/mkfds-inotify

index 728c27de20ab8d6c87c3131f3f0b53c547bc6cf2..3f26849dd8e11f8fefd6ec7cebe3afed6763cc0a 100755 (executable)
@@ -21,6 +21,7 @@ TS_DESC="inotify"
 ts_init "$*"
 
 ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_CMD_FINDMNT"
 ts_check_prog "stat"
 ts_check_prog "sed"
 
@@ -28,10 +29,8 @@ ts_cd "$TS_OUTDIR"
 
 PID=
 FD=3
-ROOT_DEV=$(stat -c %d /)
-ROOT="$(stat -c %i /)"@"$(((ROOT_DEV >> 8) & 255)):$((ROOT_DEV & 255))"
-FSTAB_DEV=$(stat -c %d /etc/fstab)
-FSTAB="$(stat -c %i /etc/fstab)"@"$(((FSTAB_DEV >> 8) & 255)):$((FSTAB_DEV & 255))"
+ROOT="$(stat -c %i /)"@"$($TS_CMD_FINDMNT --raw --noheadings -oMAJ:MIN --target /)"
+FSTAB="$(stat -c %i /etc/fstab)"@"$($TS_CMD_FINDMNT --raw --noheadings -oMAJ:MIN --target /etc/fstab)"
 {
     coproc MKFDS { "$TS_HELPER_MKFDS" inotify $FD; }
     if read -u ${MKFDS[0]} PID; then