#!/bin/ksh93
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# 61haes_r714 src/43haes/lib/ksh93/OEMVeritas/KLIB_OEMVeritas_getFilesystemsForDiskGroup.sh 1.8 
#  
# Licensed Materials - Property of IBM 
#  
# Restricted Materials of IBM 
#  
# COPYRIGHT International Business Machines Corp. 2005,2011 
# All Rights Reserved 
#  
# US Government Users Restricted Rights - Use, duplication or 
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp. 
#  
# IBM_PROLOG_END_TAG 
# @(#)11	1.8 src/43haes/lib/ksh93/OEMVeritas/KLIB_OEMVeritas_getFilesystemsForDiskGroup.sh, hacmp.utils, 61haes_r714 11/28/11 14:59:42
function KLIB_OEMVeritas_getFilesystemsForDiskGroup {
	. /usr/es/lib/ksh93/func_include

	typeset dg=$1

	if [[ -z $dg ]]; then
		return 1
	fi

	typeset l_mountpoint
	typeset l_device
	typeset l_vfs
	typeset l_nodename
	typeset l_type
	typeset l_size
	typeset l_options
	typeset l_automount
	typeset l_acct
	typeset l_type
	typeset l_minor
	typeset l_bdev
	typeset l_cdev
	typeset l_path
	typeset device
	typeset device_paths

	REQUIRED_COMMANDS="/usr/sbin/vxprint /usr/sbin/lsfs"
	for cmd in $REQUIRED_COMMANDS; do
		if [[ ! -x $cmd ]]; then
			return 1
		fi
	done

	# Get a list of device paths for this diskgroup
	LC_ALL=C /usr/sbin/vxprint -l -g $dg | while read l_type l_minor l_bdev l_cdev l_path ; do
		if [[ "$l_type" == "device:" && -n $l_path ]]; then
			l_path=${l_path/path\=/}
			device_paths="$l_path $device_paths"
		fi
	done

	if [[ -z $device_paths ]]; then
		return 0
	fi

	LC_ALL=C /usr/sbin/lsfs -c -v vxfs | while IFS=':' read l_mountpoint l_device l_vfs l_nodename l_type l_size l_options l_automount l_acct; do
		for device in $device_paths; do
			if [[ "$device" == "$l_device" ]]; then
				echo $l_mountpoint	
			fi
		done
	done
	return 0
}
