#!/sbin/runscript : ${NET_FS_LIST:="afs cifs coda davfs fuse gfs ncpfs nfs nfs4 ocfs2 shfs smbfs"} : ${NO_UNMOUNT:="/dev/shm /dev/pts /dev /sys /proc /"} start() { local types="noprocfs" i= for i in ${NET_FS_LIST}; do types="$types,$i" done # create mount points from fstab mkmntdirs /etc/fstab ebegin "Mounting local file systems" mount -at "$types" eend $? "Some local filesystems failed to mount" if [ ! -d /proc/bus/usb ]; then modprobe usbcore &>/dev/null fi if [ -e /proc/filesystems ] ; then if [ -d /proc/bus/usb -a ! -e /proc/bus/usb/devices ] ; then local usbfs=$(grep -ow usbfs /proc/filesystems) if [ -n "${usbfs}" ] ; then ebegin "Mounting USB device filesystem" local gid=$(getent group usb | cut -d: -f3) mount -t ${usbfs} \ -o ${gid:+devmode=0664,devgid=${gid},}noexec,nosuid \ usbfs /proc/bus/usb eend $? fi fi if [ -d /proc/fs/nfsd ] ; then if grep -qs nfsd /proc/filesystems ; then ebegin "Mounting nfsd filesystem" mount -t nfsd -o nodev,noexec,nosuid nfsd /proc/fs/nfsd eend $? fi fi fi } reverse_mounts() { local rev= while read line ; do rev="$line\n$rev" done < /proc/mounts } unmountable() { local i= for i in $NO_UNMOUNT ; do [ "$i" = "$1" ] && return 1 done for i in $NET_FS_LIST ; do [ "$i" = "$2" ] && return 1 done return 0 } stop() { local rev= dev= mnt= rc=0 fs= ebegin "Unmounting filesystems" sync ; sync while read line ; do rev="$line\n$rev" done < /proc/mounts echo -e "$rev" | grep -v '^$' | while read dev mnt fs ; do if unmountable $mnt $fs ; then umount -r "$mnt" rc=$(($rc + $?)) fi done eend $rc }