#!/bin/ksh
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# 61haes_r714 src/43haes/usr/sbin/cluster/cspoc/utilities/clfiltlsfs.sh 1.1 
#  
# Licensed Materials - Property of IBM 
#  
# COPYRIGHT International Business Machines Corp. 1996 
# 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 
# @(#)53        1.1 src/43haes/usr/sbin/cluster/cspoc/utilities/clfiltlsfs.sh, hacmp.cspoc, 61haes_r714 6/28/96 15:57:31
# $Id: clfiltlsfs.sh,v 1.1 1996/05/01 13:36:40 build Exp $
#
# determine which, if any, of the filesystems given on command line
# reside on a volume group which is active and run lsfs on them, ignore
# all other filesystems

FLAGS=""
FSLIST=""
for i in $* ; do
    case $i in
    -q|-c|-l)
        FLAGS="$FLAGS $i"
        ;;
    *)
        FSLIST="$FSLIST $i"
        ;;
    esac
done

ACTIVEFS=""

for i in $FSLIST ; do
    # get LV FS resides on
    LV=$(lsfs $i 2>/dev/null | awk -v F=$i '$3 == F {print($1)}')
    # get state (active or inactive) of VG containing LV (hence FS)
    STATE=$(lslv ${LV#/dev/} 2>/dev/null | (while read A B C D ; do [[ "$A" = "VG" ]] && print $C ; done))
    # if VG is active add FS to list of FS's run lsfs on
    case $STATE in
    active*)
	ACTIVEFS="$ACTIVEFS $i"
	;;
    esac
done

[[ -n "$ACTIVEFS" ]] && lsfs $FLAGS $ACTIVEFS

exit 0
