#!/bin/ksh93 # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # 61haes_r714 src/43haes/lib/ksh93/ihs/KLIB_IHS_mount_fs_for_directory.sh 1.1 # # Licensed Materials - Property of IBM # # Restricted Materials of IBM # # COPYRIGHT International Business Machines Corp. 2009,2010 # 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 # @(#)96 1.1 src/43haes/lib/ksh93/ihs/KLIB_IHS_mount_fs_for_directory.sh, hacmp, 61haes_r714 11/28/11 15:04:37 # #=head1 NAME # # KLIB_IHS_mount_fs_for_directory - Determine the pvids associated with a list of volume groups # #=head1 SYNOPSIS # # KLIB_IHS_mount_fs_for_directory vg directory # #=head1 DESCRIPTION # # Attempt to mount the filesystem on a volume group containing # the directory path # #=head1 ARGUMENTS # # 1: [scalar] volume group name # 2: [scalar] directory path # #=head1 RETURN # # 0 - success # 1 - failure # #=head1 COPYRIGHT # #(C) COPYRIGHT International Business Machines Corp. 2005 #All Rights Reserved # #=cut # function KLIB_IHS_mount_fs_for_directory { . /usr/es/lib/ksh93/func_include typeset VG=$1 typeset DIRECTORY=$2 if [[ -z $(lsvg -o | grep $VG) ]] ; then varyonvg $VG 2>/dev/null if (( $? != 0 )) ; then KLIB_IHS_log_message "WAS ERROR: Unable to vary on volume group $vg." return 1 fi fi # Look for an existing FS on the volume group that might contain the directory and mount it typeset mountpoint for mountpoint in $(lsvg -l $VG | awk '$2 == "jfs" || $2 == "jfs2" {print $7}') ; do if [[ $mountpoint == ${DIRECTORY:0:${#mountpoint}} ]] ; then if [[ ${#mountpoint} == ${#DIRECTORY} || ${DIRECTORY:${#mountpoint}:1} == "/" ]] ; then if [[ -z $(mount 2>/dev/null | awk '$3 ~ /jfs2*$/ {print $2}' | grep $mountpoint) ]] ; then mount $mountpoint 2>/dev/null if (( $? != 0 )) ; then KLIB_WAS_log_message "WAS ERROR: Unable to mount filesystem $mountpoint." return 1 fi fi fi fi done if [[ -e $DIRECTORY ]] ; then return 0 else return 1 fi }