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 <gpiccoli@igalia.com>
This commit is contained in:
Guilherme G. Piccoli
2022-12-21 15:12:47 -03:00
parent a6e1fdf249
commit f6fa4976d1

View File

@ -24,12 +24,14 @@ if [ "${PSTORE_CNT}" -ne 0 ]; then
LOOP_CNT=0 LOOP_CNT=0
while [ "${PSTORE_CNT}" -gt 0 ]; do 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}" SAVED_FILE="${PSTORE_FOLDER}/dmesg-pstore.${CURRENT_TSTAMP}-${LOOP_CNT}"
cat "${PSTORE_FILE}" > "${SAVED_FILE}" if [ -e "${PSTORE_FILE}" ]; then
sync "${SAVED_FILE}" cat "${PSTORE_FILE}" > "${SAVED_FILE}"
rm -f "${PSTORE_FILE}" sync "${SAVED_FILE}"
rm -f "${PSTORE_FILE}"
fi
PSTORE_CNT=$((PSTORE_CNT - 1)) PSTORE_CNT=$((PSTORE_CNT - 1))
LOOP_CNT=$((LOOP_CNT + 1)) LOOP_CNT=$((LOOP_CNT + 1))