#!/sbin/sh
# @(#)src/unix/pagecache/sol/common/cmd/vxfs/fsckall/fsckall.sh	3.1.48.1 05/31/01 13:10:37 - Copyright 1991-2002
#ident	"@(#)vxfs:src/unix/pagecache/sol/common/cmd/vxfs/fsckall/fsckall.sh	3.1.48.1"
#
# Copyright (c) 1998 VERITAS Software Corporation.  ALL RIGHTS RESERVED.
# UNPUBLISHED -- RIGHTS RESERVED UNDER THE COPYRIGHT
# LAWS OF THE UNITED STATES.  USE OF A COPYRIGHT NOTICE
# IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
# OR DISCLOSURE.
#
# THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND
# TRADE SECRETS OF VERITAS SOFTWARE.  USE, DISCLOSURE,
# OR REPRODUCTION IS PROHIBITED WITHOUT THE PRIOR
# EXPRESS WRITTEN PERMISSION OF VERITAS SOFTWARE.
#
#	       RESTRICTED RIGHTS LEGEND
# USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT IS
# SUBJECT TO RESTRICTIONS AS SET FORTH IN SUBPARAGRAPH
# (C) (1) (ii) OF THE RIGHTS IN TECHNICAL DATA AND
# COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013.
#	       VERITAS SOFTWARE
# 1600 PLYMOUTH STREET, MOUNTAIN VIEW, CA 94043
#

# Produce a list of the file systems that need checking. 
# This is Solaris only, so we don't need to worry about 
# root.
#
# fsck -m exit codes:
#	0	Unmounted and OK
#	32	Unmounted and needs checking
#	33	Mounted
#	34	Cannot stat device
#

for fsckdev in $* ; do
	/usr/lib/fs/vxfs/fsck -m $fsckdev >/dev/null 2>&1
	if [ $? = 32 ]; then
		vxfs_fscklist="$vxfs_fscklist $fsckdev"
	fi
done

#
# Check the file systems in parallel
#

if [ "$vxfs_fscklist" ]; then
	echo "checking vxfs filesystems"
	/usr/lib/fs/vxfs/fsck -y -o p $vxfs_fscklist
	case $? in

	0|40|33)	# file system OK
			exit 0
			;;

	*)	# couldn't fix the filesystems - return an error
		exit 1
		;;
	esac
fi

exit 0
