* Don't squeeze all the filesystem option values into one environment
variable, since they might get confused (NIXOS-84). svn path=/nixos/trunk/; revision=17919
This commit is contained in:
parent
feeff52285
commit
1e1ae9cd1e
@ -5,23 +5,12 @@ with pkgs.lib;
|
|||||||
let
|
let
|
||||||
|
|
||||||
fileSystems = config.fileSystems;
|
fileSystems = config.fileSystems;
|
||||||
mountPoints = map (fs: fs.mountPoint) fileSystems;
|
|
||||||
devices = map (fs: if fs.device != null then fs.device else "/dev/disk/by-label/${fs.label}") fileSystems;
|
|
||||||
fsTypes = map (fs: fs.fsType) fileSystems;
|
|
||||||
optionss = map (fs: fs.options) fileSystems;
|
|
||||||
autocreates = map (fs: fs.autocreate) fileSystems;
|
|
||||||
mount = config.system.sbin.mount;
|
mount = config.system.sbin.mount;
|
||||||
|
|
||||||
task =
|
task =
|
||||||
''
|
''
|
||||||
PATH=${pkgs.e2fsprogs}/sbin:${pkgs.utillinuxng}/sbin:$PATH
|
PATH=${pkgs.e2fsprogs}/sbin:${pkgs.utillinuxng}/sbin:$PATH
|
||||||
|
|
||||||
mountPoints=(${toString mountPoints})
|
|
||||||
devices=(${toString devices})
|
|
||||||
fsTypes=(${toString fsTypes})
|
|
||||||
optionss=(${toString optionss})
|
|
||||||
autocreates=(${toString autocreates})
|
|
||||||
|
|
||||||
newDevices=1
|
newDevices=1
|
||||||
|
|
||||||
# If we mount any file system, we repeat this loop, because new
|
# If we mount any file system, we repeat this loop, because new
|
||||||
@ -29,86 +18,87 @@ let
|
|||||||
# for loopback mounts).
|
# for loopback mounts).
|
||||||
|
|
||||||
while test -n "$newDevices"; do
|
while test -n "$newDevices"; do
|
||||||
|
|
||||||
newDevices=
|
newDevices=
|
||||||
|
|
||||||
for ((n = 0; n < ''${#mountPoints[*]}; n++)); do
|
${flip concatMapStrings fileSystems
|
||||||
mountPoint=''${mountPoints[$n]}
|
(fs: ''
|
||||||
device=''${devices[$n]}
|
mountPoint='${fs.mountPoint}'
|
||||||
fsType=''${fsTypes[$n]}
|
device='${if fs.device != null then fs.device else "/dev/disk/by-label/${fs.label}"}'
|
||||||
options=''${optionss[$n]}
|
fsType='${fs.fsType}'
|
||||||
autocreate=''${autocreates[$n]}
|
|
||||||
|
# A device is a pseudo-device (i.e. not an actual device
|
||||||
|
# node) if it's not an absolute path (e.g. an NFS server
|
||||||
|
# such as machine:/path), if it starts with // (a CIFS FS),
|
||||||
|
# a known pseudo filesystem (such as tmpfs), or the device
|
||||||
|
# is a directory (e.g. a bind mount).
|
||||||
|
isPseudo=
|
||||||
|
test "''${device:0:1}" != / -o "''${device:0:2}" = // -o "$fsType" = "tmpfs" \
|
||||||
|
-o -d "$device" && isPseudo=1
|
||||||
|
|
||||||
# A device is a pseudo-device (i.e. not an actual device
|
if ! test -n "$isPseudo" -o -e "$device"; then
|
||||||
# node) if it's not an absolute path (e.g. an NFS server
|
echo "skipping $device, doesn't exist (yet)"
|
||||||
# such as machine:/path), if it starts with // (a CIFS FS),
|
|
||||||
# a known pseudo filesystem (such as tmpfs), or the device
|
|
||||||
# is a directory (e.g. a bind mount).
|
|
||||||
isPseudo=
|
|
||||||
test "''${device:0:1}" != / -o "''${device:0:2}" = // -o "$fsType" = "tmpfs" \
|
|
||||||
-o -d "$device" && isPseudo=1
|
|
||||||
|
|
||||||
if ! test -n "$isPseudo" -o -e "$device"; then
|
|
||||||
echo "skipping $device, doesn't exist (yet)"
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
# !!! quick hack: if the mount point is already mounted, try
|
|
||||||
# a remount to change the options but nothing else.
|
|
||||||
if cat /proc/mounts | grep -F -q " $mountPoint "; then
|
|
||||||
if test "''${device:0:2}" != //; then
|
|
||||||
echo "remounting $device on $mountPoint"
|
|
||||||
${mount}/bin/mount -t "$fsType" \
|
|
||||||
-o remount,"$options" \
|
|
||||||
"$device" "$mountPoint" || true
|
|
||||||
fi
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
if test -z "$isPseudo"; then
|
|
||||||
|
|
||||||
device=$(readlink -f "$device")
|
|
||||||
|
|
||||||
prevMountPoint=$(
|
|
||||||
cat /etc/mtab \
|
|
||||||
| grep "^$device " \
|
|
||||||
| sed 's|^[^ ]\+ \+\([^ ]\+\).*|\1|' \
|
|
||||||
)
|
|
||||||
|
|
||||||
if test "$prevMountPoint" = "$mountPoint"; then
|
|
||||||
echo "remounting $device on $mountPoint"
|
|
||||||
${mount}/bin/mount -t "$fsType" \
|
|
||||||
-o remount,"$options" \
|
|
||||||
"$device" "$mountPoint" || true
|
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -n "$prevMountPoint"; then
|
# !!! quick hack: if the mount point is already mounted, try
|
||||||
echo "unmount $device from $prevMountPoint"
|
# a remount to change the options but nothing else.
|
||||||
${mount}/bin/umount "$prevMountPoint" || true
|
if cat /proc/mounts | grep -F -q " $mountPoint "; then
|
||||||
|
if test "''${device:0:2}" != //; then
|
||||||
|
echo "remounting $device on $mountPoint"
|
||||||
|
${mount}/bin/mount -t "$fsType" \
|
||||||
|
-o remount,"${fs.options}" \
|
||||||
|
"$device" "$mountPoint" || true
|
||||||
|
fi
|
||||||
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
# 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.
|
||||||
|
|
||||||
echo "mounting $device on $mountPoint"
|
if test -z "$isPseudo"; then
|
||||||
|
|
||||||
# !!! should do something with the result; also prevent repeated fscks.
|
device=$(readlink -f "$device")
|
||||||
if test -z "$isPseudo"; then
|
|
||||||
fsck -a "$device" || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test "$autocreate" = 1; then mkdir -p "$mountPoint"; fi
|
prevMountPoint=$(
|
||||||
|
cat /etc/mtab \
|
||||||
|
| grep "^$device " \
|
||||||
|
| sed 's|^[^ ]\+ \+\([^ ]\+\).*|\1|' \
|
||||||
|
)
|
||||||
|
|
||||||
if ${mount}/bin/mount -t "$fsType" -o "$options" "$device" "$mountPoint"; then
|
if test "$prevMountPoint" = "$mountPoint"; then
|
||||||
newDevices=1
|
echo "remounting $device on $mountPoint"
|
||||||
fi
|
${mount}/bin/mount -t "$fsType" \
|
||||||
|
-o remount,"${fs.options}" \
|
||||||
done
|
"$device" "$mountPoint" || true
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test -n "$prevMountPoint"; then
|
||||||
|
echo "unmount $device from $prevMountPoint"
|
||||||
|
${mount}/bin/umount "$prevMountPoint" || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "mounting $device on $mountPoint"
|
||||||
|
|
||||||
|
# !!! should do something with the result; also prevent repeated fscks.
|
||||||
|
if test -z "$isPseudo"; then
|
||||||
|
fsck -a "$device" || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
${optionalString fs.autocreate
|
||||||
|
''
|
||||||
|
mkdir -p "$mountPoint"
|
||||||
|
''
|
||||||
|
}
|
||||||
|
|
||||||
|
if ${mount}/bin/mount -t "$fsType" -o "$options" "$device" "$mountPoint"; then
|
||||||
|
newDevices=1
|
||||||
|
fi
|
||||||
|
'')
|
||||||
|
}
|
||||||
done
|
done
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user