mount-fix simplification

- No more inotifywait or overlay-init-watchdog

- Instead, real_rootfs rc.d is mounted back on top of the overlay to allow read/write to it. The bootup rc.d and resulting location rc.d become the same and as a result allowing init to behave naturally without extra help.

- Must be on the latest sdxpinn-patch version in order to upgrade this package. The old prerm scripts need removed before upgrading.
This commit is contained in:
Cameron Thompson
2025-01-25 22:33:05 -05:00
parent cd60b7b6db
commit dc16a3c9fe
23 changed files with 472 additions and 508 deletions

View File

@@ -98,8 +98,12 @@ handle_old_firmware() {
/bin/mount --move /real_rootfs/cache /cache
/bin/mount --move /real_rootfs/data /data
# Synchronize between /etc/rc.d and /real_rootfs/etc/rc.d
synchronize_rc_d "/etc/rc.d" "/real_rootfs/etc/rc.d"
# Synchronize rc.d
synchronize_rc_d "/real_rootfs/etc/rc.d" "/etc/rc.d"
# Bind the orignal rc.d back and make writable
/bin/mount -o bind,rw /real_rootfs/etc/rc.d /etc/rc.d
/bin/mount -o remount,rw /etc/rc.d
# Final logs and remount the original root as read-only
/bin/echo "...and we're back! The original root now lives at /real_rootfs"
@@ -192,12 +196,15 @@ handle_new_firmware() {
/bin/mount --move /real_rootfs/systemrw /systemrw
/bin/mount --move /real_rootfs/persist /persist
# Synchronize between rc.d layer 1 to Final
synchronize_rc_d "/real_rootfs/etc/rc.d" "/etc/rc.d"
# Synchronize between /etc/rc.d and /real_rootfs/etc/rc.d
synchronize_rc_d "/etc/rc.d" "/real_rootfs/etc/rc.d"
# Synchronize between /etc/rc.d and /usrdata/etc/rc.d
synchronize_rc_d "/etc/rc.d" "/usrdata/etc/rc.d"
# Synchronize between rc.d layer 2 to Final
synchronize_rc_d "/usrdata/etc/rc.d" "/etc/rc.d"
# Bind the orignal rc.d back and make writable
/bin/mount -o bind,rw /real_rootfs/etc/rc.d /etc/rc.d
/bin/mount -o remount,rw /etc/rc.d
# Final logs and remount the original root as read-only
/bin/echo "...and we're back! The original root now lives at /real_rootfs"
@@ -211,7 +218,6 @@ handle_new_firmware() {
synchronize_rc_d() {
local source_dir="$1"
local target_dir="$2"
/bin/echo "Synchronizing $source_dir with $target_dir"
for link in "$source_dir"/*; do
if [ -L "$link" ]; then
@@ -222,13 +228,12 @@ synchronize_rc_d() {
fi
fi
done
for link in "$target_dir"/*; do
if [ -L "$link" ]; then
link_name=$(basename "$link")
if [ ! -e "$source_dir/$link_name" ]; then
/bin/echo "Removing $link_name from $target_dir"
rm "$target_dir/$link_name"
/bin/echo "Copying $link_name to $source_dir"
cp -a "$link" "$source_dir/$link_name"
fi
fi
done
@@ -286,7 +291,7 @@ stop_handle_new_firmware() {
/bin/umount -lf /rootfs >/dev/null 2>&1
# Mount layer 2 /etc back
/bin/mount -t ubifs -o rw,relatime,bulk_read,assert=read-only,ubi=2,vol=0 /dev/ubi2_0 /etc
/bin/mount --bind /usrdata/etc /etc
# Mount layer 3 /etc back
/bin/mount -t overlay overlay -o lowerdir=/etc,upperdir=/usrdata/overlay-work/etc-upper,workdir=/usrdata/overlay-work/.etc-work /etc