gbmc-bridge: Fix RWFS check Some platforms mount the RWFS as mtd:rwfs instead of /dev/mtdblock<N>, this breaks the check in the purge script and causes it to overwrite the JFFS2 while it's still mounted during netboot. Tested: Manually reran the hook to verify that it's following the correct path on the known problematic platform. Google-Bug-Id: 526772581 Google-Bug-Id: 532737092 Change-Id: I35eba8636e661318bd8c7882dbf6685a051cfa13 Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/recipes-google/networking/gbmc-bridge/49-purge-rwfs.sh b/recipes-google/networking/gbmc-bridge/49-purge-rwfs.sh index 7ba5597..7346a2e 100644 --- a/recipes-google/networking/gbmc-bridge/49-purge-rwfs.sh +++ b/recipes-google/networking/gbmc-bridge/49-purge-rwfs.sh
@@ -16,11 +16,11 @@ [ -z "${gbmc_purge_rwfs-}" ] || return # fs util functions from obmc-init.sh -findmtd() { +findmtdnum() { local m m=$(grep -xl "$1" /sys/class/mtd/*/name) m=${m%/name} - m=${m##*/} + m=${m##*/mtd} echo "$m" } @@ -58,23 +58,23 @@ update_netboot_status "rwfs_check" "RWFS purge needed" "SUCCESS" update_netboot_status "rwfs_set" "Setting RWFS purge flag" "START" - local google_dir rwfs rwdev rwfst + local mtd_num + if ! mtd_num=$(findmtdnum rwfs) || [ -z "$mtd_num" ]; then + update_netboot_status "rwfs_check" "Finding RWFS MTD number failed" "FAIL" + return 1 + fi - rwfs=$(findmtd rwfs) - rwdev="/dev/mtdblock${rwfs#mtd}" - rwfst="jffs2" - - google_dir="/var/google" - if ! grep -q "$rwdev" /proc/mounts; then + local google_dir="/var/google" + if ! grep -qE "^(mtd:rwfs|/dev/mtdblock${mtd_num}|/dev/mtd${mtd_num}) " /proc/mounts; then update_netboot_status "rwfs_mfg_clear" "Erasing RWFS for manufacture image" "START" - flash_eraseall "/dev/$rwfs" || true + flash_eraseall "/dev/mtd${mtd_num}" || true update_netboot_status "rwfs_mfg_clear" "Erasing RWFS passed" "SUCCESS" update_netboot_status "rwfs_mfg_mount" "Mouting RWFS started" "START" mkdir -p /run/rwfsdir || return - if mount "$rwdev" /run/rwfsdir -t "$rwfst" -o rw; then + if mount mtd:rwfs /run/rwfsdir -t jffs2 -o rw; then google_dir="/run/rwfsdir/cow/var/google" update_netboot_status "rwfs_mfg_mount" "RWFS mounted" "SUCCESS" else