From f6fa4976d1d2eabc97e3575d719c7ee8b18f7971 Mon Sep 17 00:00:00 2001 From: "Guilherme G. Piccoli" Date: Wed, 21 Dec 2022 15:12:47 -0300 Subject: [PATCH] save-dumps: Guard for multiple ramoops backend usage The main goal of this tooling is to collect panic logs, but pstore/ramoops could be set to use other backends, like the console or ftrace ones. With that, save-dumps may end-up collecting these other logs as well, which is out of the scope - hence, fix it to only deal with "dmesg-ramoops" logs. While at it, check the existence of the pstore file; the loop might end-up having a null element, so just mimic the kdump loop and check if it's a valid/existing file. Signed-off-by: Guilherme G. Piccoli --- save-dumps.sh.in | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/save-dumps.sh.in b/save-dumps.sh.in index 90ae2c7..4a54d0e 100644 --- a/save-dumps.sh.in +++ b/save-dumps.sh.in @@ -24,12 +24,14 @@ if [ "${PSTORE_CNT}" -ne 0 ]; then LOOP_CNT=0 while [ "${PSTORE_CNT}" -gt 0 ]; do - PSTORE_FILE="$(find /sys/fs/pstore/* | grep ramoops | sort | head -n1)" + PSTORE_FILE="$(find /sys/fs/pstore/* | grep dmesg-ramoops | sort | head -n1)" SAVED_FILE="${PSTORE_FOLDER}/dmesg-pstore.${CURRENT_TSTAMP}-${LOOP_CNT}" - cat "${PSTORE_FILE}" > "${SAVED_FILE}" - sync "${SAVED_FILE}" - rm -f "${PSTORE_FILE}" + if [ -e "${PSTORE_FILE}" ]; then + cat "${PSTORE_FILE}" > "${SAVED_FILE}" + sync "${SAVED_FILE}" + rm -f "${PSTORE_FILE}" + fi PSTORE_CNT=$((PSTORE_CNT - 1)) LOOP_CNT=$((LOOP_CNT + 1))