#!/bin/sh DEVCLASS=$1 DEVNAME=$2 MOUNTDIR=/mnt XUSER=`ps -axwwo user,command|grep Xsession|grep -v grep|tail -n1|cut -f1 -d" "` function mountdisk { I=0 for l in `disklabel ${DEVNAME}|sed -e "s/^ *//"|cut -f1 -d" "`; do if [ ${I} -ne 2 ]; then # ignore the two first lines of disklabel if [ "$l" = "#" ]; then I=${I}+1 fi else PART=`echo $l|sed -e "s/://"` if [ ${PART} != "c" ]; then DIR=${MOUNTDIR}/${DEVNAME}${PART} if [ ! -d "${DIR}" ]; then mkdir -p ${DIR} elif [ -n "`mount|grep ${DIR}`" ]; then umount ${DIR} fi if [ -n "${XUSER}" ]; then chown ${XUSER} ${DIR} chmod 700 ${DIR} else chown root ${DIR} chmod 755 ${DIR} fi mount -o nodev,nosuid /dev/${DEVNAME}${PART} ${DIR} if [ $? -ne 0 ]; then rmdir ${DIR} fi fi fi done } case $DEVCLASS in 2) # disk devices mountdisk $DEVNAME ;; esac