#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License"). You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
#
# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
# All Rights Reserved
#
if [ -n "$1" ]; then
echo "mountall: $1" 1>&2
fi
echo "Usage:\nmountall [-F FSType] [-l|-r|-g] [file_system_table]" 1>&2
exit 2
}
err=0
# Clear these in case they were already set in our environment.
# checkmessage "fsck_device | mount_point"
#
# Simple auxilary routine to the shell function checkfs. Prints out
# instructions for a manual file system check before entering the shell.
#
if [ "$1" != "" ] ; then
else
echo "WARNING - Unable to repair one or more filesystems." \
fi
}
#
# checkfs raw_device fstype mountpoint
#
# Check the file system specified. The return codes from fsck have the
# following meanings.
# 0 - file system is unmounted and okay
# 32 - file system is unmounted and needs checking (fsck -m only)
# 33 - file system is already mounted
# 34 - cannot stat device
# 36 - uncorrectable errors detected - terminate normally (4.1 code 8)
# 37 - a signal was caught during processing (4.1 exit 12)
# 39 - uncorrectable errors detected - terminate rightaway (4.1 code 8)
# 40 - for root, same as 0 (used by rcS to remount root)
#
if [ $? -ne 0 ]
then
# Determine fsck options by file system type
;;
*) foptions="-y"
;;
esac
echo "The "$3" file system ("$1") is being checked."
case $? in
0|40) # file system OK
;;
*) # couldn't fix the file system
checkmessage "$1"
;;
esac
fi
}
#
# Used to save an entry that we will want to mount either in
# a command file or as a mount point list.
#
# saveentry fstype options special mountp
#
else
fi
}
# Do the passed mount options include "global"?
*,global,*)
return 0
;;
esac
return 1
}
# Is the passed fstype a "remote" one?
for t in $RemoteFSTypes
do
[ "$t" = "$1" ] && return 0
done
return 1
}
# Get list of remote FS types (just once)
RemoteFSTypes=`while read t junk; do echo $t; done < /etc/dfs/fstypes`
#
# Process command line args
#
while getopts ?grlsF: c
do
case $c in
g) GFLAG="g";;
r) RFLAG="r";;
l) LFLAG="l";;
s) SFLAG="s";;
if [ "$TYPES" = "one" ]
then
echo "mountall: more than one FSType specified"
exit 2
fi
TYPES="one";
?????????*)
echo "mountall: FSType $FSType exceeds 8 characters"
exit 2
esac
;;
\?) usage "";;
esac
done
if [ $# -gt 1 ]; then
usage "multiple arguments not supported"
fi
# get file system table name and make sure file exists
if [ $# = 1 ]; then
case $1 in
;;
*) FSTAB=$1
;;
esac
fi
#
# if an alternate vfstab file is used or serial mode is specified, then
# use a mount command file
#
if [ $# = 1 -o "$SFLAG" ]; then
fi
then
echo "mountall: file system table ($FSTAB) not found"
exit 1
fi
#
# Check for incompatible args
#
then
usage "options -g, -r and -l are mutually exclusive"
fi
# remote FSType not allowed
usage "option -l and FSType are incompatible"
fi
# remote FSType required
usage "option -r and FSType are incompatible"
fi
# file-system-table format:
#
# column 1: special- block special device or resource name
# column 2: fsckdev- char special device for fsck
# column 3: mountp- mount point
# column 4: fstype- File system type
# column 5: fsckpass- number if to be checked automatically
# column 7: mntopts- -o specific mount options
# White-space separates columns.
# Lines beginning with \"#\" are comments. Empty lines are ignored.
# a '-' in any field is a no-op.
#
# Read FSTAB, fsck'ing appropriate filesystems:
#
exec < $FSTAB
do
'#'* | '') # Ignore comments, empty lines
continue ;;
'-') # Ignore no-action lines
continue
esac
if [ "$automnt" != "yes" ]; then
continue
fi
# ignore different fstypes
continue
fi
# The -g option is not in the man page, but according to
# PSARC/1998/255 it's used by Sun Cluster (via contract) to
# mount disk-based filesystems with the "global" option.
# Also, the -l option now skips those "global" mounts.
#
# Note: options -g -l -r are mutually exclusive
#
if [ -n "$GFLAG" ]; then
# Mount "local" filesystems that have
# the "global" option in mntopts.
fi
if [ -n "$LFLAG" ]; then
# Mount "local" filesystems, excluding
# those marked "global".
fi
if [ -n "$RFLAG" ]; then
# Mount "remote" filesystems.
fi
if [ "$fstype" = "-" ]; then
continue
fi
else
OPTIONS=""
fi
#
# Ignore entries already mounted
#
#
# Can't fsck if no fsckdev is specified
#
if [ "$fsckdev" = "-" ]; then
continue
fi
#
# For fsck purposes, we make a distinction between file systems
# that don't. For those that do, just keep a list of them
# and pass the list to the fsckall script for that file
# file system type.
#
#
# add fstype to the list of fstypes for which
# fsckall should be called, if it's not already
# in the list.
#
if [ "$fsckall_fstypes" != "" ] ; then
break
fi
done
fi
fsckall_fstypes="$fsckall_fstypes ${fstype}"
fi
#
# add the device to the name of devices to be passed
# to the fsckall program for this file system type
#
eval $cmd
continue
fi
#
# fsck everything else:
#
# fsck -m simply returns true if the filesystem is suitable for
# mounting.
#
case $? in
continue
;;
continue
;;
33) # already mounted
echo "$special already mounted"
;;
34) # bogus special device
echo "Cannot stat $fsckdev - ignoring"
err=1
;;
*) # uncorrectable errors
echo "$fsckdev uncorrectable error"
err=1
;;
esac
done
#
# Call the fsckall programs
#
do
eval $cmd
case $? in
0) # file systems OK
;;
*) # couldn't fix some of the filesystems
echo "fsckall failed with exit code "$?"."
;;
esac
done
if [ "$ALTM" ]; then
if [ ! -f "$ALTM" ]; then
exit
fi
exit
fi
if [ -n "$FSType" ]; then
exit
fi
# Some remote filesystems (e.g. autofs) shouldn't be mounted
if [ "$RFLAG" ]; then
exit
fi
exit
fi
# else mount them all