minix/etc/rc.subr.minix

69 lines
1.2 KiB
Text
Raw Normal View History

mountfstab()
{
fsck_opts=""
fflag=""
while getopts "fo:" opt
do case $opt
in f) fflag="-f"
;;
o) fsck_opts="$OPTARG"
;;
*) echo "mountfstab: odd"
return 1
;;
esac
done
shift `expr $OPTIND - 1`
# Make fsck necessary for unclean shutdown
msg="The system was not properly shut down. Checking file systems."
if shutdown -C
then echo "$msg"
fflag="-f"
fi
fstabfile="$1"
if [ ! -f $fstabfile ]
then echo "mountfstab: $fstabfile not found"
return 1
fi
cat $fstabfile | sed 's/#.*//' | while read fsline
do set "" $fsline
shift
if [ $# -eq 0 ]; then continue; fi
if [ $# -lt 3 ]
then echo "$fstabfile: short line"
continue
fi
# This line's parameters
dev="$1"; mp="$2"; fstype="$3"
# Sanity checks
if [ ! -b $dev ]; then echo "$dev missing"; continue; fi
if [ ! -d $mp ]; then echo "$mp missing"; continue; fi
# Do fsck if necessary or requested
if [ -n "$fflag" ]
then echo "Checking $fstype $dev"
if ! fsck.$fstype $fflag $fsck_opts -p $dev
then echo "$dev fail"
continue
fi
fi
# Skip the actual mount for /, it's already mounted
if [ "$mp" = / ]
then continue
fi
# Do actual mount command
mount -t $fstype $dev $mp
done
}