X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=scripts%2Fgrml-udev-rebuildfstab;h=4bc5bb201ba06ab8b9304bcb169035c0f38244d2;hb=1aca06da3d9ef8598040a6dc9135ebcea23ddd74;hp=7831e7143b1ca59d9a351cdaf9990739fef143d9;hpb=b999254e24b001780f8ef882001886310d0c9898;p=grml-udev-config.git diff --git a/scripts/grml-udev-rebuildfstab b/scripts/grml-udev-rebuildfstab index 7831e71..4bc5bb2 100755 --- a/scripts/grml-udev-rebuildfstab +++ b/scripts/grml-udev-rebuildfstab @@ -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 +# 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" @@ -50,7 +50,7 @@ fi if grep -q " nofstab" /proc/cmdline ; then - exit + bailout 0 fi grep -q 'nolabel' /proc/cmdline && NOLABEL='TRUE' || LABEL='TRUE' @@ -58,13 +58,13 @@ grep -q 'nolabel' /proc/cmdline && NOLABEL='TRUE' || LABEL='TRUE' if [ "$CONFIG_FSTAB" = "no" ] ; then - exit + bailout 0 fi if grep -q ' /mnt ' /proc/mounts ; then logit '/mnt is a mounted directory, exiting.' - exit 1 + bailout 1 fi # make sure we have the $MNTFILE before reading/writing into it @@ -106,7 +106,7 @@ fi [ ! -w /etc/fstab ] && { logit "fatal - /etc/fstab not writeable, exiting" - exit + bailout 0 } # Simple shell grep, searches for lines STARTING with string @@ -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 @@ -185,17 +198,17 @@ fi if [ -z "$ACTION" ] ; then logit "Seems that $0 is not run in a udev environment, exiting." >&2 - exit 1 + bailout 1 fi # ignore loop devices for now. case $DEVNAME in /dev/loop*) - exit 0 + bailout 0 ;; esac -removeentries "$ADDEDBYGRML $DEVNAME" /etc/fstab +removeentries "$ADDEDBYGRML $DEVNAME" /etc/fstab device=$(get_device_name) mountpoint=$(get_mount_point $device) @@ -208,12 +221,12 @@ mountpoint=$(get_mount_point $device) for devicelink in $DEVLINKS ; do # ignore external - case "$devicelink" in "*external*") continue ;; esac - stringinfile $devicelink $TMPFILE && exit + case "$devicelink" in *external*) continue ;; esac + stringinfile $devicelink $TMPFILE && bailout 0 done # if entry is already present ignore it -stringinfile $device $TMPFILE && exit +stringinfile $device $TMPFILE && bailout 0 options=noauto,user,dev,suid,exec case $ID_FS_TYPE in @@ -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 @@ -278,4 +291,6 @@ if [ -r "$MNTFILE" ] ; then cat $TMPFILE > $MNTFILE fi +bailout 0 + ## END OF FILE #################################################################