From 60e4da4a9b5607090be1c1501caa142b94aef698 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 9 Jan 2007 16:29:27 +0000 Subject: [PATCH] * Hacked up support for volume labels. svn path=/nixos/trunk/; revision=7587 --- upstart-jobs/filesystems.nix | 45 +++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/upstart-jobs/filesystems.nix b/upstart-jobs/filesystems.nix index 14ae17bb10c..23849db7886 100644 --- a/upstart-jobs/filesystems.nix +++ b/upstart-jobs/filesystems.nix @@ -41,33 +41,42 @@ script fsType=\${fsTypes[$n]} options=\${optionss[$n]} - if ! test -e \"$device\"; then + isLabel= + if echo \"$device\" | grep -q '^LABEL='; then isLabel=1; fi + + if ! test -n \"$isLabel\" -o -e \"$device\"; then echo \"skipping $device, doesn't exist (yet)\" continue fi - device=$(readlink -f \"$device\") - # 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 + # !!! not very smart about labels yet; should resolve the label somehow. + if test -z \"$isLabel\"; then + + device=$(readlink -f \"$device\") + + 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 - if test -n \"$prevMountPoint\"; then - echo \"unmount $device from $prevMountPoint\" - ${utillinux}/bin/umount \"$prevMountPoint\" || true fi echo \"mounting $device on $mountPoint\"