1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-11-24 00:07:11 +02:00

[package] block-extroot: Merged 24230 from trunk: Added an md5sum to extroot and underlying root, which is used to ensure that extroot is not mounted after sysupgrade (until user deals with the necessary changes to the extroot)

git-svn-id: svn://svn.openwrt.org/openwrt/branches/backfire@24231 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
cshore 2010-12-03 21:20:57 +00:00
parent 84217b4045
commit 721b6073c5
3 changed files with 57 additions and 0 deletions

View File

@ -53,6 +53,7 @@ define Package/block-extroot/install
$(INSTALL_DATA) ./files/extmount.sh $(1)/lib/functions/
$(INSTALL_DIR) $(1)/lib/preinit
$(INSTALL_DATA) ./files/50_determine_usb_root $(1)/lib/preinit/
$(INSTALL_DATA) ./files/55_determine_extroot_sysupgrade $(1)/lib/preinit/
$(INSTALL_DATA) ./files/60_pivot_usb_root $(1)/lib/preinit/
$(INSTALL_DIR) $(1)/lib/preinit
echo "extroot_settle_time=\"$(CONFIG_EXTROOT_SETTLETIME)\"" >$(1)/lib/preinit/00_extroot.conf

View File

@ -18,6 +18,7 @@ determine_external_root() {
if [ "$jffs" = "/tmp/overlay" ] && [ -r "/tmp/overlay/etc/config/fstab" ]; then
UCI_CONFIG_DIR="/tmp/overlay/etc/config"
ER_IS_SQUASHFS=true
ER_OVERLAY_PREFIX="/tmp/overlay"
fi
# For squashfs on firstboot root_device will be tmpfs for the ramoverlay,

View File

@ -0,0 +1,55 @@
#!/bin/sh
# Copyright (C) 2010 Daniel Dickinson
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
check_set_md5sum() {
local er_md5sum_file
er_md5sum_file="${ER_OVERLAY_PREFIX}/.extroot.md5sum"
local er_extroot_md5sum
if [ -f $md5sum_file ]; then
er_extroot_md5sum="$(cat $er_md5sum_file)"
fi
local er_extroot_overlay_md5sum
if [ -f "/overlay/etc/extroot.md5sum" ]; then
er_extroot_overlay_md5sum="$(cat /overlay/.extroot.md5sum)"
fi
if [ -z "$er_extroot_overlay_md5sum" ]; then
cat $er_md5sum_file >/overlay/.extroot.md5sum
elif [ "$er_extroot_overlay_md5sum" != "$er_extroot_md5sum" ]; then
pi_extroot_mount_success="false"
mkdir -p /tmp/overlay-disabled
mount --move /overlay /tmp/overlay-disabled
fi
}
set_jffs_md5sum() {
# We do this anytime block-extroot exists, even on the first boot with
# no extroot defined.
local er_md5sum_file
er_md5sum_file="${ER_OVERLAY_PREFIX}/.extroot.md5sum"
local er_extroot_md5sum
if [ -f $er_md5sum_file ]; then
er_extroot_md5sum="$(cat $er_md5sum_file)"
fi
if [ -z "$er_extroot_md5sum" ]; then
dd if=/dev/urandom count=32 bs=1k 2>/dev/null | md5sum | cut -f1 -d\ >$er_md5sum_file
fi
}
determine_extroot_sysupgrade() {
check_skip || set_jffs_md5sum
check_skip || [ "$pi_extroot_mount_success" != "true" ] || {
check_set_md5sum
}
}
boot_hook_add preinit_mount_root determine_extroot_sysupgrade