mirror of
https://github.com/openglow-org/forgefirm.git
synced 2026-09-27 16:51:12 -07:00
probes: reuse existing slot mounts; explicit -t ext4
The image's fstab keeps the factory slots mounted under /factory, and busybox mount's auto-type iteration against an already-mounted ext4 device provokes a cosmetic kernel 'Can't open blockdev' for each foreign-type claim (reproduced and pinned on the bench: ext3-typed mount of an ext4-held device prints it; ext4-typed does not). Probes now reuse an existing mountpoint from /proc/mounts and mount fresh targets with an explicit -t ext4.
This commit is contained in:
+15
-6
@@ -48,16 +48,25 @@ BOOTED_ROOT=$(sed -n 's/.*root=\([^ ]*\).*/\1/p' /proc/cmdline)
|
||||
# P_VERSION P_KERNEL(yes|no)
|
||||
probe_part () {
|
||||
P_PRESENT=no; P_STATE=unreadable; P_TYPE=unknown; P_VERSION=""; P_KERNEL=no
|
||||
P_MOUNTED=""
|
||||
[ -b "$1" ] || return 1
|
||||
P_PRESENT=yes
|
||||
if [ "$1" = "$BOOTED_ROOT" ]; then
|
||||
ROOT_DIR=""
|
||||
else
|
||||
ROOT_DIR="/tmp/ffboot.probe.$$"
|
||||
mkdir -p "$ROOT_DIR"
|
||||
if ! mount -o ro "$1" "$ROOT_DIR" 2>/dev/null; then
|
||||
rmdir "$ROOT_DIR" 2>/dev/null
|
||||
return 1
|
||||
# Reuse an existing mount (the image keeps the factory slots mounted
|
||||
# under /factory); a fresh mount is explicit -t ext4 - letting mount
|
||||
# iterate types provokes a cosmetic kernel "Can't open blockdev" for
|
||||
# each foreign-type claim against an already-mounted device.
|
||||
ROOT_DIR=$(sed -n "s|^$1 \([^ ]*\).*|\1|p" /proc/mounts | head -n 1)
|
||||
if [ -z "$ROOT_DIR" ]; then
|
||||
ROOT_DIR="/tmp/ffboot.probe.$$"
|
||||
P_MOUNTED=yes
|
||||
mkdir -p "$ROOT_DIR"
|
||||
if ! mount -o ro -t ext4 "$1" "$ROOT_DIR" 2>/dev/null; then
|
||||
rmdir "$ROOT_DIR" 2>/dev/null
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ -f "$ROOT_DIR/etc/forgefirm-version" ]; then
|
||||
@@ -70,7 +79,7 @@ probe_part () {
|
||||
P_STATE=empty
|
||||
fi
|
||||
[ -f "$ROOT_DIR/boot/zImage" ] && P_KERNEL=yes
|
||||
if [ -n "$ROOT_DIR" ]; then
|
||||
if [ -n "$P_MOUNTED" ]; then
|
||||
umount "$ROOT_DIR" 2>/dev/null
|
||||
rmdir "$ROOT_DIR" 2>/dev/null
|
||||
fi
|
||||
|
||||
@@ -76,21 +76,25 @@ archive_dev () {
|
||||
# read-only under /tmp (newer factory firmware has no /factory/imgN
|
||||
# mounts, and the rootfs is read-only).
|
||||
slot_probe () {
|
||||
S_TYPE=unknown; S_VER=""
|
||||
S_TYPE=unknown; S_VER=""; S_MOUNTED=""
|
||||
if [ "$1" = "$ACTIVE" ]; then
|
||||
RD=""
|
||||
else
|
||||
RD="/tmp/ffinstall.probe.$$"
|
||||
mkdir -p "$RD" || return 1
|
||||
mount -o ro "/dev/mmcblk2p$1" "$RD" 2>/dev/null \
|
||||
|| { rmdir "$RD" 2>/dev/null; return 1; }
|
||||
RD=$(sed -n "s|^/dev/mmcblk2p$1 \([^ ]*\).*|\1|p" /proc/mounts | head -n 1)
|
||||
if [ -z "$RD" ]; then
|
||||
RD="/tmp/ffinstall.probe.$$"
|
||||
S_MOUNTED=yes
|
||||
mkdir -p "$RD" || return 1
|
||||
mount -o ro -t ext4 "/dev/mmcblk2p$1" "$RD" 2>/dev/null \
|
||||
|| { rmdir "$RD" 2>/dev/null; return 1; }
|
||||
fi
|
||||
fi
|
||||
if [ -f "$RD/etc/forgefirm-version" ]; then
|
||||
S_TYPE=forgefirm; S_VER=$(cat "$RD/etc/forgefirm-version")
|
||||
elif [ -f "$RD/etc/version" ]; then
|
||||
S_TYPE=factory; S_VER=$(cat "$RD/etc/version")
|
||||
fi
|
||||
if [ -n "$RD" ]; then
|
||||
if [ -n "$S_MOUNTED" ]; then
|
||||
umount "$RD" 2>/dev/null
|
||||
rmdir "$RD" 2>/dev/null
|
||||
fi
|
||||
@@ -235,7 +239,7 @@ rm -f "$KEYFILE"
|
||||
# --- post-write verify --------------------------------------------------------
|
||||
MP="/tmp/ffinstall.verify.$$"
|
||||
mkdir -p "$MP"
|
||||
mount -o ro "/dev/mmcblk2p$TARGET" "$MP" || die "new rootfs does not mount"
|
||||
mount -o ro -t ext4 "/dev/mmcblk2p$TARGET" "$MP" || die "new rootfs does not mount"
|
||||
NEWVER=$(cat "$MP/etc/forgefirm-version" 2>/dev/null)
|
||||
[ -n "$NEWVER" ] || { umount "$MP"; die "new rootfs has no ForgeFIRM version stamp"; }
|
||||
[ -f "$MP/boot/zImage" ] || { umount "$MP"; die "new rootfs has no kernel"; }
|
||||
|
||||
Reference in New Issue
Block a user