diff options
author | Serhii Voloshynov <serhii.voloshynov@globallogic.com> | 2023-05-29 13:10:06 +0300 |
---|---|---|
committer | Serhii Voloshynov <serhii.voloshynov@globallogic.com> | 2023-05-29 13:10:06 +0300 |
commit | b61797fd00df4dd9f1dbbb10a85c4de9e8a97f35 (patch) | |
tree | ca2a9876cb80218eef418177fc13031c58d2e94d | |
parent | 778a912b4c0f78af3793a6c2a9cbe10c08fd6175 (diff) | |
download | meta-mlinux-b61797fd00df4dd9f1dbbb10a85c4de9e8a97f35.tar.gz meta-mlinux-b61797fd00df4dd9f1dbbb10a85c4de9e8a97f35.tar.bz2 meta-mlinux-b61797fd00df4dd9f1dbbb10a85c4de9e8a97f35.zip |
fix after review
-rw-r--r-- | recipes-core/multitech/overlayfs-init-ubi/overlayfs.init | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/recipes-core/multitech/overlayfs-init-ubi/overlayfs.init b/recipes-core/multitech/overlayfs-init-ubi/overlayfs.init index 263aa62..c5d3d37 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,22 +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_nonpersistent() { +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 " - rm -rf $MNT_USER/* + rm -rf "${MNT_USER:?}/"* } # Most efficient way to clear UBIFS file system -do_erase_all() { +do_erase_persistent() { loginfo "Erasing user data" # Sys must be mounted to use ubifs utilities mount -t sysfs sysfs /sys @@ -70,10 +71,11 @@ do_erase_all() { 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 + fw_setenv default_reset_f 0 } do_rw_mount() { @@ -82,10 +84,9 @@ do_rw_mount() { mnt_user # user_data is now accessible if [[ "$DO_ERASE_PERSISTENT" -eq 1 ]] ; then - do_erase_all - fw_setenv default_reset_f 0 - elif [[ "$DO_CLEAR_PERSISTENT" -eq 1 ]] ; then - do_remove_nonpersistent + do_erase_persistent + elif [[ "$DO_ERASE_ALL_EXCEPT_PERSISTENT" -eq 1 ]] ; then + do_erase_all_except_persistent fw_setenv default_reset_f 0 fi @@ -109,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 } |