mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2025-01-07 14:00:59 +03:00
* Mount file systems until a fixpoint is reached.
* Work properly for loopback mounts. svn path=/nixos/trunk/; revision=7453
This commit is contained in:
parent
f89f3c0643
commit
bf8e19f6db
@ -23,30 +23,52 @@ script
|
|||||||
fsTypes=(${toString fsTypes})
|
fsTypes=(${toString fsTypes})
|
||||||
optionss=(${toString optionss})
|
optionss=(${toString optionss})
|
||||||
|
|
||||||
for ((n = 0; n < \${#mountPoints[*]}; n++)); do
|
newDevices=1
|
||||||
mountPoint=\${mountPoints[$n]}
|
|
||||||
device=\${devices[$n]}
|
|
||||||
fsType=\${fsTypes[$n]}
|
|
||||||
options=\${optionss[$n]}
|
|
||||||
|
|
||||||
# If $device is already mounted somewhere else, unmount it first.
|
# If we mount any file system, we repeat this loop, because new
|
||||||
prevMountPoint=$(cat /proc/mounts | grep \"^$device \" | sed 's|^[^ ]\\+ \\+\\([^ ]\\+\\).*|\\1|')
|
# mount opportunities may have become available (such as images
|
||||||
|
# for loopback mounts).
|
||||||
|
|
||||||
|
while test -n \"$newDevices\"; do
|
||||||
|
|
||||||
if test \"$prevMountPoint\" = \"$mountPoint\"; then
|
newDevices=
|
||||||
echo \"remounting $device on $mountPoint\"
|
|
||||||
${utillinux}/bin/mount -t \"$fsType\" -o remount,\"$options\" \"$device\" \"$mountPoint\" || true
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test -n \"$prevMountPoint\"; then
|
for ((n = 0; n < \${#mountPoints[*]}; n++)); do
|
||||||
echo \"unmount $device from $prevMountPoint\"
|
mountPoint=\${mountPoints[$n]}
|
||||||
${utillinux}/bin/umount \"$prevMountPoint\" || true
|
device=\${devices[$n]}
|
||||||
fi
|
fsType=\${fsTypes[$n]}
|
||||||
|
options=\${optionss[$n]}
|
||||||
|
|
||||||
echo \"mounting $device on $mountPoint\"
|
# If $device is already mounted somewhere else, unmount it first.
|
||||||
|
# !!! 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
|
||||||
|
echo \"remounting $device on $mountPoint\"
|
||||||
|
${utillinux}/bin/mount -t \"$fsType\" \\
|
||||||
|
-o remount,\"$options\" \\
|
||||||
|
\"$device\" \"$mountPoint\" || true
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test -n \"$prevMountPoint\"; then
|
||||||
|
echo \"unmount $device from $prevMountPoint\"
|
||||||
|
${utillinux}/bin/umount \"$prevMountPoint\" || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo \"mounting $device on $mountPoint\"
|
||||||
|
|
||||||
|
if ${utillinux}/bin/mount -t \"$fsType\" -o \"$options\" \"$device\" \"$mountPoint\"; then
|
||||||
|
newDevices=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
mkdir -p \"$mountPoint\" || true
|
|
||||||
${utillinux}/bin/mount -t \"$fsType\" -o \"$options\" \"$device\" \"$mountPoint\" || true
|
|
||||||
done
|
done
|
||||||
|
|
||||||
end script
|
end script
|
||||||
|
Loading…
Reference in New Issue
Block a user