]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
refactor(overlayfs): exit early in case LiveOS_rootfs is mounted
authorBenjamin Drung <benjamin.drung@canonical.com>
Mon, 13 Apr 2026 11:10:20 +0000 (13:10 +0200)
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>
Thu, 16 Apr 2026 10:56:06 +0000 (06:56 -0400)
Increase the code readability by exiting early in case LiveOS_rootfs is
already mounted.

modules.d/70overlayfs/mount-overlayfs.sh

index dbae5d51c7f961bbb369c4e680b95646e1d1088d..6adc2d7b18c519f8653be9b1410e9a6cfca34f66 100755 (executable)
@@ -20,6 +20,9 @@ else
     ovlfs=lowerdir=/run/rootfsbase
 fi
 
-if ! strstr "$(cat /proc/mounts)" LiveOS_rootfs; then
-    mount -t overlay LiveOS_rootfs -o "$ovlfs",upperdir=/run/overlayfs,workdir=/run/ovlwork "$NEWROOT"
+if strstr "$(cat /proc/mounts)" LiveOS_rootfs; then
+    # LiveOS_rootfs already mounted
+    return 0
 fi
+
+mount -t overlay LiveOS_rootfs -o "$ovlfs",upperdir=/run/overlayfs,workdir=/run/ovlwork "$NEWROOT"