source: gpfs_3.1_ker2.6.20/lpp/mmfs/bin/mmsdrquery @ 223

Last change on this file since 223 was 16, checked in by rock, 17 years ago
  • Property svn:executable set to *
File size: 30.2 KB
RevLine 
[16]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. 2007
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# @(#)72 1.1.1.1 src/avs/fs/mmfs/ts/admin/mmsdrquery.sh, mmfs, avs_rgpfs24, rgpfs24s011a 3/29/07 15:24:10
17##########################################################################
18#
19# Retrieve the requested information form the mmsdrfs file.
20#
21#   Usage:  mmsdrquery queryType itemList [scope [norefresh]]
22#
23# where
24#
25#   queryType   specifies the type of infromation requested.  The supported
26#               query types are defined in file mmsdrquerydef and can be
27#               specified using either the appropriate keyword or its
28#               corresponding integer value.
29#
30#   itemList    a colon-separated list describing the information that
31#               is to be returned.  The supported items are defined in
32#               file mmsdrquerydef and can be specified using the item's
33#               keyword or integer value.  The 'all' keyword is equivalent
34#               to requesting all currently defined items in the order
35#               in which they appear in the mmsdrquerydef file.
36#
37#   scope       can be used to limit the number of the returned items.
38#               The meaning and syntax of this parameter dependents on
39#               the query type:
40#
41#               - for sdrq_cluster_info the only valid value is 'all'.
42#
43#               - for sdrq_node_info the same syntax must be used as
44#                 for the -N option on mmchnode and similar commands.
45#
46#               - for sdrq_nsd_info the scope parameter can be either
47#                 a list of NSD names, a list of file system device
48#                 names, the keyword 'free_disks', or a fully-qualified
49#                 path name for a file containing NSD or device names.
50#                 All file system device names must include the /dev
51#                 prefix to distinguish them from NSD names.
52#
53#               - for sdrq_fs_info the scope parameter can be either
54#                 a colon-separated list of device names or one of
55#                 the 'all' key words: all, all_local, or all_remote.
56#
57#               If ommitted, 'all' is assumed for all query types.
58#
59#   norefresh   (optional) assume the cached mmsdrfs data is current.
60#
61#
62# The output consists of one or more records, containing the following
63# colon-separated fields:
64#
65#    fixed eycatcher  - the character string 'mmsdrquery'
66#    query type       - the value of the queryType input parameter
67#    error indicator  - if not zero, the rest of the record is undefined
68#    version number   - the value of $sdrq_current_format
69#    reserved field 1
70#    reserved field 2
71#
72# The remainder of the fields represent the values of the requested items
73# in the same order as they appear in the itemList input parameter.
74#
75# If an unkown request type is specified, the error indicator field
76# in the output line is set to 109 (ENOSYS).
77#
78# If the specified object in the scope parameter does not exist, the error
79# indicator in the output line is set to 19 (ENODEV).
80#
81# If an individual item is unknown, or is not supported any more,
82# the corresponding field in the output is set to "sdrq_unknown_item"
83# or "sdr_obsolete_item" respectively.
84#
85##########################################################################
86
87# Include global declarations and service routines.
88. /usr/lpp/mmfs/bin/mmglobfuncs
89. /usr/lpp/mmfs/bin/mmsdrfsdef
90. /usr/lpp/mmfs/bin/mmsdrquerydef
91
92sourceFile="mmsdrquery.sh"
93[[ -n $DEBUG || -n $DEBUGmmsdrquery ]] && set -x
94$mmTRACE_ENTER "$*"
95
96# Local work files.  Names should be of the form:
97#   fn=${tmpDir}fn.${mmcmd}.$$
98
99LOCAL_FILES=" "
100
101# Local declarations
102usageMsg=39
103typeset -l queryType_lc
104typeset -l itemList_lc
105integer seqNumber=0
106rc=0
107reserved=""
108
109
110#############################
111# Check the input arguments.
112#############################
113[[ $arg1 = '-?' || $arg1 = '-h' || $arg1 = '--help' || $arg1 = '--' ]] &&  \
114  syntaxError "help" $usageMsg
115
116queryType=$arg1
117queryType_lc=$queryType
118itemList=$arg2
119itemList_lc=$itemList
120scope=$arg3
121norefresh=$arg4
122
123[[ -z $arg2 ]] && syntaxError "missingArgs" $usageMsg
124[[ -n $arg5 ]] && syntaxError "extraArg"    $usageMsg "$arg5"
125
126
127###########################################################
128# Ensure that the local copy of the mmsdrfs is up-to-date.
129###########################################################
130if [[ -z $norefresh ]]
131then
132  gpfsInitOutput=$(gpfsInit nolock)
133  setGlobalVar $? $gpfsInitOutput
134fi
135
136
137####################################
138# Handle the different query types.
139####################################
140if [[ $queryType_lc = sdrq_cluster_info || $queryType = $sdrq_cluster_info ]]
141then
142  ###############################
143  # Global cluster information
144  ###############################
145
146  # Retrieve and parse the version and nodeset header lines.
147  versionLine=$($head -1 $mmsdrfsFile)
148  nodesetHdrLine=$($grep "^$HOME_CLUSTER:$NODESET_HDR:" $mmsdrfsFile)
149  IFS=":"
150  set -f ; set -A v -- - $versionLine ; set +f
151  set -f ; set -A w -- - $nodesetHdrLine ; set +f
152  IFS="$IFS_sv"
153
154  # If necessary, initialize the item list and print the header line.
155  if [[ $itemList_lc = all ]]
156  then
157    itemList_lc="1001:1002:1003:1004:1005:1006:1007:1008:1009:1010:1011:1012:1013:1014:1015"
158    hdrLine="mmsdrquery:sdrq_cluster_info:HEADER:version:reserved:reserved"
159    hdrLine="${hdrLine}:sdrq_cluster_name:sdrq_cluster_id:sdrq_cluster_type"
160    hdrLine="${hdrLine}:sdrq_primary_server:sdrq_secondary_server:sdrq_rsh_path"
161    hdrLine="${hdrLine}:sdrq_rcp_path:sdrq_uid_domain:sdrq_security_level"
162    hdrLine="${hdrLine}:sdrq_cipher_list:sdrq_tcp_port_number:sdrq_os_environment"
163    hdrLine="${hdrLine}:sdrq_sdrfs_version:sdrq_sdrfs_format:sdrq_sdrfs_gennumber"
164    print -- "${hdrLine}:"
165  fi  # end of if [[ $itemList_lc = all ]]
166
167  # Build the common header; assume everything will be all right.
168  (( seqNumber += 1 ))
169  result="mmsdrquery:sdrq_cluster_info:$rc:$sdrq_current_format:$reserved:$reserved"
170
171  # Parse the item list and build the rest of the output line.
172  IFS=":"
173  for item in $itemList_lc
174  do
175    case $item in
176
177      sdrq_cluster_name | $sdrq_cluster_name )
178        result="${result}:${v[$CLUSTER_NAME_Field]}"
179        ;;
180
181      sdrq_cluster_id | $sdrq_cluster_id )
182        result="${result}:${v[$CLUSTERID_Field]}"
183        ;;
184
185      sdrq_cluster_type | $sdrq_cluster_type )
186        result="${result}:${v[$CLUSTER_TYPE_Field]}"
187        ;;
188
189      sdrq_primary_server | $sdrq_primary_server )
190        result="${result}:${v[$PRIMARY_SERVER_Field]}"
191        ;;
192
193      sdrq_secondary_server | $sdrq_secondary_server )
194        [[ ${v[$BACKUP_SERVER_Field]} = "_NOSECONDARY_" ]] &&  \
195          v[$BACKUP_SERVER_Field]=""
196        result="${result}:${v[$BACKUP_SERVER_Field]}"
197        ;;
198
199      sdrq_rsh_path | $sdrq_rsh_path )
200        [[ -z ${v[$RSH_PATH_Field]} || ${v[$RSH_PATH_Field]} = "_DEFAULT_" ]] &&  \
201          v[$RSH_PATH_Field]=$rsh
202        result="${result}:${v[$RSH_PATH_Field]}"
203        ;;
204
205      sdrq_rcp_path | $sdrq_rcp_path )
206        [[ -z ${v[$RCP_PATH_Field]} || ${v[$RCP_PATH_Field]} = "_DEFAULT_" ]] &&  \
207          v[$RCP_PATH_Field]=$rcp
208        result="${result}:${v[$RCP_PATH_Field]}"
209        ;;
210
211      sdrq_uid_domain | $sdrq_uid_domain )
212        uidDomain=$(showCfgValue uidDomain)
213        [[ -z $uidDomain ]] && uidDomain=${v[$CLUSTER_NAME_Field]}
214        result="${result}:$uidDomain"
215        ;;
216
217      sdrq_sdrfs_version | $sdrq_sdrfs_version )
218        result="${result}:${v[$SDRFS_VERSION_Field]}"
219        ;;
220
221      sdrq_sdrfs_format | $sdrq_sdrfs_format )
222        result="${result}:${v[$SDRFS_FORMAT_Field]}"
223        ;;
224
225      sdrq_sdrfs_gennumber | $sdrq_sdrfs_gennumber )
226        result="${result}:${v[$SDRFS_GENNUM_Field]}"
227        ;;
228
229      sdrq_security_level | $sdrq_security_level )
230        result="${result}:${v[$SECLEVEL_Field]}"
231        ;;
232
233      sdrq_cipher_list | $sdrq_cipher_list )
234        result="${result}:${w[$CIPHER_LIST_Field]}"
235        ;;
236
237      sdrq_tcp_port_number | $sdrq_tcp_port_number )
238        result="${result}:${w[$TCP_PORT_Field]}"
239        ;;
240
241      sdrq_os_environment | $sdrq_os_environment )
242        result="${result}:${w[$OS_ENVIRONMENT_Field]}"
243        ;;
244
245#     xxx | $xxx )
246#       result="${result}:$sdrq_obsolete_item"
247#       ;;
248
249      * ) # Unrecognized item
250        result="${result}:$sdrq_unknown_item"
251        ;;
252    esac  # end of case $item in
253
254  done  # end of for item in $itemList_lc
255  IFS="$IFS_sv"
256
257  # Add trailing colon and print the result.
258  print -- "${result}:"
259
260elif [[ $queryType_lc = sdrq_node_info || $queryType = $sdrq_node_info ]]
261then
262  #############################
263  # Node specific information
264  #############################
265
266  # Process the scope parameter for this query type:
267  #   If scope is not specified, return information for all nodes.
268  #   Otherwise, the scope parameter must confirm to the syntax of
269  #   the -N option for mmchnode and similar commands.
270  [[ -z $scope ]] && scope=all
271  if [[ $scope != all ]]
272  then
273    # Allow any combination of the comma, semi-colon and/or the
274    # colon character to be used as a list separator character.
275    scope=$(print -- "$scope" | $sed 's/:/,/g')
276    scope=$(print -- "$scope" | $sed 's/;/,/g')
277    createVerifiedNodefile "$scope" $REL_HOSTNAME_Field $nodefile
278    if [[ ! -s $nodefile ]]
279    then
280      # No nodes were found that matched the input specification.
281      rc=$MM_DeviceNotFound   # device does not exist (ENODEV)
282      result="mmsdrquery:sdrq_node_info:$rc:$sdrq_current_format:$reserved:$reserved"
283      print -- "${result}:"
284      cleanupAndExit $rc
285    fi  # end of if [[ ! -s $nodefile ]]
286  fi  # end of if [[ $scope != all ]]
287
288  # If necessary, initialize the item list and print the header line.
289  if [[ $itemList_lc = all ]]
290  then
291    itemList_lc="2001:2002:2003:2004:2005:2006:2007:2008:2009:2010"
292    hdrLine="mmsdrquery:sdrq_node_info:HEADER:version:reserved:reserved"
293    hdrLine="${hdrLine}:sdrq_node_number:sdrq_admin_interface:sdrq_daemon_interface"
294    hdrLine="${hdrLine}:sdrq_daemon_ip_address:sdrq_client_node:sdrq_manager_node"
295    hdrLine="${hdrLine}:sdrq_quorum_node:sdrq_product_version:sdrq_daemon_version"
296    hdrLine="${hdrLine}:sdrq_os_name"
297    print -- "${hdrLine}:"
298  fi  # end of if [[ $itemList_lc = all ]]
299
300  # Go through the mmsdrfs file and retrieve the requested information.
301  $rm -f $tmpsdrfs $chnodes $diskLines
302  IFS=":"
303  exec 3<&-
304  exec 3< $mmsdrfsFile
305  while read -u3 sdrfsLine
306  do
307    # Parse the line.
308    set -f ; set -A v -- - $sdrfsLine ; set +f
309
310    IFS="$IFS_sv"
311    getThisNode=""
312
313    case ${v[$LINE_TYPE_Field]} in
314
315      $MEMBER_NODE )
316        if [[ $scope = all ]]
317        then
318          getThisNode=yes
319        else
320          getThisNode=$($grep -w ${v[$REL_HOSTNAME_Field]} $nodefile)
321        fi
322
323        if [[ -n $getThisNode ]]
324        then
325          # Build the common header; assume everything will be all right.
326          (( seqNumber += 1 ))
327          result="mmsdrquery:sdrq_node_info:$rc:$sdrq_current_format:$reserved:$reserved"
328
329          # Parse the item list and build the rest of the output line.
330          IFS=":"
331          for item in $itemList_lc
332          do
333            case $item in
334
335              sdrq_node_number | $sdrq_node_number )
336                result="${result}:${v[$NODE_NUMBER_Field]}"
337                ;;
338
339              sdrq_admin_interface | $sdrq_admin_interface )
340                result="${result}:${v[$REL_HOSTNAME_Field]}"
341                ;;
342
343              sdrq_daemon_interface | $sdrq_daemon_interface )
344                [[ -z ${v[$DAEMON_NODENAME_Field]} ]] &&  \
345                  v[$DAEMON_NODENAME_Field]=${v[$REL_HOSTNAME_Field]}
346                result="${result}:${v[$DAEMON_NODENAME_Field]}"
347                ;;
348
349              sdrq_daemon_ip_address | $sdrq_daemon_ip_address )
350                result="${result}:${v[$IPA_Field]}"
351                ;;
352
353              sdrq_client_node | $sdrq_client_node )
354                [[ ${v[$DESIGNATION_Field]} = "$CLIENT" ]] &&  \
355                  result="${result}:true" || result="${result}:false"
356                ;;
357
358              sdrq_manager_node | $sdrq_manager_node )
359                [[ ${v[$DESIGNATION_Field]} = "$MANAGER" ]] &&  \
360                  result="${result}:true" || result="${result}:false"
361                ;;
362
363              sdrq_quorum_node | $sdrq_quorum_node )
364                [[ ${v[$CORE_QUORUM_Field]} = "$quorumNode" ]] &&  \
365                  result="${result}:true" || result="${result}:false"
366                ;;
367
368              sdrq_product_version | $sdrq_product_version )
369                result="${result}:${v[$PRODUCT_VERSION_Field]}"
370                ;;
371
372              sdrq_daemon_version | $sdrq_daemon_version )
373                result="${result}:${v[$DAEMON_VERSION_Field]}"
374                ;;
375
376              sdrq_os_name | $sdrq_os_name )
377                result="${result}:${v[$OS_NAME_Field]}"
378                ;;
379
380#             xxx | $xxx )
381#               result="${result}:$sdrq_obsolete_item"
382#               ;;
383
384              * ) # Unrecognized item
385                result="${result}:$sdrq_unknown_item"
386                ;;
387            esac  # end of case $item in
388
389          done  # end of for item in $itemList_lc
390          IFS="$IFS_sv"
391
392          # Add trailing colon and print the result.
393          print -- "${result}:"
394
395        fi  # end of if [[ -n $getThisNode ]]
396        ;;
397
398      * )  # Not interested in any ohter lines.
399        ;;
400
401    esac  # end case ${v[$LINE_TYPE_Field]} in
402
403    IFS=":"  # Change the separator back to ":" for the next iteration.
404
405  done  # end while read -u3 sdrfsLine
406
407  IFS="$IFS_sv"  # Restore the default IFS settings.
408
409
410elif [[ $queryType_lc = sdrq_nsd_info || $queryType = $sdrq_nsd_info ]]
411then
412  #############################
413  # NSD specific information
414  #############################
415
416#esjxx - Add code to put out messages for each specifically requested disk name
417#esjxx   that was not found and for each fs device name that was given and that
418#esjxx   does not exist or has no disks (because it is for a remote fs).  This
419#esjxx   should also cover the free disk case
420
421  # Process the scope parameter for this query type:
422  #   If scope is not specified, return information for all disks.
423  #   Otherwise, the scope parameter can be either a list of NSD names,
424  #   file system device names, and/or the keyword 'free_disks', or
425  #   a fully-qualified path name for a file containing NSD or device names.
426  #   All file system device names must include the /dev prefix to distinguish
427  #   them from NSD names.
428
429  if [[ -z $scope || $scope = all ]]
430  then
431    scope=all
432
433  elif [[ $scope = /* && $scope != +(/)dev+(/)* ]]
434  then
435    # The scope parameter is a path name for a file.
436    # Verify the existence of the file and create our own copy.
437    checkUserFile "$scope" $tmpfile
438    [[ $? -ne 0 ]] && cleanupAndExit
439
440  else
441    # The scope parameter is a list of NSD and/or device names.
442    # Allow any combination of the comma, semi-colon and/or the
443    # colon character to be used as a list separator character.
444    scope=$(print -- "$scope" | $sed 's/;/,/g')
445    scope=$(print -- "$scope" | $sed 's/:/,/g')
446
447    # Parse the list and put the items into a file.
448    $rm -f $tmpfile
449    IFS=","
450    for token in $scope
451    do
452      [[ -z $token ]] && continue
453      print -- "$token" >> $tmpfile
454      checkForErrors "writing to file $tmpfile" $?
455    done  # end for token in $scope
456    IFS="$IFS_sv"
457  fi  # end of if [[ -z $scope || $scope = all ]]
458
459  # Separate the NSD names from the file system device names.
460  if [[ $scope != all ]]
461  then
462    $rm -f $diskfile
463    exec 3<&-
464    exec 3< $tmpfile
465    while read -u3 token
466    do
467      if [[ $token = +(/)dev+(/)* ]]
468      then
469        # Add the fs name to the list of file systems.
470        fsList="${fsList} ${token##+(/)dev+(/)}"
471      elif [[ $token = free_disks ]]
472      then
473        # Add the funny NO_DEVICE name to the list of file systems.
474        fsList="${fsList} $NO_DEVICE"
475      elif [[ $token = all ]]
476      then
477        # This will overwrite everything else.
478        scope=all
479        break
480      else
481        # This must be an NSD name.
482        print -- "$token" >> $diskfile
483        checkForErrors "writing to file $diskfile" $?
484      fi
485    done  # end of while read -u3 token
486
487    # Ensure the fsList has a trailing blank.
488    [[ -n $fsList ]] && fsList="${fsList} "
489  fi  # end of if [[ $scope != all ]]
490
491  # If necessary, initialize the item list and print the header line.
492  if [[ $itemList_lc = all ]]
493  then
494    itemList_lc="3001:3002:3003:3004:3005:3006:3007:3008:3009:3010:3011"
495    hdrLine="mmsdrquery:sdrq_nsd_info:HEADER:version:reserved:reserved"
496    hdrLine="${hdrLine}:sdrq_nsd_name:sdrq_nsd_server_list:sdrq_backup_nsd_server_list"
497    hdrLine="${hdrLine}:sdrq_fs_name:sdrq_storage_pool:sdrq_disk_usage"
498    hdrLine="${hdrLine}:sdrq_failure_group:sdrq_nsd_id:sdrq_disk_subtype"
499    hdrLine="${hdrLine}:sdrq_quorum_disk:sdrq_disk_status"
500    print -- "${hdrLine}:"
501  fi  # end of if [[ $itemList_lc = all ]]
502
503  # Go through the mmsdrfs file and retrieve the requested information.
504  $rm -f $tmpsdrfs $chnodes $diskLines
505  IFS=":"
506  exec 3<&-
507  exec 3< $mmsdrfsFile
508  while read -u3 sdrfsLine
509  do
510    # Parse the line.
511    set -f ; set -A v -- - $sdrfsLine ; set +f
512
513    IFS="$IFS_sv"
514
515    case ${v[$LINE_TYPE_Field]} in
516
517      $SG_DISKS )
518        if [[ $scope = all || $fsList = *" ${v[$DEV_NAME_Field]} "* ]]
519        then
520          getThisDisk=yes
521        elif [[ -s $diskfile ]]
522        then
523          getThisDisk=$($grep -w ${v[$DISK_NAME_Field]} $diskfile)
524        else
525          getThisDisk=""
526        fi
527
528        if [[ -n $getThisDisk ]]
529        then
530          # Build the common header; assume everything will be all right.
531          (( seqNumber += 1 ))
532          result="mmsdrquery:sdrq_nsd_info:$rc:$sdrq_current_format:$reserved:$reserved"
533
534          # Parse the item list and build the rest of the output line.
535          IFS=":"
536          for item in $itemList_lc
537          do
538            case $item in
539
540              sdrq_nsd_name | $sdrq_nsd_name )
541                result="${result}:${v[$DISK_NAME_Field]}"
542                ;;
543
544              sdrq_nsd_server_list | $sdrq_nsd_server_list )
545                result="${result}:${v[$NSD_PRIMARY_NODE_Field]}"
546                ;;
547
548              sdrq_backup_nsd_server_list | $sdrq_backup_nsd_server_list )
549                result="${result}:${v[$NSD_BACKUP_NODE_Field]}"
550                ;;
551
552              sdrq_fs_name | $sdrq_fs_name )
553                [[ ${v[$DEV_NAME_Field]} = "$NO_DEVICE" ]] &&  \
554                  v[$DEV_NAME_Field]="free_disk"
555                result="${result}:${v[$DEV_NAME_Field]}"
556                ;;
557
558              sdrq_storage_pool | $sdrq_storage_pool )
559                [[ -z ${v[$STORAGE_POOL_Field]} ]] &&  \
560                  v[$STORAGE_POOL_Field]="system"
561                result="${result}:${v[$STORAGE_POOL_Field]}"
562                ;;
563
564              sdrq_disk_usage | $sdrq_disk_usage )
565                result="${result}:${v[$DISK_USAGE_Field]}"
566                ;;
567
568              sdrq_failure_group | $sdrq_failure_group )
569                result="${result}:${v[$FAILURE_GROUP_Field]}"
570                ;;
571
572              sdrq_nsd_id | $sdrq_nsd_id )
573                result="${result}:${v[$PVID_Field]}"
574                ;;
575
576              sdrq_disk_subtype | $sdrq_disk_subtype )
577                result="${result}:${v[$NSD_SUBTYPE_Field]}"
578                ;;
579
580              sdrq_quorum_disk | $sdrq_quorum_disk )
581                [[ ${v[$PAXOS_Field]} = "$PaxosDisk" ]] &&  \
582                  result="${result}:true" || result="${result}:false"
583                ;;
584
585              sdrq_disk_status | $sdrq_disk_status )
586                [[ -z ${v[$DISK_STATUS_Field]} ]] &&  \
587                  v[$DISK_STATUS_Field]="ready"
588                result="${result}:${v[$DISK_STATUS_Field]}"
589                ;;
590
591#             xxx | $xxx )
592#               result="${result}:$sdrq_obsolete_item"
593#               ;;
594
595              * ) # Unrecognized item
596                result="${result}:$sdrq_unknown_item"
597                ;;
598            esac  # end of case $item in
599
600          done  # end of for item in $itemList_lc
601          IFS="$IFS_sv"
602
603          # Add trailing colon and print the result.
604          print -- "${result}:"
605
606        fi  # end of if [[ -n $getThisDisk ]]
607        ;;
608
609      * )  # Not interested in any ohter lines.
610        ;;
611
612    esac  # end case ${v[$LINE_TYPE_Field]} in
613
614    IFS=":"  # Change the separator back to ":" for the next iteration.
615
616  done  # end while read -u3 sdrfsLine
617
618  IFS="$IFS_sv"  # Restore the default IFS settings.
619
620
621  if [[ $seqNumber -eq 0 ]]
622  then
623    # No disks were found that matched the input specification."
624    rc=$MM_DeviceNotFound   # device does not exist (ENODEV)
625    result="mmsdrquery:sdrq_nsd_info:$rc:$sdrq_current_format:$reserved:$reserved"
626    print -- "${result}:"
627    print -u2 "$mmcmd: No disks were found that matched the input specification."
628  fi  # end of if [[ $seqNumber -eq 0 ]]
629
630
631elif [[ $queryType_lc = sdrq_fs_info  || $queryType = $sdrq_fs_info ]]
632then
633  ###################################
634  # File system specific information
635  ###################################
636
637#esjxx - Add code to put out messages for each specifically requested file system
638#esjxx   that was not found.
639
640  # Process the scope parameter for this query type:
641  #   If scope is not specified, return information for all disks.
642  #   Otherwise, the scope parameter can be either a list of device names
643  #   or one of the 'all' key words: all, all_local, or all_remote.
644
645  if [[ -z $scope || $scope = all ]]
646  then
647    scope=all
648
649  elif [[ $scope = all_local || $scope = all_remote ]]
650  then
651    scope=$scope
652
653# elif [[ $scope = /* && $scope != +(/)dev+(/)* ]]
654# then
655#   # The scope parameter is a path name for a file.
656#   # Verify the existence of the file and create our own copy.
657#   checkUserFile "$scope" $tmpfile
658#   [[ $? -ne 0 ]] && cleanupAndExit
659
660  else
661    # The scope parameter is a list of device names.
662    # Allow any combination of the comma, semi-colon and/or the
663    # colon character to be used as a list separator character.
664    scope=$(print -- "$scope" | $sed 's/;/,/g')
665    scope=$(print -- "$scope" | $sed 's/:/,/g')
666
667    # Parse the list of device names.
668    $rm -f $tmpfile
669    IFS=","
670    for token in $scope
671    do
672      [[ -z $token ]] && continue
673      # Add the fs name to the list of file systems.
674      fsList="${fsList} ${token##+(/)dev+(/)}"
675    done  # end for token in $scope
676    IFS="$IFS_sv"
677
678    # Ensure the fsList has a trailing blank.
679    [[ -n $fsList ]] && fsList="${fsList} "
680  fi  # end of if [[ -z $scope || $scope = all ]]
681
682  # If necessary, initialize the item list and print the header line.
683  if [[ $itemList_lc = all ]]
684  then
685    itemList_lc="4001:4002:4003:4004:4005:4006:4007:4008:4009:4010:4011:4012:4013:4014"
686    hdrLine="mmsdrquery:sdrq_fs_info:HEADER:version:reserved:reserved"
687    hdrLine="${hdrLine}:sdrq_device_name:sdrq_mount_point:sdrq_fs_type"
688    hdrLine="${hdrLine}:sdrq_owning_cluster_name:sdrq_remote_device_name"
689    hdrLine="${hdrLine}:sdrq_automount_option:sdrq_rw_options:sdrq_quota_option"
690    hdrLine="${hdrLine}:sdrq_atime_option:sdrq_mtime_option:sdrq_other_mount_options"
691    hdrLine="${hdrLine}:sdrq_mount_options:sdrq_drive_letter:sdrq_device_minor_number"
692    print -- "${hdrLine}:"
693  fi  # end of if [[ $itemList_lc = all ]]
694
695  # Go through the mmsdrfs file and retrieve the requested information.
696  $rm -f $tmpsdrfs $chnodes $diskLines
697  IFS=":"
698  exec 3<&-
699  exec 3< $mmsdrfsFile
700  while read -u3 sdrfsLine
701  do
702    # Parse the line.
703    set -f ; set -A v -- - $sdrfsLine ; set +f
704
705    IFS="$IFS_sv"
706
707    case ${v[$LINE_TYPE_Field]} in
708
709      $VERSION_LINE )
710        ourClusterName=${v[$CLUSTER_NAME_Field]}
711        ;;
712
713      $SG_HEADR )
714        # Starting the processing of a new file system.
715        # See if the file system should be displayed.
716        if [[ $scope  = all                                            ||
717              $scope  = all_local  && ${v[$FS_TYPE_Field]} = $localfs  ||
718              $scope  = all_remote && ${v[$FS_TYPE_Field]} = $remotefs ||
719              $fsList = *" ${v[$DEV_NAME_Field]} "*                    ]]
720        then
721          getThisFileSystem=yes
722
723          # Start collecting the potentially needed information.
724          # The actual output will be constructed when all of the information
725          # becomes available (when the SG_MOUNT line is processed).
726          remoteDeviceName=${v[$REMOTE_DEV_NAME_Field]}
727          deviceMinorNumber=${v[$DEV_MINOR_Field]}
728          if [[ ${v[$FS_TYPE_Field]} = $localfs ]]
729          then
730            fsType=local
731          else
732            fsType=remote
733          fi
734
735        else
736          getThisFileSystem=""
737        fi  # end of if [[ $scope  = all ...
738        ;;
739
740      $SG_ETCFS )
741        if [[ -n $getThisFileSystem ]]
742        then
743          # Save some more potentially needed information.
744          stanzaLine=${v[$ETCFS_TEXT_Field]}
745          if [[ ${v[$LINE_NUMBER_Field]} = $MOUNT_POINT_Line ]]
746          then
747            mountPoint=$stanzaLine
748          elif [[ ${v[$LINE_NUMBER_Field]} -eq $MOUNT_Line ]]
749          then
750            value=${stanzaLine#*=$BLANKchar}
751            if [[ $value = mmfs ]]
752            then
753              automountOption=yes
754            elif [[ $value = false ]]
755            then
756              automountOption=no
757            else
758              automountOption=$value
759            fi
760          fi  # end of if [[ ${v[$LINE_NUMBER_Field]} = $MOUNT_POINT_Line ]]
761        fi  # end of if [[ -n $getThisFileSystem ]]
762        ;;
763
764
765      $SG_MOUNT )
766        if [[ -n $getThisFileSystem ]]
767        then
768          # Create a combined list of all mount options.
769          rwOption=${v[$RW_OPT_Field]}
770          quotaOption=${v[$QUOTA_OPT_Field]}
771          atimeOption=${v[$ATIME_OPT_Field]}
772          mtimeOption=${v[$MTIME_OPT_Field]}
773          otherMountOptions=${v[$OTHER_OPT_Field]}
774          allMountOptions="${rwOption},${atimeOption},${mtimeOption}"
775          [[ -n $quotaOption ]] &&  \
776            allMountOptions="${allMountOptions},${quotaOption}"
777          [[ -n $otherMountOptions ]] &&  \
778            allMountOptions="${allMountOptions},${otherMountOptions}"
779
780          # At this point all of the needed information is available.
781          # Build the common header; assume everything will be all right.
782          (( seqNumber += 1 ))
783          result="mmsdrquery:sdrq_fs_info:$rc:$sdrq_current_format:$reserved:$reserved"
784
785          # Parse the item list and build the rest of the output line.
786          IFS=":"
787          for item in $itemList_lc
788          do
789            case $item in
790
791              sdrq_device_name | $sdrq_device_name )
792                result="${result}:${v[$DEV_NAME_Field]}"
793                ;;
794
795              sdrq_mount_point | $sdrq_mount_point )
796                result="${result}:$mountPoint"
797                ;;
798
799              sdrq_fs_type | $sdrq_fs_type )
800                result="${result}:$fsType"
801                ;;
802
803              sdrq_owning_cluster_name | $sdrq_owning_cluster_name )
804                if [[ ${v[$NODESETID_Field]} = "$HOME_CLUSTER" ]]
805                then
806                  result="${result}:$ourClusterName"
807                else
808                  result="${result}:${v[$NODESETID_Field]}"
809                fi
810                ;;
811
812              sdrq_remote_device_name | $sdrq_remote_device_name )
813                if [[ -n $remoteDeviceName ]]
814                then
815                  result="${result}:$remoteDeviceName"
816                else
817                  result="${result}:${v[$DEV_NAME_Field]}"
818                fi
819                ;;
820
821              sdrq_automount_option | $sdrq_automount_option )
822                result="${result}:$automountOption"
823                ;;
824
825              sdrq_rw_options | $sdrq_rw_options )
826                result="${result}:$rwOption"
827                ;;
828
829              sdrq_quota_option | $sdrq_quota_option )
830                if [[ -n $quotaOption ]]
831                then
832                  result="${result}:$quotaOption"
833                else
834                  result="${result}:no"
835                fi
836                ;;
837
838              sdrq_atime_option | $sdrq_atime_option )
839                result="${result}:$atimeOption"
840                ;;
841
842              sdrq_mtime_option | $sdrq_mtime_option )
843                result="${result}:$mtimeOption"
844                ;;
845
846              sdrq_other_mount_options | $sdrq_other_mount_options )
847                result="${result}:$otherMountOptions"
848                ;;
849
850              sdrq_mount_options | $sdrq_mount_options )
851                result="${result}:$allMountOptions"
852                ;;
853
854              sdrq_drive_letter | $sdrq_drive_letter )
855                result="${result}:${v[$DRIVE_LETTER_Field]}"
856                ;;
857
858              sdrq_device_minor_number | $sdrq_device_minor_number )
859                result="${result}:$deviceMinorNumber"
860                ;;
861
862#             xxx | $xxx )
863#               result="${result}:$sdrq_obsolete_item"
864#               ;;
865
866              * ) # Unrecognized item
867                result="${result}:$sdrq_unknown_item"
868                ;;
869            esac  # end of case $item in
870
871          done  # end of for item in $itemList_lc
872          IFS="$IFS_sv"
873
874          # Add trailing colon and print the result.
875          print -- "${result}:"
876
877        fi  # end of if [[ -n $getThisFileSystem ]]
878        ;;
879
880      * )  # Not interested in any ohter lines.
881        ;;
882
883    esac  # end case ${v[$LINE_TYPE_Field]} in
884
885    IFS=":"  # Change the separator back to ":" for the next iteration.
886
887  done  # end while read -u3 sdrfsLine
888
889  IFS="$IFS_sv"  # Restore the default IFS settings.
890
891  if [[ $seqNumber -eq 0 ]]
892  then
893    # No file systems were found that matched the input specification."
894    rc=$MM_DeviceNotFound   # device does not exist (ENODEV)
895    result="mmsdrquery:sdrq_fs_info:$rc:$sdrq_current_format:$reserved:$reserved"
896    print -- "${result}:"
897    print -u2 "$mmcmd: No file systems were found that matched the input specification."
898  fi  # end of if [[ $seqNumber -eq 0 ]]
899
900else
901  # Unkown query type
902  print -u2 "$mmcmd:  Unknown query type $queryType"
903  rc=$MM_NotSupported   # function not supported (ENOSYS)
904
905  # Build the common header and print the result.
906  result="mmsdrquery:$queryType:$rc:$sdrq_current_format:$seqNumber:$reserved:$reserved"
907  print -- "${result}:"
908
909fi  # end of if [[ $queryType_lc = sdrq_cluster_info || ...
910
911cleanupAndExit $rc
912
Note: See TracBrowser for help on using the repository browser.