diff mbox series

common/rc: _add_dmesg_filter returns when RESULT_DIR is null

Message ID 20250318132459.152699-1-zlang@kernel.org (mailing list archive)
State New
Headers show
Series common/rc: _add_dmesg_filter returns when RESULT_DIR is null | expand

Commit Message

Zorro Lang March 18, 2025, 1:24 p.m. UTC
I always hit below error on a system with readonly rootfs:

  ++ _xfs_prepare_for_eio_shutdown /dev/loop0
  ...
  ++ _add_dmesg_filter 'Internal error'
  ++ local 'regexp=Internal error'
  ++ local filter_file=/dmesg_filter
  ++ '[' '!' -e /dmesg_filter ']'
  ++ echo 'Internal error'
  ./common/rc: line 4716: /dmesg_filter: Read-only file system

The RESULT_DIR is null, due to xfstests/check calls _test_mount and
_scratch_mount before RESULT_DIR creation. And _test_mount does
_prepare_for_eio_shutdown -> _xfs_prepare_for_eio_shutdown ->
_add_dmesg_filter "Internal error" when RESULT_DIR is null.

Signed-off-by: Zorro Lang <zlang@kernel.org>
---
 common/rc | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/common/rc b/common/rc
index e51686389..01e89747d 100644
--- a/common/rc
+++ b/common/rc
@@ -4716,6 +4716,12 @@  _check_dmesg_filter()
 # Add a simple expression to the default dmesg filter
 _add_dmesg_filter()
 {
+	# This function might be called before having RESULT_DIR, do nothing
+	# if RESULT_DIR isn't created
+	if [ ! -d "${RESULT_DIR}" ];then
+		return 1
+	fi
+
 	local regexp="$1"
 	local filter_file="${RESULT_DIR}/dmesg_filter"