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>
ts_init "$*"
ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_CMD_FINDMNT"
ts_check_prog "stat"
ts_check_prog "sed"
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