3 rw- CHR /dev/zero mem:5 0 1:5 mem char 1:5
ASSOC,MODE,TYPE,NAME,SOURCE,POS,MAJ:MIN,CHRDRV,DEVTYPE,RDEV: 0
+MNTID[RUN]: 0
+DEV[RUN]: 0
+FINDMNT[RUN]: 0
+DEV[STR]: 0
--- /dev/null
+#!/bin/bash
+#
+# Copyright (C) 2021 Masatake YAMATO <yamato@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+
+function lsfd_compare_dev {
+ local LSFD=$1
+ local FINDMNT=$2
+ local EXPR=$3
+
+ ts_check_prog "grep"
+
+ local MNTID=$("${LSFD}" --raw -n -o MNTID -Q "${EXPR}")
+ echo 'MNTID[RUN]:' $?
+ local DEV=$("${LSFD}" --raw -n -o DEV -Q "${EXPR}")
+ echo 'DEV[RUN]:' $?
+ # "stat -c" %d or "stat -c %D" can be used here instead of "findmnt".
+ # "stat" just prints a device id.
+ # Unlike "stat", "findmnt" can print the major part and minor part
+ # for a given device separately.
+ # We can save the code for extracting the major part and minor part
+ # if we use findmnt.
+ local FINDMNT_MNTID_DEV=$("${FINDMNT}" --raw -n -o ID,MAJ:MIN | grep "^${MNTID}")
+ echo 'FINDMNT[RUN]:' $?
+ [ "${MNTID} ${DEV}" == "${FINDMNT_MNTID_DEV}" ]
+ echo 'DEV[STR]:' $?
+}
. $TS_TOPDIR/functions.sh
ts_init "$*"
+. $TS_SELF/lsfd-functions.bash
+
ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_CMD_FINDMNT"
+
ts_check_test_command "$TS_HELPER_MKFDS"
ts_check_prog "stat"
[ "${LSFD_SIZE}" == $(stat -c %s /etc/passwd) ]
echo 'SIZE[STR]:' $?
+ lsfd_compare_dev "${TS_CMD_LSFD}" "${TS_CMD_FINDMNT}" "${EXPR}"
kill -CONT ${PID}
wait ${MKFDS_PID}
. $TS_TOPDIR/functions.sh
ts_init "$*"
+. $TS_SELF/lsfd-functions.bash
+
ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_CMD_FINDMNT"
+
ts_check_test_command "$TS_HELPER_MKFDS"
ts_check_prog "stat"
${TS_CMD_LSFD} -n -o ASSOC,MODE,TYPE,NAME,SOURCE,POS,MAJ:MIN,CHRDRV,DEVTYPE,RDEV -Q "${EXPR}"
echo 'ASSOC,MODE,TYPE,NAME,SOURCE,POS,MAJ:MIN,CHRDRV,DEVTYPE,RDEV': $?
+ lsfd_compare_dev "${TS_CMD_LSFD}" "${TS_CMD_FINDMNT}" "${EXPR}"
+
kill -CONT ${PID}
wait ${MKFDS_PID}
fi