1 #!/bin/ksh -p
2 #
3 # CDDL HEADER START
4 #
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
8 #
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
13 #
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 #
20 # CDDL HEADER END
21 #
22
23 #
24 # Copyright 2010 Sun Microsystems, Inc. All rights reserved.
25 #
26
27 #
28 # ID: xattr_003
29 #
30 # DESCRIPTION:
31 # Verify from local tmpfs with xattrs moved to mount point preserve/omit xattrs
32 # and from mount point with xattrs moved to local tmpfs preserve/omit xattrs
33 #
34 # STRATEGY:
35 # 1. Create a file, and set an with an xattr
36 # 2. Move the file to mount point
37 # 3. Check that mv doesn't have any flags to preserve/omit xattrs -
38 # they're always moved.
39 # 4. Do the same in reverse.
40 #
41
42 . $STF_SUITE/include/libtest.ksh
43
44 tc_id=xattr_003
45 tc_desc="Verify from local tmpfs with xattrs moved to mount point preserve/omit xattrs\
46 and from mount point with xattrs moved to local tmpfs preserve/omit xattrs"
47
48 print_test_case $tc_id - $tc_desc
49
50 if [[ $STC_CIFS_CLIENT_DEBUG == 1 ]] || \
51 [[ *:${STC_CIFS_CLIENT_DEBUG}:* == *:$tc_id:* ]]; then
52 set -x
53 fi
54
55 server=$(server_name) || return
56
57 testdir_init $TDIR
58 smbmount_clean $TMNT
59 smbmount_init $TMNT
60
61 cmd="mount -F smbfs //$TUSER:$TPASS@$server/public $TMNT"
62 cti_execute -i '' FAIL $cmd
63 if [[ $? != 0 ]]; then
64 cti_fail "FAIL: smbmount can't mount the public share unexpectedly"
65 return
66 else
67 cti_report "PASS: smbmount can mount the public share as expected"
68 fi
69
70 smbmount_getmntopts $TMNT |grep /xattr/ >/dev/null
71 if [[ $? != 0 ]]; then
72 smbmount_clean $TMNT
73 cti_unsupported "UNSUPPORTED (no xattr in this mount)"
74 return
75 fi
76
77 #create a file in local file system with a xattr and then mv it to mount point
78
79 cti_execute_cmd "touch $TDIR/test_file"
80 create_xattr $TDIR/test_file passwd /etc/passwd
81 cti_execute_cmd "mv $TDIR/test_file $TMNT/test_file"
82 if [[ $? != 0 ]]; then
83 cti_fail "FAIL: can't move the file with xattr from local to mount point unexpectedly
84 "
85 return
86 else
87 cti_report "PASS: can move the file with xattr from local to mount point as expected"
88 fi
89 cti_execute FAIL "runat $TMNT/test_file diff passwd /etc/passwd"
90 if [[ $? != 0 ]]; then
91 cti_fail "FAIL: after move the xattr has changed unexpectedly"
92 return
93 else
94 cti_report "PASS: after move the xattr has not changed as expected"
95 fi
96 cti_execute_cmd "rm -rf $TDIR/*"
97 cti_execute_cmd "rm -rf $TMNT/*"
98
99 #create a file in mount point with a xattr and then mv it to local file system
100
101 cti_execute_cmd "touch $TMNT/test_file"
102 create_xattr $TMNT/test_file passwd /etc/passwd
103 cti_execute_cmd "mv $TMNT/test_file $TDIR/test_file"
104 if [[ $? != 0 ]]; then
105 cti_fail "FAIL: can't move the file with xattr from mount point to local unexpectedly"
106 return
107 else
108 cti_report "PASS: can move the file with xattr from mount point to local as expected"
109 fi
110 cti_execute FAIL "runat $TDIR/test_file diff passwd /etc/passwd"
111 if [[ $? != 0 ]]; then
112 cti_fail "FAIL: after move the xattr has changed unexpectedly"
113 return
114 else
115 cti_report "PASS: after move the xattr has not changed as expected"
116 fi
117
118 smbmount_clean $TMNT
119 cti_pass "$tc_id: PASS"