Print this page
7290 ZFS test suite needs to control what utilities it can run
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/test/zfs-tests/tests/functional/inuse/inuse_003_pos.ksh
          +++ new/usr/src/test/zfs-tests/tests/functional/inuse/inuse_003_pos.ksh
↓ open down ↓ 18 lines elided ↑ open up ↑
  19   19  #
  20   20  # CDDL HEADER END
  21   21  #
  22   22  
  23   23  #
  24   24  # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  25   25  # Use is subject to license terms.
  26   26  #
  27   27  
  28   28  #
  29      -# Copyright (c) 2012, 2015 by Delphix. All rights reserved.
       29 +# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
  30   30  #
  31   31  
  32   32  . $STF_SUITE/include/libtest.shlib
  33   33  . $STF_SUITE/tests/functional/inuse/inuse.cfg
  34   34  
  35   35  #
  36   36  # DESCRIPTION:
  37   37  # ZFS will not interfere with devices that are in use by ufsdump or
  38   38  # ufsrestore.
  39   39  #
↓ open down ↓ 10 lines elided ↑ open up ↑
  50   50  
  51   51  verify_runnable "global"
  52   52  
  53   53  function cleanup
  54   54  {
  55   55          poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
  56   56  
  57   57          poolexists $TESTPOOL2 && destroy_pool $TESTPOOL2
  58   58  
  59   59          log_note "Kill off ufsdump process if still running"
  60      -        $KILL -0 $PIDUFSDUMP > /dev/null 2>&1 && \
  61      -            log_must $KILL -9 $PIDUFSDUMP  > /dev/null 2>&1
       60 +        kill -0 $PIDUFSDUMP > /dev/null 2>&1 && \
       61 +            log_must kill -9 $PIDUFSDUMP  > /dev/null 2>&1
  62   62          #
  63   63          # Note: It would appear that ufsdump spawns a number of processes
  64   64          # which are not killed when the $PIDUFSDUMP is whacked.  So best bet
  65   65          # is to find the rest of the them and deal with them individually.
  66   66          #
  67      -        for all in `$PGREP ufsdump`
       67 +        for all in `pgrep ufsdump`
  68   68          do
  69      -                $KILL -9 $all > /dev/null 2>&1
       69 +                kill -9 $all > /dev/null 2>&1
  70   70          done
  71   71  
  72   72          log_note "Kill off ufsrestore process if still running"
  73      -        $KILL -0 $PIDUFSRESTORE > /dev/null 2>&1 && \
  74      -            log_must $KILL -9 $PIDUFSRESTORE  > /dev/null 2>&1
       73 +        kill -0 $PIDUFSRESTORE > /dev/null 2>&1 && \
       74 +            log_must kill -9 $PIDUFSRESTORE  > /dev/null 2>&1
  75   75  
  76      -        ismounted $UFSMP ufs && log_must $UMOUNT $UFSMP
       76 +        ismounted $UFSMP ufs && log_must umount $UFSMP
  77   77  
  78      -        $RM -rf $UFSMP
  79      -        $RM -rf $TESTDIR
       78 +        rm -rf $UFSMP
       79 +        rm -rf $TESTDIR
  80   80  
  81   81          #
  82   82          # Tidy up the disks we used.
  83   83          #
  84   84          log_must cleanup_devices $vdisks $sdisks
  85   85  }
  86   86  
  87   87  log_assert "Ensure ZFS does not interfere with devices that are in use by " \
  88   88      "ufsdump or ufsrestore"
  89   89  
↓ open down ↓ 6 lines elided ↑ open up ↑
  96   96  typeset cwd=""
  97   97  
  98   98  for num in 0 1 2; do
  99   99          eval typeset slice=\${FS_SIDE$num}
 100  100          disk=${slice%s*}
 101  101          slice=${slice##*s}
 102  102          log_must set_partition $slice "" $FS_SIZE $disk
 103  103  done
 104  104  
 105  105  log_note "Make a ufs filesystem on source $rawdisk1"
 106      -$ECHO "y" | $NEWFS -v $rawdisk1 > /dev/null 2>&1
      106 +echo "y" | newfs -v $rawdisk1 > /dev/null 2>&1
 107  107  (($? != 0)) && log_untested "Unable to create ufs filesystem on $rawdisk1"
 108  108  
 109      -log_must $MKDIR -p $UFSMP
      109 +log_must mkdir -p $UFSMP
 110  110  
 111  111  log_note "mount source $disk1 on $UFSMP"
 112      -log_must $MOUNT $disk1 $UFSMP
      112 +log_must mount $disk1 $UFSMP
 113  113  
 114  114  log_note "Now create some directories and files to be ufsdump'ed"
 115  115  while (($dirnum <= 2)); do
 116      -        log_must $MKDIR $bigdir${dirnum}
      116 +        log_must mkdir $bigdir${dirnum}
 117  117          while (( $filenum <= 2 )); do
 118      -                $FILE_WRITE -o create -f $bigdir${dirnum}/file${filenum} \
      118 +                file_write -o create -f $bigdir${dirnum}/file${filenum} \
 119  119                      -b $BLOCK_SIZE -c $BLOCK_COUNT
 120  120                  if [[ $? -ne 0 ]]; then
 121  121                          if [[ $dirnum -lt 3 ]]; then
 122      -                                log_fail "$FILE_WRITE only wrote" \
      122 +                                log_fail "file_write only wrote" \
 123  123                                      "<(( $dirnum * 3 + $filenum ))>" \
 124  124                                      "files, this is not enough"
 125  125                          fi
 126  126                  fi
 127  127                  ((filenum = filenum + 1))
 128  128          done
 129  129          filenum=0
 130  130          ((dirnum = dirnum + 1))
 131  131  done
 132  132  
 133      -log_must $UMOUNT $UFSMP
      133 +log_must umount $UFSMP
 134  134  
 135  135  log_note "Start ufsdump in the background"
 136      -log_note "$UFSDUMP 0bf 512 $rawdisk0 $disk1"
 137      -$UFSDUMP 0bf 512 $rawdisk0 $disk1 &
      136 +log_note "ufsdump 0bf 512 $rawdisk0 $disk1"
      137 +ufsdump 0bf 512 $rawdisk0 $disk1 &
 138  138  PIDUFSDUMP=$!
 139  139  
 140  140  unset NOINUSE_CHECK
 141  141  log_note "Attempt to zpool the source device in use by ufsdump"
 142      -log_mustnot $ZPOOL create $TESTPOOL1 "$disk1"
      142 +log_mustnot zpool create $TESTPOOL1 "$disk1"
 143  143  log_mustnot poolexists $TESTPOOL1
 144  144  
 145  145  log_note "Attempt to take the source device in use by ufsdump as spare device"
 146      -log_mustnot $ZPOOL create $TESTPOOL1 "$FS_SIDE2" spare "$disk1"
      146 +log_mustnot zpool create $TESTPOOL1 "$FS_SIDE2" spare "$disk1"
 147  147  log_mustnot poolexists $TESTPOOL1
 148  148  
 149  149  wait $PIDUFSDUMP
 150  150  typeset -i retval=$?
 151      -(($retval != 0)) && log_fail "$UFSDUMP failed with error code $ret_val"
      151 +(($retval != 0)) && log_fail "ufsdump failed with error code $ret_val"
 152  152  
 153      -log_must $MOUNT $disk1 $UFSMP
      153 +log_must mount $disk1 $UFSMP
 154  154  
 155      -log_must $RM -rf $UFSMP/*
 156      -log_must $MKDIR $restored_files
      155 +log_must rm -rf $UFSMP/*
      156 +log_must mkdir $restored_files
 157  157  
 158  158  cwd=$PWD
 159  159  log_must cd $restored_files
 160  160  log_note "Start ufsrestore in the background from the target device"
 161      -log_note "$UFSRESTORE rbf 512 $rawdisk0"
 162      -$UFSRESTORE rbf 512 $rawdisk0 &
      161 +log_note "ufsrestore rbf 512 $rawdisk0"
      162 +ufsrestore rbf 512 $rawdisk0 &
 163  163  PIDUFSRESTORE=$!
 164  164  log_must cd $cwd
 165  165  
 166  166  log_note "Attempt to zpool the restored device in use by ufsrestore"
 167      -log_mustnot $ZPOOL create -f $TESTPOOL2 "$disk1"
      167 +log_mustnot zpool create -f $TESTPOOL2 "$disk1"
 168  168  log_mustnot poolexists $TESTPOOL2
 169  169  
 170  170  log_note "Attempt to take the restored device in use by ufsrestore as spare" \
 171  171      "device"
 172      -log_mustnot $ZPOOL create -f $TESTPOOL2 "$FS_SIDE2" spare "$disk1"
      172 +log_mustnot zpool create -f $TESTPOOL2 "$FS_SIDE2" spare "$disk1"
 173  173  log_mustnot poolexists $TESTPOOL2
 174  174  
 175  175  log_pass "Unable to zpool over a device in use by ufsdump or ufsrestore"
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX