From cc937cf3acfbdd89fd1ce318d764f89bfd0f12fc Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Fri, 5 Jan 2024 17:54:36 +0900 Subject: [PATCH] tests: (lsfd::mkfds-inotify) use findmnt(1) instead of stat(1) to get bdev numbers 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 --- tests/ts/lsfd/mkfds-inotify | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/ts/lsfd/mkfds-inotify b/tests/ts/lsfd/mkfds-inotify index 728c27de20..3f26849dd8 100755 --- a/tests/ts/lsfd/mkfds-inotify +++ b/tests/ts/lsfd/mkfds-inotify @@ -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 -- 2.39.2