#!/bin/sh
#
# Copyright (c) 2001 by Sun Microsystems, Inc.
# All rights reserved.
#
#ident	"@(#)scmountdev	1.2	01/11/07 SMI"

#
# script to mount /global/.devices/node@? locally
# so drvconfig and devfsadm can be run to configure global devices.
#

# We need to enable vxvm volumes before trying to mount /global/.devices
# if the root disk has been encapsulated.

sedp=/usr/bin/sed

#
# If no vxrecover utility, infer VxVM package is not installed on this node.
#
if [ -x /usr/sbin/vxrecover ]
then
	/usr/sbin/vxrecover -n -s
fi

exec < $vfstab; readvfstab /global/.devices/node@`/usr/sbin/clinfo -n`

if [ "$mountp" ]; then
	# convert did device names to native solaris names
	if [ `echo $special | grep -c did` -gt 0 ] ; then

		diddev=`echo $special | $sedp 's/.*d/d/
		s/s.*//'`
		devspecial=`/usr/cluster/bin/scdidadm -l -o path $diddev| $sedp 's/ *$//'`
		slice=`echo $special|$sedp -e 's,..*\(..\)$,\1,'`
		fsckdev=$devspecial$slice
		special=`echo $fsckdev | $sedp s/rdsk/dsk/`
	fi

	checkfs ${fsckdev} ${fstype} ${mountp}
	if [ "x$mntopts" != x- ]; then
		# Strip out "global" option
		opts=`$sedp -e 's/^[	 ][	 ]*//' \
			-e 's/^global$//' -e 's/^global,//' \
			-e 's/,global//g' << EOF
		$mntopts
		EOF`
		#
		# 4274632: mount option warning for /global/.devices
		#
		/sbin/mount -m -o "$opts" $special $mountp
	else
		/sbin/mount -m $special $mountp
	fi
	mntlist="${mntlist}${special} ${mountp}\n"
fi
