Print this page
XXX Remove nawk(1)

Split Close
Expand all
Collapse all
          --- old/usr/src/test/zfs-tests/include/libtest.shlib
          +++ new/usr/src/test/zfs-tests/include/libtest.shlib
↓ open down ↓ 679 lines elided ↑ open up ↑
 680  680          typeset -i ratio=0
 681  681          ratio=$($PRTVTOC /dev/rdsk/${disk}s2 | \
 682  682                  $GREP "sectors\/cylinder" | \
 683  683                  $AWK '{print $2}')
 684  684  
 685  685          if ((ratio == 0)); then
 686  686                  return
 687  687          fi
 688  688  
 689  689          typeset -i endcyl=$($PRTVTOC -h /dev/rdsk/${disk}s2 |
 690      -                $NAWK -v token="$slice" '{if ($1==token) print $6}')
      690 +                $AWK -v token="$slice" '{if ($1==token) print $6}')
 691  691  
 692  692          ((endcyl = (endcyl + 1) / ratio))
 693  693          echo $endcyl
 694  694  }
 695  695  
 696  696  
 697  697  #
 698  698  # Given a size,disk and total slice number,  this function formats the
 699  699  # disk slices from 0 to the total slice number with the same specified
 700  700  # size.
↓ open down ↓ 639 lines elided ↑ open up ↑
1340 1340          log_must $RM -rf $zdbout
1341 1341  }
1342 1342  
1343 1343  #
1344 1344  # Given a pool, and this function list all disks in the pool
1345 1345  #
1346 1346  function get_disklist # pool
1347 1347  {
1348 1348          typeset disklist=""
1349 1349  
1350      -        disklist=$($ZPOOL iostat -v $1 | $NAWK '(NR >4) {print $1}' | \
     1350 +        disklist=$($ZPOOL iostat -v $1 | $AWK '(NR >4) {print $1}' | \
1351 1351              $GREP -v "\-\-\-\-\-" | \
1352 1352              $EGREP -v -e "^(mirror|raidz1|raidz2|spare|log|cache)$")
1353 1353  
1354 1354          $ECHO $disklist
1355 1355  }
1356 1356  
1357 1357  #
1358 1358  # Destroy all existing metadevices and state database
1359 1359  #
1360 1360  function destroy_metas
↓ open down ↓ 101 lines elided ↑ open up ↑
1462 1462  # and to see if the content of <token> contain the <keyword> specified.
1463 1463  #
1464 1464  # Return 0 is contain, 1 otherwise
1465 1465  #
1466 1466  function check_pool_status # pool token keyword
1467 1467  {
1468 1468          typeset pool=$1
1469 1469          typeset token=$2
1470 1470          typeset keyword=$3
1471 1471  
1472      -        $ZPOOL status -v "$pool" 2>/dev/null | $NAWK -v token="$token:" '
     1472 +        $ZPOOL status -v "$pool" 2>/dev/null | $AWK -v token="$token:" '
1473 1473                  ($1==token) {print $0}' \
1474 1474          | $GREP -i "$keyword" > /dev/null 2>&1
1475 1475  
1476 1476          return $?
1477 1477  }
1478 1478  
1479 1479  #
1480 1480  # These 5 following functions are instance of check_pool_status()
1481 1481  #       is_pool_resilvering - to check if the pool is resilver in progress
1482 1482  #       is_pool_resilvered - to check if the pool is resilver completed
↓ open down ↓ 200 lines elided ↑ open up ↑
1683 1683          $SWAP -l > $sfi
1684 1684          $METASTAT -c > $msi 2>/dev/null
1685 1685          $DUMPADM > $dmpi 2>/dev/null
1686 1686  
1687 1687  # write an awk script that can process the output of format
1688 1688  # to produce a list of disks we know about. Note that we have
1689 1689  # to escape "$2" so that the shell doesn't interpret it while
1690 1690  # we're creating the awk script.
1691 1691  # -------------------
1692 1692          $CAT > /tmp/find_disks.awk <<EOF
1693      -#!/bin/nawk -f
     1693 +#!/usr/xpg4/bin/awk -f
1694 1694          BEGIN { FS="."; }
1695 1695  
1696 1696          /^Specify disk/{
1697 1697                  searchdisks=0;
1698 1698          }
1699 1699  
1700 1700          {
1701 1701                  if (searchdisks && \$2 !~ "^$"){
1702 1702                          split(\$2,arr," ");
1703 1703                          print arr[1];
↓ open down ↓ 616 lines elided ↑ open up ↑
2320 2320  #
2321 2321  # Get the given disk/slice state from the specific field of the pool
2322 2322  #
2323 2323  function get_device_state #pool disk field("", "spares","logs")
2324 2324  {
2325 2325          typeset pool=$1
2326 2326          typeset disk=${2#/dev/dsk/}
2327 2327          typeset field=${3:-$pool}
2328 2328  
2329 2329          state=$($ZPOOL status -v "$pool" 2>/dev/null | \
2330      -                $NAWK -v device=$disk -v pool=$pool -v field=$field \
     2330 +                $AWK -v device=$disk -v pool=$pool -v field=$field \
2331 2331                  'BEGIN {startconfig=0; startfield=0; }
2332 2332                  /config:/ {startconfig=1}
2333 2333                  (startconfig==1) && ($1==field) {startfield=1; next;}
2334 2334                  (startfield==1) && ($1==device) {print $2; exit;}
2335 2335                  (startfield==1) &&
2336 2336                  ($1==field || $1 ~ "^spares$" || $1 ~ "^logs$") {startfield=0}')
2337 2337          echo $state
2338 2338  }
2339 2339  
2340 2340  
↓ open down ↓ 123 lines elided ↑ open up ↑
2464 2464  #
2465 2465  # $1 source string
2466 2466  # $2 start position. Count from 1
2467 2467  # $3 offset
2468 2468  #
2469 2469  function get_substr #src_str pos offset
2470 2470  {
2471 2471          typeset pos offset
2472 2472  
2473 2473          $ECHO $1 | \
2474      -                $NAWK -v pos=$2 -v offset=$3 '{print substr($0, pos, offset)}'
     2474 +                $AWK -v pos=$2 -v offset=$3 '{print substr($0, pos, offset)}'
2475 2475  }
2476 2476  
2477 2477  #
2478 2478  # Check if the given device is physical device
2479 2479  #
2480 2480  function is_physical_device #device
2481 2481  {
2482 2482          typeset device=${1#/dev/dsk/}
2483 2483          device=${device#/dev/rdsk/}
2484 2484  
↓ open down ↓ 87 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX