| 1 | #!/bin/ksh | 
|---|
| 2 | # IBM_PROLOG_BEGIN_TAG | 
|---|
| 3 | # This is an automatically generated prolog. | 
|---|
| 4 | # | 
|---|
| 5 | # | 
|---|
| 6 | # | 
|---|
| 7 | # Licensed Materials - Property of IBM | 
|---|
| 8 | # | 
|---|
| 9 | # (C) COPYRIGHT International Business Machines Corp. 2004,2005 | 
|---|
| 10 | # All Rights Reserved | 
|---|
| 11 | # | 
|---|
| 12 | # US Government Users Restricted Rights - Use, duplication or | 
|---|
| 13 | # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. | 
|---|
| 14 | # | 
|---|
| 15 | # IBM_PROLOG_END_TAG | 
|---|
| 16 | # @(#)12 1.2 src/avs/fs/mmfs/ts/admin/mmdynamicmap.sh, mmfs, avs_rgpfs24, rgpfs240610b 4/4/05 10:44:21 | 
|---|
| 17 | ######################################################################### | 
|---|
| 18 | # | 
|---|
| 19 | #  Usage:  mmdynamicmap Device | 
|---|
| 20 | # | 
|---|
| 21 | ######################################################################### | 
|---|
| 22 |  | 
|---|
| 23 | # Include global declarations and service routines. | 
|---|
| 24 | . /usr/lpp/mmfs/bin/mmglobfuncs | 
|---|
| 25 | . /usr/lpp/mmfs/bin/mmsdrfsdef | 
|---|
| 26 | . /usr/lpp/mmfs/bin/mmfsfuncs | 
|---|
| 27 |  | 
|---|
| 28 | sourceFile="mmdynamicmap.sh" | 
|---|
| 29 | [[ -n $DEBUG || -n $DEBUGmmdynamicmap ]] && set -x | 
|---|
| 30 | $mmTRACE_ENTER "$*" | 
|---|
| 31 |  | 
|---|
| 32 | # Local variables | 
|---|
| 33 |  | 
|---|
| 34 | usageMsg=34 | 
|---|
| 35 |  | 
|---|
| 36 | ###################### | 
|---|
| 37 | # Mainline processing | 
|---|
| 38 | ###################### | 
|---|
| 39 |  | 
|---|
| 40 | ###################################### | 
|---|
| 41 | # Process the command line arguments. | 
|---|
| 42 | ###################################### | 
|---|
| 43 | [[ $arg1 = '-?' || $arg1 = '-h' || $arg1 = '--help' || $arg1 = '--' ]] && \ | 
|---|
| 44 | syntaxError "help" $usageMsg | 
|---|
| 45 |  | 
|---|
| 46 | [[ $argc -lt 1  ]] && \ | 
|---|
| 47 | syntaxError "missingArgs" $usageMsg | 
|---|
| 48 |  | 
|---|
| 49 | # The first argument is always the file system name. | 
|---|
| 50 | device=$arg1 | 
|---|
| 51 |  | 
|---|
| 52 | [[ $argc -gt 1  ]] && \ | 
|---|
| 53 | syntaxError "extraArg" $usageMsg $arg2 | 
|---|
| 54 |  | 
|---|
| 55 |  | 
|---|
| 56 | # Strip away any /dev/ prefix from the device id. | 
|---|
| 57 | deviceName=${device##+(/)dev+(/)} | 
|---|
| 58 | fqDeviceName="/dev/${deviceName}" | 
|---|
| 59 |  | 
|---|
| 60 | # Verify the device name. | 
|---|
| 61 | if [[ $deviceName != ${deviceName#*/} ]] | 
|---|
| 62 | then | 
|---|
| 63 | if [[ $deviceName = ${deviceName#/} ]] | 
|---|
| 64 | then | 
|---|
| 65 | printErrorMsg 170 $mmcmd $device | 
|---|
| 66 | else | 
|---|
| 67 | printErrorMsg 169 $mmcmd $device | 
|---|
| 68 | fi | 
|---|
| 69 | rc=22  # EINVAL | 
|---|
| 70 | cleanupAndExit $rc | 
|---|
| 71 | fi | 
|---|
| 72 |  | 
|---|
| 73 |  | 
|---|
| 74 | ##################################################################### | 
|---|
| 75 | # Set up trap exception handling and call the gpfsInit function. | 
|---|
| 76 | # It will ensure that the local copy of the mmsdrfs and the rest | 
|---|
| 77 | # of the GPFS system files are up-to-date. | 
|---|
| 78 | # | 
|---|
| 79 | # Note:  To avoid undesired side effects, tell gpfsInit to restrict | 
|---|
| 80 | #        mount point checking only to the file system that is subject | 
|---|
| 81 | #        to the current invocation of the mmdynamicmap command. | 
|---|
| 82 | ##################################################################### | 
|---|
| 83 | trap pretrap2 HUP INT QUIT KILL | 
|---|
| 84 | export MOUNT_POINT_CHECK="$deviceName" | 
|---|
| 85 | gpfsInitOutput=$(gpfsInit nolock) | 
|---|
| 86 | setGlobalVar $? $gpfsInitOutput | 
|---|
| 87 | unset MOUNT_POINT_CHECK | 
|---|
| 88 |  | 
|---|
| 89 |  | 
|---|
| 90 | ###################################################### | 
|---|
| 91 | # Retrieve the mount information for the file system. | 
|---|
| 92 | # If the device is not found, return 19 (ENODEV). | 
|---|
| 93 | ###################################################### | 
|---|
| 94 | efOptions=$($awk -F: '                                           \ | 
|---|
| 95 | BEGIN {                                                       \ | 
|---|
| 96 | { n = 0 }                                                   \ | 
|---|
| 97 | { mountPoint = "" }                                         \ | 
|---|
| 98 | { fsType     = "" }                                         \ | 
|---|
| 99 | }                                                             \ | 
|---|
| 100 | /':$SG_HEADR:$deviceName:'/ {                                 \ | 
|---|
| 101 | if ( $'$FS_TYPE_Field' == "'$remotefs'" ) {                \ | 
|---|
| 102 | { fsType = "remotefs" }                                 \ | 
|---|
| 103 | { remoteDevName = $'$REMOTE_DEV_NAME_Field' }           \ | 
|---|
| 104 | }                                                          \ | 
|---|
| 105 | else {                                                     \ | 
|---|
| 106 | { fsType = "localfs" }                                  \ | 
|---|
| 107 | }                                                          \ | 
|---|
| 108 | }                                                             \ | 
|---|
| 109 | /':$SG_MOUNT:$deviceName:'/ {                                 \ | 
|---|
| 110 | { printf $'$RW_OPT_Field' }                                \ | 
|---|
| 111 | if ( $'$MTIME_OPT_Field' != "" ) {                         \ | 
|---|
| 112 | { printf ","$'$MTIME_OPT_Field' }                       \ | 
|---|
| 113 | }                                                          \ | 
|---|
| 114 | if ( $'$ATIME_OPT_Field' != "" ) {                         \ | 
|---|
| 115 | { printf ","$'$ATIME_OPT_Field' }                       \ | 
|---|
| 116 | }                                                          \ | 
|---|
| 117 | if ( $'$OTHER_OPT_Field' != "" ) {                         \ | 
|---|
| 118 | { printf ","$'$OTHER_OPT_Field' }                       \ | 
|---|
| 119 | }                                                          \ | 
|---|
| 120 | if ( $'$QUOTA_OPT_Field' != "" ) {                         \ | 
|---|
| 121 | { printf ",quota="$'$QUOTA_OPT_Field' }                 \ | 
|---|
| 122 | }                                                          \ | 
|---|
| 123 | if ( fsType == "remotefs" ) {                              \ | 
|---|
| 124 | { printf ",dev="$'$NODESETID_Field'"\\:"remoteDevName } \ | 
|---|
| 125 | { printf ",ldev='$deviceName'" }                        \ | 
|---|
| 126 | }                                                          \ | 
|---|
| 127 | else {                                                     \ | 
|---|
| 128 | { printf ",dev='$deviceName'" }                         \ | 
|---|
| 129 | }                                                          \ | 
|---|
| 130 | { exit }                                                   \ | 
|---|
| 131 | }                                                             \ | 
|---|
| 132 | END {                                                         \ | 
|---|
| 133 | if ( fsType == "" ) {                                      \ | 
|---|
| 134 | # Filesystem not found - return ENODEV                  \ | 
|---|
| 135 | { exit '$MM_DeviceNotFound' }                           \ | 
|---|
| 136 | }                                                          \ | 
|---|
| 137 | else {                                                     \ | 
|---|
| 138 | # Filesystem found - finish the line.                   \ | 
|---|
| 139 | { printf "\n" }                                         \ | 
|---|
| 140 | { exit  0 }                                             \ | 
|---|
| 141 | }                                                          \ | 
|---|
| 142 | }                                                             \ | 
|---|
| 143 | ' $mmsdrfsFile) | 
|---|
| 144 | rc=$? | 
|---|
| 145 | if [[ $rc -ne 0 || -z $efOptions ]] | 
|---|
| 146 | then | 
|---|
| 147 | [[ $rc -eq  0 ]] && rc=1 | 
|---|
| 148 | if [[ $rc -eq $MM_DeviceNotFound ]] | 
|---|
| 149 | then | 
|---|
| 150 | # File system not found. | 
|---|
| 151 | printErrorMsg 288 $mmcmd $device | 
|---|
| 152 | else | 
|---|
| 153 | # Unexpected error. | 
|---|
| 154 | checkForErrors awk $rc | 
|---|
| 155 | fi | 
|---|
| 156 | cleanupAndExit $rc | 
|---|
| 157 | fi | 
|---|
| 158 |  | 
|---|
| 159 |  | 
|---|
| 160 | ################################# | 
|---|
| 161 | # Put out the result and return. | 
|---|
| 162 | ################################# | 
|---|
| 163 | print -- "-fstype=gpfs,$efOptions :$fqDeviceName" | 
|---|
| 164 |  | 
|---|
| 165 | cleanupAndExit 0 | 
|---|
| 166 |  | 
|---|