From ec0ba3c1ddd26ccd7bfee27b2b900f7c73401ad9 Mon Sep 17 00:00:00 2001 From: Milton Miller Date: Tue, 23 Feb 2016 21:48:48 -0600 Subject: initfs: Add flash clear and update during init Add code to clear the rwfs (preserving files from the whitelist) during init, by a command line option. Also allow it to be triggered by the file system not being a jffs2. A console user can download images to /run/initramfs/ at the debug-init-sh prompt for manual update. Also add code but do not enable detecting images loaded into initramfs / for future update options. If enabled a custom initrd with update images can be bulit (it would not fit in flash and need to be netbooted). Signed-off-by: Milton Miller --- .../obmc-phosphor-initfs/files/obmc-init.sh | 54 +++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) (limited to 'meta-phosphor/common') diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh index f2fe938a8..12c5a2f1b 100644 --- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh +++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh @@ -85,13 +85,21 @@ rwfs=$(findmtd rwfs) rodev=/dev/mtdblock${rofs#mtd} rwdev=/dev/mtdblock${rwfs#mtd} +# Set to y for yes, anything else for no. +force_rwfst_jffs2=y +flash_images_before_init=n + rofst=squashfs rwfst=$(probe_fs_type $rwdev) roopts=ro rwopts=rw +image=/run/initramfs/image- +trigger=${image}rwfs + init=/sbin/init -fsck=/sbin/fsck.$rwfst +fsckbase=/sbin/fsck. +fsck=$fsckbase$rwfst fsckopts=-a echo rofs = $rofs $rofst rwfs = $rwfs $rwfst @@ -101,6 +109,50 @@ then debug_takeover "Debug initial shell requested by command line." fi +# If there are images in root move them to run/initramfs/ now. +imagebasename=${image##*/} +if test -n "${imagebasename}" -a "x$flash_images_before_init" = xy && + ls /${imagebasename}* > /dev/null 2>&1 +then + echo "Pending flash updates found." + mv /${imagebasename}* ${image%$imagebasename} +fi + +if grep -w clean-rwfs-filesystem /proc/cmdline +then + echo "Cleaning of read-write overlay filesystem requested." + touch $trigger +fi + +if test "x$force_rwfst_jffs2" = xy -a $rwfst != jffs2 -a ! -f $trigger +then + echo "Converting read-write overlay filesystem to jffs2 forced." + touch $trigger +fi + +if ls $image* > /dev/null 2>&1 +then + if ! test -x /update + then + debug_takeover "Flash update requested but /update missing!" + elif test -f $trigger -a ! -s $trigger + then + echo "Saving selected files from read-write overlay filesystem." + /update && rm -f $image* + echo "Clearing read-write overlay filesystem." + flash_eraseall /dev/$rwfs + echo "Restoring saved files to read-write overlay filesystem." + touch $trigger + /update + rm -rf /save $trigger + else + /update && rm -f $image* + fi + + rwfst=$(probe_fs_type $rwdev) + fsck=$fsckbase$rwfst +fi + mount $rodev $rodir -t $rofst -o $roopts if test -x $rodir$fsck -- cgit v1.2.1