9f65cc
From 122da496446405e60a6eb5b037af263b5fd14378 Mon Sep 17 00:00:00 2001
9f65cc
From: Kairui Song <kasong@redhat.com>
9f65cc
Date: Mon, 15 Feb 2021 23:05:08 +0800
9f65cc
Subject: [PATCH] refactor(squash): don't record mount points in text file
9f65cc
9f65cc
The squasn mount points are recorded in text file so later clean up
9f65cc
script can umount them, this is not needed, the mount points are fixed
9f65cc
so just detect the umount by hardcoded pattern.
9f65cc
9f65cc
(cherry picked from commit bdd194bb8c0427921b87b4dce16c05e18e0c2fb0)
9f65cc
9f65cc
Resolves: #1959336
9f65cc
---
9f65cc
 modules.d/99squash/clear-squash.sh | 10 +++++-----
9f65cc
 modules.d/99squash/init-squash.sh  |  8 --------
9f65cc
 2 files changed, 5 insertions(+), 13 deletions(-)
9f65cc
9f65cc
diff --git a/modules.d/99squash/clear-squash.sh b/modules.d/99squash/clear-squash.sh
9f65cc
index 1d626f98..4f357817 100755
9f65cc
--- a/modules.d/99squash/clear-squash.sh
9f65cc
+++ b/modules.d/99squash/clear-squash.sh
9f65cc
@@ -1,6 +1,6 @@
9f65cc
 #!/bin/bash
9f65cc
-SQUASH_MNT_REC=/squash/mounts
9f65cc
-
9f65cc
-mapfile -t SQUASH_MNTS < $SQUASH_MNT_REC
9f65cc
-
9f65cc
-umount --lazy -- "${SQUASH_MNTS[@]}"
9f65cc
+mnt="/squash/root"
9f65cc
+for dir in jsquash/root/*; do
9f65cc
+	mnt="$mnt ${dir#$SQUASH_MNT}"
9f65cc
+done
9f65cc
+umount --lazy -- $mnt
9f65cc
diff --git a/modules.d/99squash/init-squash.sh b/modules.d/99squash/init-squash.sh
9f65cc
index ecb6cc58..fee0105e 100755
9f65cc
--- a/modules.d/99squash/init-squash.sh
9f65cc
+++ b/modules.d/99squash/init-squash.sh
9f65cc
@@ -3,9 +3,6 @@ PATH=/bin:/sbin
9f65cc
 
9f65cc
 SQUASH_IMG=/squash/root.img
9f65cc
 SQUASH_MNT=/squash/root
9f65cc
-SQUASH_MNT_REC=/squash/mounts
9f65cc
-
9f65cc
-echo $SQUASH_MNT > $SQUASH_MNT_REC
9f65cc
 
9f65cc
 # Following mount points are neccessary for mounting a squash image
9f65cc
 
9f65cc
@@ -34,9 +31,6 @@ if [ $? != 0 ]; then
9f65cc
     echo "Unable to setup overlay module"
9f65cc
 fi
9f65cc
 
9f65cc
-# These modules are no longer needed, delete to save memory
9f65cc
-rm -rf /usr/lib/modules/
9f65cc
-
9f65cc
 [ ! -d "$SQUASH_MNT" ] && \
9f65cc
 	mkdir -m 0755 -p $SQUASH_MNT
9f65cc
 
9f65cc
@@ -59,8 +53,6 @@ for file in $SQUASH_MNT/*; do
9f65cc
 
9f65cc
 	mount -t overlay overlay -o\
9f65cc
 		lowerdir=$lowerdir,upperdir=$upperdir,workdir=$workdir $mntdir
9f65cc
-
9f65cc
-	echo $mntdir >> $SQUASH_MNT_REC
9f65cc
 done
9f65cc
 
9f65cc
 exec /init.orig
9f65cc