#!/usr/bin/ksh # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # bos720 src/bos/usr/sbin/lsjfs/lsjfs.sh 1.1.4.2 # # Licensed Materials - Property of IBM # # COPYRIGHT International Business Machines Corp. 1991,1993 # 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 # @(#)85 1.1.4.2 src/bos/usr/sbin/lsjfs/lsjfs.sh, cmdfs, bos720 7/15/11 04:51:45 #### # # This awk script is used to parse the output of lsfs -qc and # put it in a format acceptable to SMIT. # # This script will first determine the vfstype being called for # and based on that type do the following: # # For lsjfs: The lsfs -qc output is: # #MountPoint:Device:Vfs:Nodename:Type:Size:Options:AutoMount:Acct # /:/dev/hd4:jfs::bootfs:8192:rw:yes:no # (lv size 8192:fs size 8192:frag size 4096:nbpi 4096:compress no) # # It needs to be translated into: # #MountPoint:Device:Vfs:Nodename:Type:Size:Options:AutoMount:Acct:\ # OtherOptions:LvSize:FsSize:FragSize:Nbpi:Compress: # /:/dev/hd4:jfs::bootfs:8192:rw:yes:no::8192:8192:4096:4096:no: # # # For lsjfs2: The lsfs -qc output is: # #MountPoint:Device:Vfs:Nodename:Type:Size:Options:AutoMount:Acct # /:/dev/hd4:jfs2::bootfs:8192:rw:yes:no:32 # (lv size 8192:fs size 8192:block size 4096:sparse files yes:inline log no:inline log size 0:EAformat v1:Quota userquota,groupquota:DMAPI no:VIX no:EFS no:ISNAPSHOT no:maxext 32:MountGuard) # # # It needs to be translated into: # #MountPoint:Device:Vfs:Nodename:Type:Size:Options:AutoMount:Acct:\ # OtherOptions:LvSize:FsSize:BlockSize:Sparse:InlineLog:InlineLogSz:EAformat:Quota:DMAPI:VIX:EFS:ISNAPSHOT:maxext:MountGuard # /:/dev/hd4:jfs2::bootfs:8192:rw:yes:no::8192:8192:4096:yes:no:0:v1:userquota,groupquota:no:no:no:no:32:no # #### # We need to determine whether we are being called to check # on jfs or jfs2 filesystems. We can determine that from # how we are called. vfstype=`/usr/bin/basename $0 | /usr/bin/cut -c 3-` fsnamelist=$* if [ -z "$fsnamelist" ] then fsnamelist=`/usr/sbin/lsfs -cv $vfstype | grep -v "#MountPoint" | \ /usr/bin/awk -F: ' { print $1 }'` fi rc=0 print_header=1 for fsname in $fsnamelist do lsfsout=`/usr/sbin/lsfs -cq $fsname` if [ $? -ne 0 ] then rc=1 continue; fi echo "$lsfsout" | /usr/bin/awk -F: -v vfstype=$vfstype -v print_header=$print_header ' BEGIN { # # If the query from lsfs -q fails then then there # will be no parenthetical list. The query_good # flag will be set any time the parenthetical list # is encountered. # query_good = 0 need_query = 0 } # # Match the first line; it begins w/ "#" # NR == 1 && $1 ~ /\#.+/ { # # Print out the lsjfs header, which depends on our type # if (print_header) { if (vfstype == "jfs") { printf ("%s%s\n", $0, \ ":OtherOptions:LvSize:FsSize:FragSize:Nbpi:Compress:Bf:AgSize:"); } else if (vfstype == "jfs2") { printf ("%s%s\n", $0, \ ":OtherOptions:LvSize:FsSize:BlockSize:Sparse:InlineLog:InlineLogSz:EAformat:Quota:DMAPI:VIX:EFS:ISNAPSHOT:maxext:MountGuard"); } else { # Do not have any extra options for this type # But some of the Options get split into OtherOptions printf ("%s%s\n", $0, ":OtherOptions:"); } } continue; } # # Look at vfstype only # NR > 1 && $3 == vfstype { if (NR > 2) { if (query_good) { printf ("\n") query_good = 0 } else if (need_query) { # Fill in blank entries since we did not get # any extra options for this one if (vfstype == "jfs") { printf (":::::::\n") } else if (vfstype == "jfs2") { printf ("::::::::::::\n") } else { printf ("\n") } } } # need_query is set until we see our following query items need_query = 1 # # Print first 6 fields # MountPoint:Device:Vfs:Nodename:Type:Size # for (i = 1; i < 7; ++i) printf ("%s:", $i); # # Pull nodev and nosuid out of 7th field if present; # these will be printed under OtherOptions; this # is a smit requirement. # other["nodev"] = "" other["nosuid"] = "" other["nointegrity"] = "" perm="" n = split($7, options, ","); for (i = 1; i <= n; ++i) { if (options[i] == "rw") perm="rw"; else if (options[i] == "ro" && perm != "rw") perm="ro"; else other[options[i]] = 1; } printf ("%s", perm); for (i = 8; i <= NF; ++i) printf (":%s", $i); printf (":"); sep="" for (i = 0; i <= n; i++) { if (other[options[i]]) { printf("%s%s", sep, options[i]); sep=","; } } printf (":"); continue } # # Process the filesystem query items # Need to check for need_query here. We do not want to pick up the # query items for a different vfstype filesystem if our item did not # have any items. # NR > 1 && $1 ~ /[" "\t]*\(.+[0-9]+/ && need_query { gsub (/[\(\)]/, ""); # # pick out each value out of the parenthetical list. # num_fields = split ($0, fields, ":") for (i = 1; i <= num_fields; i++) { num_values = split (fields[i], values, " "); printf ("%s:", values[num_values]); } query_good = 1 need_query = 0 } # Well this record does not match anything we are looking for. That # means we do not have any query items for the last record we matched, # so we need to unset need_query to prevent picking up some other # vfstype query items. { if (query_good) { printf ("\n") query_good = 0 } else if (need_query) { # Fill in blank entries since we did not get any extra # options for this one if (vfstype == "jfs") { printf (":::::::\n") } else if (vfstype == "jfs2") { printf ("::::::::::::\n") } else { printf ("\n") } } need_query = 0 } END { if (query_good) printf ("\n") else if (need_query) if (vfstype == "jfs") { printf (":::::::\n") } else if (vfstype == "jfs2") { printf ("::::::::::::\n") } else { printf ("\n") } }' print_header=0 done exit $rc