forked from mirrors/nixpkgs
stage-1: escape mount points and options
mountFS adds these strings to fstab and then relies on `mount` parsing fstab. If they have spaces or tabs in them, that would break fstab and therefore not mount with the unhelpful error: No such file or directory. Co-authored-by: Lily Foster <lily@lily.flowers> Co-authored-by: Luflosi <Luflosi@users.noreply.github.com>
This commit is contained in:
parent
7e2aec079c
commit
753f883c35
|
@ -342,6 +342,14 @@ checkFS() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
escapeFstab() {
|
||||||
|
local original="$1"
|
||||||
|
|
||||||
|
# Replace space
|
||||||
|
local escaped="${original// /\\040}"
|
||||||
|
# Replace tab
|
||||||
|
echo "${escaped//$'\t'/\\011}"
|
||||||
|
}
|
||||||
|
|
||||||
# Function for mounting a file system.
|
# Function for mounting a file system.
|
||||||
mountFS() {
|
mountFS() {
|
||||||
|
@ -569,7 +577,7 @@ while read -u 3 mountPoint; do
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mountFS "$device" "$mountPoint" "$options" "$fsType"
|
mountFS "$device" "$(escapeFstab "$mountPoint")" "$(escapeFstab "$options")" "$fsType"
|
||||||
done
|
done
|
||||||
|
|
||||||
exec 3>&-
|
exec 3>&-
|
||||||
|
|
Loading…
Reference in a new issue