summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerhii Voloshynov <serhii.voloshynov@globallogic.com>2023-05-22 13:05:41 +0300
committerJohn Klug <john.klug@multitech.com>2023-06-07 11:47:20 -0500
commitefe6f328a6af0076f9f626a606e0cfdba08a5dee (patch)
tree18ac0eb8534335707aead1bfae765c4f16b817a6
parent776d0e4e15cf0ac96730b15cdb505ccbd1e06371 (diff)
downloadmeta-mlinux-efe6f328a6af0076f9f626a606e0cfdba08a5dee.tar.gz
meta-mlinux-efe6f328a6af0076f9f626a606e0cfdba08a5dee.tar.bz2
meta-mlinux-efe6f328a6af0076f9f626a606e0cfdba08a5dee.zip
failed to perform firmware upgrade and reset to factory defaults when there is no space on /var/persistent GP-1997
use u-boot env as erase persistent flag
-rw-r--r--recipes-core/multitech/overlayfs-init-ubi/overlayfs.init43
1 files changed, 29 insertions, 14 deletions
diff --git a/recipes-core/multitech/overlayfs-init-ubi/overlayfs.init b/recipes-core/multitech/overlayfs-init-ubi/overlayfs.init
index eee3aab..445bcde 100644
--- a/recipes-core/multitech/overlayfs-init-ubi/overlayfs.init
+++ b/recipes-core/multitech/overlayfs-init-ubi/overlayfs.init
@@ -12,7 +12,7 @@ USER_PARTITION="ubi0:user-data"
# Erase the file system
DO_ERASE_PERSISTENT=$(fw_printenv erase_persistent_f | cut -d '"' -f2 | grep -Eo '[0-9]+$' || true)
# Remove files not hidden
-DO_ERASE_ALL_EXCEPT_PERSISTENT=$(fw_printenv default_reset_f | cut -d '"' -f2 | grep -Eo '[0-9]+$' || true)
+DO_CLEAR_PERSISTENT=$(fw_printenv default_reset_f | cut -d '"' -f2 | grep -Eo '[0-9]+$' || true)
pid=$$
prefix="<3>overlayrootfs-generator[${pid}]: "
@@ -43,23 +43,37 @@ my_switch_root() {
for f in $fs ; do
if [[ -d $NEW_ROOT/$f ]] ; then
loginfo "my_switch_root: mount -o noatime,move --bind $f $NEW_ROOT/$f"
- mount -o noatime,move --bind "$f" "$NEW_ROOT/$f"
+ mount -o noatime,move --bind $f $NEW_ROOT/$f
else
# loginfo "my_switch_root: Skipping $NEW_ROOT/$f"
:
fi
done
- /sbin/pivot_root "$NEW_ROOT" "$NEW_ROOT"/orig
+ /sbin/pivot_root $NEW_ROOT $NEW_ROOT/orig
}
-do_erase_all_except_persistent() {
- # Delete all files and folders except for the "${MNT_USER}/.persistent" directory.
+do_remove_old() {
+ shopt -s dotglob
+ rm -rf $MNT_USER/*.old
+ shopt -u dotglob
+}
+
+# select files for deletion
+do_clear_old() {
+ # when "clear user data" is requested - mark all non-hidden files for deletion
loginfo "Clearing user data. Persistent data will be left "
- rm -rf "${MNT_USER:?}/"*
+
+ for FILE_PATH in "$MNT_USER"/*; do
+ FILE_NAME=$(basename "$FILE_PATH")
+ # rename all files and folders that exist in /mnt/user
+ mv "$FILE_PATH" "$MNT_USER/$FILE_NAME.old" 2>&1 | logpipe
+ done
+ do_remove_old
+ fw_setenv default_reset_f 0
}
# Most efficient way to clear UBIFS file system
-do_erase_persistent() {
+do_erase_old() {
loginfo "Erasing user data"
# Sys must be mounted to use ubifs utilities
mount -t sysfs sysfs /sys
@@ -71,9 +85,10 @@ do_erase_persistent() {
umount -l $MNT_USER
loginfo "Erase user-data partition $DEV"
# Would be nice if ubiupdatevol took volume names instead of numbers
- ubiupdatevol "${DEV}" -t 2>&1 | logpipe
+ ubiupdatevol ${DEV} -t 2>&1 | logpipe
mnt_user
+ fw_setenv erase_persistent_f 0
}
do_rw_mount() {
@@ -81,13 +96,13 @@ do_rw_mount() {
mount -t tmpfs inittemp /mnt
mnt_user # user_data is now accessible
+ do_remove_old
+
if [[ "$DO_ERASE_PERSISTENT" -eq 1 ]] ; then
- do_erase_persistent
- fw_setenv erase_persistent_f 0
- fw_setenv default_reset_f 0
- elif [[ "$DO_ERASE_ALL_EXCEPT_PERSISTENT" -eq 1 ]] ; then
- do_erase_all_except_persistent
+ do_erase_old
fw_setenv default_reset_f 0
+ elif [[ "$DO_CLEAR_PERSISTENT" -eq 1 ]] ; then
+ do_clear_old
fi
mkdir -p $UPPERDIR $WORKDIR $OVERLAY $USER_ORIG ${MNT_USER}/.persistent
@@ -108,7 +123,7 @@ do_rw_mount() {
cgroupmnts=$(sed -r -e 's/[^[:space:]]*[[:space:]]//' -e 's/[[:space:]]+.*//g' /proc/mounts | grep '^/orig')
for mp in ${cgroupmnts} ; do
if [[ $mp != /orig ]] && [[ $mp != /orig/mnt* ]] && [[ -d $mp ]] ; then
- umount -l "$mp" >/dev/null 2>&1
+ umount -l $mp >/dev/null 2>&1
fi
done
}