gbmc-dump-ramoops: Add lastrebootcause file
Add a file to /tmp/ to indicate the last reboot is a crash or software reboot/AC power on
Tested:
File is created and shows correct value.
* On BMC reboot or powercycle:
```
root@host-nfd01:~# cat /tmp/lastrebootcause
0
```
* When crash happened:
```
root@host-nfd01:~# echo c > /proc/sysrq-trigger
root@host-nfd01:~# cat /tmp/lastrebootcause
1
```
Fusion-Link:
fusion2/fe0c6d71-3f74-3c78-9874-2172af1f4967
fusion2/64636aad-518a-39e6-970c-237774b7f2e8
fusion2/71647659-7eaa-34ca-9b67-853973902c4d
fusion2/65998a48-220c-3867-982c-c664450ce716
fusion2/6110bddc-a1b2-3f23-9f0b-d1754d159db1
Google-Bug-Id: 405059545
Change-Id: Ie0d8b90384d15d1bd72645fe3f262cdf655081f2
Signed-off-by: Anh Phan <anhphan@google.com>
diff --git a/recipes-google/ramoops/gbmc-dump-ramoops/gbmc-dump-ramoops.sh b/recipes-google/ramoops/gbmc-dump-ramoops/gbmc-dump-ramoops.sh
index 2d22488..952f5a0 100644
--- a/recipes-google/ramoops/gbmc-dump-ramoops/gbmc-dump-ramoops.sh
+++ b/recipes-google/ramoops/gbmc-dump-ramoops/gbmc-dump-ramoops.sh
@@ -8,8 +8,15 @@
dumpdir="/run/log/kdump"
mkdir -p ${dumpdir}
+# Create a file to indicate lastrebootcause
+reboot_reason_file="/tmp/lastrebootcause"
+# 0: normal reboot, 1: crash
+echo 0 > ${reboot_reason_file}
+
pmsgs=$(ls /sys/fs/pstore/pmsg-*) || exit 0
+echo 1 > ${reboot_reason_file}
+
# there should always be 1 pmsg file
# if not, only process the first one and delete them all at the end
pmsg=$(echo "$pmsgs" | head -n 1)