summaryrefslogtreecommitdiff
path: root/recipes-core
diff options
context:
space:
mode:
authorjeff <jhatch@multitech.com>2023-06-06 08:56:59 -0500
committerjeff <jhatch@multitech.com>2023-06-06 08:56:59 -0500
commit94e00d72d8c8e8a12838ac8a818f082215f87cd1 (patch)
tree1f2b998f7957abe12176b604f304ec0b0db93cab /recipes-core
parentfaec7c38186ec22290d1cfc87e7a9b8406492f76 (diff)
parentff436ac2e18c6650e8fefbe5d905a3ea4d391825 (diff)
downloadmeta-mlinux-94e00d72d8c8e8a12838ac8a818f082215f87cd1.tar.gz
meta-mlinux-94e00d72d8c8e8a12838ac8a818f082215f87cd1.tar.bz2
meta-mlinux-94e00d72d8c8e8a12838ac8a818f082215f87cd1.zip
Merge branch 'sv/fix-reset-to-default-mtcap3' into 6
Diffstat (limited to 'recipes-core')
-rw-r--r--recipes-core/multitech/overlayfs-init-ubi/overlayfs.init43
1 files changed, 14 insertions, 29 deletions
diff --git a/recipes-core/multitech/overlayfs-init-ubi/overlayfs.init b/recipes-core/multitech/overlayfs-init-ubi/overlayfs.init
index 9e60961..c6a3ace 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_CLEAR_PERSISTENT=$(fw_printenv default_reset_f | cut -d '"' -f2 | grep -Eo '[0-9]+$' || true)
+DO_ERASE_ALL_EXCEPT_PERSISTENT=$(fw_printenv default_reset_f | cut -d '"' -f2 | grep -Eo '[0-9]+$' || true)
pid=$$
prefix="<3>overlayrootfs-generator[${pid}]: "
@@ -43,37 +43,23 @@ 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_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
+do_erase_all_except_persistent() {
+ # Delete all files and folders except for the "${MNT_USER}/.persistent" directory.
loginfo "Clearing user data. Persistent data will be left "
-
- 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
+ rm -rf "${MNT_USER:?}/"*
}
# Most efficient way to clear UBIFS file system
-do_erase_old() {
+do_erase_persistent() {
loginfo "Erasing user data"
# Sys must be mounted to use ubifs utilities
mount -t sysfs sysfs /sys
@@ -85,10 +71,9 @@ do_erase_old() {
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() {
@@ -96,13 +81,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_old
+ 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
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
@@ -125,7 +110,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
}