From 944c9a7217309451dfb73a92ec09f12e6772dbc1 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Sun, 2 Apr 2023 10:07:18 +0200 Subject: T5136: properly unmount filesystems after installation (cherry picked from commit f34e9028252034cf17dbf380a2cded8bf14c71c2) --- scripts/install/install-functions | 24 ++++++++++++++++++++++-- scripts/install/install-image-existing | 9 +++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/scripts/install/install-functions b/scripts/install/install-functions index b3ec42c1..feeeb489 100755 --- a/scripts/install/install-functions +++ b/scripts/install/install-functions @@ -86,10 +86,10 @@ tolower () { } # Validates a user response. Returns the response if valid. -# Returns the default is the user just hits enter. +# Returns the default is the user just hits enter. # Returns nothing if not valid. Default parameter is $1. # Options are in $2. If options are defined return must be a member -# of the enum. +# of the enum. get_response () { local ldefault=$(tolower "$1") local loptions=$(tolower "$2") @@ -370,6 +370,26 @@ EOF return 1 } +# try to unmount. log any errors and return the appropriate status. +# $1: arguments for umount +try_unmount () +{ + args="$*" + output=$(eval "umount $args 2>&1") + status=$? + if [ $status == 0 ]; then + return 0 + fi + # error + cat < Date: Mon, 3 Apr 2023 08:02:24 +0200 Subject: T5136: do not rm -rf if unmount fails Commit f34e9028 ("T5136: properly unmount filesystems after installation") assumed it would be a good idea to simply rm -rf the new root folder. This could have a bad, non booting side effect. Warn user if unmount fails but the filesystem is synced anyway. The rest is handled by the Kernel on reboot. (cherry picked from commit 964e06bc3404b096d55e939b2bdb8d9c61a6a9b9) --- scripts/install/install-image-existing | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/install/install-image-existing b/scripts/install/install-image-existing index abbd1421..feba6683 100755 --- a/scripts/install/install-image-existing +++ b/scripts/install/install-image-existing @@ -280,7 +280,6 @@ fi # unmount filesystems if ! try_unmount "--read-only $INST_ROOT $READ_ROOT"; then - rm -rf $REL_ROOT failure_exit 'Failed to unmount new squashfs image.' fi -- cgit v1.2.3