1 #
   2 # CDDL HEADER START
   3 #
   4 # The contents of this file are subject to the terms of the
   5 # Common Development and Distribution License (the "License").
   6 # You may not use this file except in compliance with the License.
   7 #
   8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9 # or http://www.opensolaris.org/os/licensing.
  10 # See the License for the specific language governing permissions
  11 # and limitations under the License.
  12 #
  13 # When distributing Covered Code, include this CDDL HEADER in each
  14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15 # If applicable, add the following below this CDDL HEADER, with the
  16 # fields enclosed by brackets "[]" replaced with your own identifying
  17 # information: Portions Copyright [yyyy] [name of copyright owner]
  18 #
  19 # CDDL HEADER END
  20 #
  21 
  22 #
  23 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  24 # Use is subject to license terms.
  25 #
  26 # NFSv4 SETATTR operation test - negative tests
  27 #       Test NOSPC/DQUOT, need special FSs support
  28 
  29 # include all test enironment
  30 source SETATTR.env
  31 
  32 # connect to the test server
  33 Connect
  34 
  35 # setting local variables
  36 set TNAME $argv0
  37 set bfh [get_fh "$BASEDIRS"]
  38 set owner "owner-Sattr"
  39 
  40 # Start testing
  41 # --------------------------------------------------------------
  42 # a: Setattr size when FS has no more quota, expect DQUOT
  43 set expcode "DQUOT"
  44 set ASSERTION "Setattr while FS has no more quota, expect $expcode"
  45 set tag "$TNAME{a}"
  46 putmsg stdout 0 "$tag: $ASSERTION"
  47 set qpath [path2comp $env(QUOTADIR) $DELM]
  48 set res [compound {Putrootfh; foreach c $qpath {Lookup $c}; 
  49         Getfh; Lookup "quotas"}]
  50 # add check of quota setup for Solaris:
  51 if {($env(SRVOS) == "Solaris") && ($status == "NOENT")} {
  52         putmsg stdout 0 "\t Test NOTINUSE: QUOTA is not setup in server."
  53 } else {
  54         set qfh [lindex [lindex $res end-1] 2]
  55         set tf "file_$env(TUSER2).1"
  56         # set size to 16 (as whole number of diskblocks)
  57         set fsize [expr 1024 * 16]
  58         if {[is_cipso $env(SERVER)]} {
  59                 set ret [exec zlogin $env(ZONENAME) \
  60                         "su $env(TUSER2) -c \"qfh=$qfh; tf=$tf; owner=$owner; \
  61                                 fsize=$fsize; export qfh tf owner fsize; \
  62                                  /nfsh /$TNAME\""]
  63                 puts $ret
  64 
  65                 # get clientid for assertion{b} below 
  66                 set cid [getclientid $owner]
  67                 if {$cid == -1} {
  68                         putmsg stdout 0 "$TNAME: test setup - getclientid"
  69                         putmsg stderr 0 "\t Test UNRESOLVED: unable to get clientid"
  70                         exit $UNRESOLVED
  71                 }
  72         } else {
  73                 set cid [getclientid $owner]
  74                 if {$cid == -1} {
  75                         putmsg stdout 0 "$TNAME: test setup - getclientid"
  76                         putmsg stderr 0 "\t Test UNRESOLVED: unable to get clientid"
  77                         exit $UNRESOLVED
  78                 }
  79                 set cid_owner "$cid $owner"
  80                 set nfh [basic_open $qfh $tf 0 $cid_owner open_sid oseqid status]
  81                 if {$nfh == -1} {
  82                         putmsg stderr 0 \
  83                                 "\t Test UNRESOLVED: basic_open failed, status=$status"
  84                 } else {
  85                         set res [compound {Putfh $nfh; Setattr $open_sid {{size $fsize}}}]
  86                         ckres "Setattr" $status $expcode $res $PASS
  87                         incr oseqid
  88                         compound {Putfh $nfh; Close $oseqid $open_sid}
  89                 }
  90         }
  91 }
  92 
  93 
  94 # b: Setattr bigger size when FS has no more disk space, expect NOSPC
  95 set expcode "NOSPC"
  96 set ASSERTION "Setattr bigger size on a file in NoSPC_FS, expect $expcode"
  97 set tag "$TNAME{b}"
  98 putmsg stdout 0 "$tag: $ASSERTION"
  99 # Open the tmp file
 100 set bfh [get_fh "[path2comp $env(NSPCDIR) $DELM]"]
 101 set cid_owner "$cid $owner-b"
 102 set tf "$env(RWFILE)"
 103 set nfh [basic_open $bfh $tf 0 $cid_owner open_sid oseqid status]
 104 if {$nfh == -1} {
 105         putmsg stderr 0 "\t Test UNRESOLVED: basic_open failed, status=$status"
 106 } else {
 107         # set size to 16 (as whole number of diskblocks)
 108         set fsize [expr 1024 * 16]
 109         set res [compound {Putfh $nfh; Setattr $open_sid {{size $fsize}}}]
 110         ckres "Setattr" $status $expcode $res $PASS
 111         incr oseqid
 112         compound {Putfh $nfh; Close $oseqid $open_sid}
 113 }
 114 
 115 
 116 # c: Setattr time_access_set when FS is READONLY, expect ROFS
 117 set expcode "ROFS"
 118 set ASSERTION "Setattr time_access_set w/target FS READONLY, expect $expcode"
 119 set tag "$TNAME{c}"
 120 putmsg stdout 0 "$tag: $ASSERTION"
 121 set tfh [get_fh "[path2comp $env(ROFSDIR) $DELM] $env(RWFILE)"]
 122 if {$tfh == ""} {
 123         putmsg stdout 0 "\t Test UNTESTED: ROFS is not setup."
 124 } else {
 125         set stateid {0 0}
 126         set ntime "[clock seconds] 0"
 127         set res [compound {Putfh $tfh; 
 128                 Setattr $stateid {{time_access_set {$ntime}}}; 
 129                 Getattr time_access}]
 130         ckres "Setattr" $status $expcode $res $PASS
 131 }
 132 
 133 
 134 # --------------------------------------------------------------
 135 # disconnect and exit
 136 Disconnect
 137 exit $PASS