grml-udev-rebuildfstab: update script header.
[grml-udev-config.git] / scripts / grml-udev-rebuildfstab
index 9181b74..4bc5bb2 100755 (executable)
@@ -1,9 +1,9 @@
 #!/bin/bash
-# Filename:      rebuildfstab
-# Purpose:       calls scanpartitions as root and adds entries to /etc/fstab
-# Authors:       grml-team (grml.org),  (c) Klaus Knopper Nov 2002, (c) Michael Prokop <mika@grml.org>
+# Filename:      scripts/grml-udev-rebuildfstab
+# Purpose:       udev script to update /etc/fstab
+# Authors:       grml-team (grml.org)
 # Bug-Reports:   see http://grml.org/bugs/
-# License:       This file is licensed under the GPL v2.
+# License:       This file is licensed under the GPL v2+.
 ################################################################################
 
 PATH="/bin:/sbin:/usr/bin:/usr/sbin"
@@ -138,7 +138,20 @@ iso9660)
 break;
 ;;
 *)
-[ -n "$LABEL" ]  && [ -n "$ID_FS_LABEL" ] && echo "LABEL=$ID_FS_LABEL_ENC"  && return
+if [ -n "$LABEL" ]  && [ -n "$ID_FS_LABEL_ENC" ] ; then
+  # see check_for_label() in scanpartitions for details
+  case $ID_FS_LABEL_ENC in
+    *\ *|*\x20*)
+      addinfo=" # space char inside label ($ID_FS_LABEL_ENC) not supported"
+      break ;;
+    /)
+      addinfo=" # label '/' not supported"
+      break ;;
+  esac
+
+  echo "LABEL=$ID_FS_LABEL_ENC"
+  return
+fi
 ;;
 esac
 [ -n "$DM_NAME" ] && echo /dev/mapper/$DM_NAME && return
@@ -208,7 +221,7 @@ mountpoint=$(get_mount_point $device)
 
 for devicelink in $DEVLINKS ; do
     # ignore external
-    case "$devicelink" in "*external*") continue ;; esac
+    case "$devicelink" in *external*) continue ;; esac
     stringinfile $devicelink $TMPFILE && bailout 0
 done
 
@@ -241,8 +254,8 @@ case $ACTION in
 add|change)
 (
     flock -x 200
-    echo $ADDEDBYGRML $DEVNAME >> /etc/fstab
-    echo $device $mountpoint $ID_FS_TYPE $options 0 0 $addinfo >> /etc/fstab
+    echo "$ADDEDBYGRML $DEVNAME" >> /etc/fstab
+    echo "$device $mountpoint $ID_FS_TYPE $options 0 0 $addinfo # $DEVNAME" >> /etc/fstab
 ) 200>/var/run/rebuildfstab.lock