--- ../bak/filesystems 2004-11-07 15:46:38 +0200 +++ ../bak/filesystems 2004-11-23 00:33:50 +0200 @@ -4,7 +4,10 @@ AddConfigHandler FilesystemsOptions AddConfigHelp "Unmount [...]" "If you have network shares or external devices that should be unmounted before suspending, list them here." AddConfigHelp "Mount [...]" "If you have network shares or external devices that should be mounted after resuming, list them here." +AddConfigHelp "UnmountFSTypes [...]" "Unmount fylesystems by type. Useful for unmounting all filesystems of specific type which are not in /etc/fstab, e.g. manually mounted cifs or smbfs fylesystems" +AddConfigHelp "UnmountSleepTime [smhd]" "Time to sleep before sending SIGKILL for processes using filesystems to be unmounted. The parameter value is a number of seconds, suffix has the same meaning as for sleep(1)" +sleeptime=1 FilesystemsUnmount() { local mnt local ret @@ -24,7 +27,7 @@ FilesystemsUnmount() { done fi - [ "$needsleep" -eq 1 ] && sleep 1 + [ "$needsleep" -eq 1 ] && sleep $sleeptime # Send KILL to processes and unmount ret=0 @@ -54,6 +57,22 @@ FilesystemsMount() { return $ret } +FSTypesUnmount() { + local fstype + [ -z "$FS_TYPES" ] && return 0 + + ret=0 + FS_UNMOUNTS_SAVE="$FS_UNMOUNTS" + for fstype in $FS_TYPES; do + FS_UNMOUNTS=`awk '($3 == "'$fstype'") {print $2}' /proc/mounts |sort -r` + vecho 2 "Filesystems of type \"$fstype\" to unmount: $FS_UNMOUNTS" + FilesystemsUnmount || ret=1 + done + + FS_UNMOUNTS="$FS_UNMOUNTS_SAVE" + return $ret +} + FilesystemsOptions() { case $1 in unmount) @@ -61,11 +80,20 @@ FilesystemsOptions() { shift FS_UNMOUNTS="$FS_UNMOUNTS $@" ;; + unmountfstypes) + [ -z "$FS_TYPES" ] && AddSuspendHook 45 FSTypesUnmount + shift + FS_TYPES="$FS_TYPES $@" + ;; mount) [ -z "$FS_MOUNTS" ] && AddResumeHook 50 FilesystemsMount shift FS_MOUNTS="$FS_MOUNTS $@" ;; + unmountsleeptime) + shift + sleeptime="$1" + ;; *) return 1 esac