aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonard Kugis <leonard@kug.is>2025-10-14 21:19:35 +0200
committerLeonard Kugis <leonard@kug.is>2025-10-14 21:19:35 +0200
commite0ea95554a3ee88e82034deda05d7c660e8f09d0 (patch)
treef12eba769aeff52a93d1a42238b631c1feaa4ded
parent5bfba451f9ea6321de03839b933b4a270cfdaaa3 (diff)
downloadmagisk-fstab-e0ea95554a3ee88e82034deda05d7c660e8f09d0.tar.gz
fstab: Corrected mountpoint checking
Mountpoints will no longer be unneccessarily created if already existent.
-rw-r--r--fstab.sh15
1 files changed, 10 insertions, 5 deletions
diff --git a/fstab.sh b/fstab.sh
index ca4beee..cf783ca 100644
--- a/fstab.sh
+++ b/fstab.sh
@@ -168,6 +168,12 @@ is_swap_active() {
return 1
}
+exists_root() {
+ p="$1"
+ # shellcheck disable=SC2086
+ su $su_options -c "test -e $(shell_quote "$p")"
+}
+
log "$0 $args"
# --- process each fstab line ---
@@ -229,7 +235,7 @@ while IFS= read -r rawline || [ -n "$rawline" ]; do
err "Line $line_no: bindfs not available but requested (vfstype=bindfs)."
continue
fi
- if [ ! -e "$fs_file" ]; then
+ if ! exists_root "$fs_file"; then
log "Line $line_no: Creating mountpoint $fs_file"
run_root mkdir -p "$fs_file" || {
err "Line $line_no: mkdir failed for $fs_file"
@@ -249,11 +255,11 @@ while IFS= read -r rawline || [ -n "$rawline" ]; do
# --- bind / rbind mounts ---
echo "$fs_mntops" | grep -q bind && {
- if is_mounted("$fs_file"); then
+ if is_mounted "$fs_file"; then
log "Line $line_no: $fs_file already mounted — skipped."
continue
fi
- if [ ! -e "$fs_file" ]; then
+ if ! exists_root "$fs_file"; then
log "Line $line_no: Creating mountpoint $fs_file"
run_root mkdir -p "$fs_file" || {
err "Line $line_no: mkdir failed for $fs_file"
@@ -276,7 +282,7 @@ while IFS= read -r rawline || [ -n "$rawline" ]; do
continue
fi
- if [ ! -e "$fs_file" ]; then
+ if ! exists_root "$fs_file"; then
log "Line $line_no: Creating mountpoint $fs_file"
run_root mkdir -p "$fs_file" || {
err "Line $line_no: mkdir failed"
@@ -300,4 +306,3 @@ else
echo "Done: all entries processed successfully." | { [ -n "${LOG_FILE:-}" ] && tee -a "$LOG_FILE" || cat; }
exit 0
fi
-