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 - positive tests
  27 #       verify setattr to with different FSs.
  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 
  38 # Start testing
  39 # --------------------------------------------------------------
  40 # a: Setattr mode when FS has no more quota, expect OK
  41 set expcode "OK"
  42 set ASSERTION "Setattr mode while FS has no more quota, expect $expcode"
  43 set tag "$TNAME{a}"
  44 putmsg stdout 0 "$tag: $ASSERTION"
  45 set qpath [path2comp $env(QUOTADIR) $DELM]
  46 set res [compound {Putrootfh; foreach c $qpath {Lookup $c}; 
  47         Getfh; Lookup "quotas"}]
  48 # add check of quota setup for Solaris:
  49 if {($env(SRVOS) == "Solaris") && ($status == "NOENT")} {
  50         putmsg stdout 0 "\t Test NOTINUSE: QUOTA is not setup in server."
  51 } else {
  52         set qfh [lindex [lindex $res end-1] 2]
  53         set stateid {0 0}
  54         set tf "file_$env(TUSER2).2"
  55         set mode 751
  56         if {[is_cipso $env(SERVER)]} {
  57                 set res [exec zlogin $env(ZONENAME) \
  58                         "su $env(TUSER2) -c \"qfh=$qfh; tf=$tf; \
  59                                 mode=$mode; export qfh tf mode; /nfsh /$TNAME\""]
  60                 set nmd [lindex [lindex [lindex [lindex $res 4] 2] 0] 1]
  61                 set status [lindex $res 0]
  62         } else {
  63                 set res [compound {Putfh $qfh; Lookup $tf;
  64                         Setattr $stateid {{mode $mode}}; Getattr mode}]
  65                 set nmd [lindex [lindex [lindex [lindex $res 3] 2] 0] 1]
  66         }
  67 
  68         if {[ckres "Setattr" $status $expcode $res $FAIL] == "true"} {
  69                 if {"$nmd" != "$mode"} {
  70                         putmsg stderr 0 "\t Test FAIL: unexpected value from GETATTR."
  71                         putmsg stderr 1 "\t    res=($res)."
  72                 } else {
  73                         logres PASS
  74                 }
  75         }
  76 }
  77 
  78 
  79 # b: Setattr time_access when FS has no more inode, expect OK
  80 set expcode "OK"
  81 set ASSERTION "Setattr time_access while FS has no more inode, expect $expcode"
  82 set tag "$TNAME{b}"
  83 putmsg stdout 0 "$tag: $ASSERTION"
  84 set tfh [get_fh "[path2comp $env(NSPCDIR) $DELM] $env(RWFILE)"]
  85 set stateid {0 0}
  86 set ntime "[clock seconds] 0"
  87 set res [compound {Putfh $tfh; 
  88         Setattr $stateid {{time_access_set {$ntime}}}; Getattr time_access}]
  89 if {[ckres "Setattr" $status $expcode $res $FAIL] == "true"} {
  90     set aval [lindex [lindex [lindex [lindex $res 2] 2] 0] 1]
  91     if {"$aval" != "$ntime"} {
  92         putmsg stderr 0 "\t Test FAIL: unexpected value from GETATTR."
  93         putmsg stderr 1 "\t    res=($res)."
  94     } else {
  95         logres PASS
  96     }
  97 }
  98 
  99 
 100 # e: Setattr less size when FS has no more disk space, expect OK
 101 set expcode "OK"
 102 set ASSERTION "Setattr less size w/FS has no more disk space, expect $expcode"
 103 set tag "$TNAME{e}"
 104 putmsg stdout 0 "$tag: $ASSERTION"
 105 # Open the tmp file
 106 set bfh [get_fh "[path2comp $env(NSPCDIR) $DELM]"]
 107 set id "[pid]"
 108 set clientid [getclientid $id]
 109 set oseqid 1
 110 set otype 0
 111 set res [compound {Putfh $bfh; 
 112         Open $oseqid 3 0 {$clientid $id} {$otype 0 0} {0 $env(RWFILE)}; 
 113         Getfh; Getattr size}]
 114 if {$status != "OK"} {
 115         putmsg stderr 0 "\t Test UNRESOLVED: Open op failed unexpectedly"
 116         putmsg stderr 1 "\t    res=($res)."
 117 } else {
 118     set open_sid [lindex [lindex $res 1] 2]
 119     set rflags [lindex [lindex $res 1] 4] 
 120     set nfh [lindex [lindex $res 2] 2]
 121     set osize [lindex [lindex [lindex [lindex $res 3] 2] 0] 1]
 122     incr oseqid
 123     if {[expr $rflags & $OPEN4_RESULT_CONFIRM] == $OPEN4_RESULT_CONFIRM} {
 124         set res [compound {Putfh $nfh; Open_confirm "$open_sid" $oseqid}]
 125         set open_sid [lindex [lindex $res 1] 2]
 126         incr oseqid
 127     }
 128     set nsize [expr $osize - 16]
 129     set res [compound {Putfh $nfh; 
 130         Setattr $open_sid {{size $nsize}}}]
 131     ckres "Setattr" $status $expcode $res $PASS
 132     # restore the original size
 133     incr oseqid
 134     set res [compound {Putfh $nfh; 
 135         Setattr $open_sid {{size $osize}}}]
 136     incr oseqid
 137     compound {Putfh $nfh; Close $oseqid $open_sid}
 138 }
 139 
 140 
 141 # --------------------------------------------------------------
 142 # Final cleanup
 143 # disconnect and exit
 144 Disconnect
 145 exit $PASS