* Mount file systems until a fixpoint is reached.

* Work properly for loopback mounts.

svn path=/nixos/trunk/; revision=7453
This commit is contained in:
Eelco Dolstra 2006-12-21 18:10:33 +00:00
parent f89f3c0643
commit bf8e19f6db

View File

@ -23,6 +23,16 @@ script
fsTypes=(${toString fsTypes}) fsTypes=(${toString fsTypes})
optionss=(${toString optionss}) optionss=(${toString optionss})
newDevices=1
# If we mount any file system, we repeat this loop, because new
# mount opportunities may have become available (such as images
# for loopback mounts).
while test -n \"$newDevices\"; do
newDevices=
for ((n = 0; n < \${#mountPoints[*]}; n++)); do for ((n = 0; n < \${#mountPoints[*]}; n++)); do
mountPoint=\${mountPoints[$n]} mountPoint=\${mountPoints[$n]}
device=\${devices[$n]} device=\${devices[$n]}
@ -30,11 +40,19 @@ script
options=\${optionss[$n]} options=\${optionss[$n]}
# If $device is already mounted somewhere else, unmount it first. # If $device is already mounted somewhere else, unmount it first.
prevMountPoint=$(cat /proc/mounts | grep \"^$device \" | sed 's|^[^ ]\\+ \\+\\([^ ]\\+\\).*|\\1|') # !!! Note: we use /etc/mtab, not /proc/mounts, because mtab
# contains more accurate info when using loop devices.
prevMountPoint=$(
cat /etc/mtab \\
| grep \"^$device \" \\
| sed 's|^[^ ]\\+ \\+\\([^ ]\\+\\).*|\\1|' \\
)
if test \"$prevMountPoint\" = \"$mountPoint\"; then if test \"$prevMountPoint\" = \"$mountPoint\"; then
echo \"remounting $device on $mountPoint\" echo \"remounting $device on $mountPoint\"
${utillinux}/bin/mount -t \"$fsType\" -o remount,\"$options\" \"$device\" \"$mountPoint\" || true ${utillinux}/bin/mount -t \"$fsType\" \\
-o remount,\"$options\" \\
\"$device\" \"$mountPoint\" || true
continue continue
fi fi
@ -45,8 +63,12 @@ script
echo \"mounting $device on $mountPoint\" echo \"mounting $device on $mountPoint\"
mkdir -p \"$mountPoint\" || true if ${utillinux}/bin/mount -t \"$fsType\" -o \"$options\" \"$device\" \"$mountPoint\"; then
${utillinux}/bin/mount -t \"$fsType\" -o \"$options\" \"$device\" \"$mountPoint\" || true newDevices=1
fi
done
done done
end script end script