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_004
29 #
30 # DESCRIPTION:
31 # Verify from local tmpfs with xattrs copied to mount point retain xattr info
32 # and from mount point with xattrs copied to local tmpfs retain xattr info
33 #
34 # STRATEGY:
35 # 1. Create files in local tmpfs with xattrs
36 # 2. Copy those files to mount point
37 # 3. Ensure the xattrs can be retain
38 # 4. Do the same in reverse.
39 #
40
41 . $STF_SUITE/include/libtest.ksh
42
43 tc_id=xattr_004
44 tc_desc="Verify from local tmpfs with xattrs copied to mount point retain xattr info\
45 and from mount point with xattrs copied to local tmpfs retain xattr info"
46 print_test_case $tc_id - $tc_desc
47
48 if [[ $STC_CIFS_CLIENT_DEBUG == 1 ]] || \
49 [[ *:${STC_CIFS_CLIENT_DEBUG}:* == *:$tc_id:* ]]; then
50 set -x
51 fi
52
53 server=$(server_name) || return
54
55 testdir_init $TDIR
56 smbmount_clean $TMNT
57 smbmount_init $TMNT
58
59 cmd="mount -F smbfs //$TUSER:$TPASS@$server/public $TMNT"
60 cti_execute -i '' FAIL $cmd
61 if [[ $? != 0 ]]; then
62 cti_fail "FAIL: smbmount can't mount the public share unexpectedly"
63 return
64 else
65 cti_report "PASS: smbmount can mount the public share as expected"
66 fi
67
68 smbmount_getmntopts $TMNT |grep /xattr/ >/dev/null
69 if [[ $? != 0 ]]; then
70 smbmount_clean $TMNT
71 cti_unsupported "UNSUPPORTED (no xattr in this mount)"
72 return
73 fi
74
75 # Create files in local tmpfs, and set some xattrs on them.
76
77 cti_execute_cmd "touch $TDIR/test_file1"
78 cti_execute_cmd "runat $TDIR/test_file1 cp /etc/passwd ."
79
80 # copy local tmpfs to mount point
81
82 cti_execute_cmd "cp -@ $TDIR/test_file1 $TMNT"
83
84 # ensure the xattr information has been copied correctly
85
86 cti_execute_cmd "runat $TMNT/test_file1 diff passwd /etc/passwd"
87 if [[ $? != 0 ]]; then
88 cti_fail "FAIL: file xattr not retain when it copy from local tmpfs to mount point"
89 return
90 else
91 cti_report "PASS: file xattr retain when it copy from local tmpfs to mount point"
92 fi
93 # copy mount point to local tmpfs
94
95 cti_execute_cmd "cp -@ $TMNT/test_file1 $TDIR/test_file2"
96 # ensure the xattr information has been copied correctly
97
98 cti_execute_cmd "runat $TDIR/test_file2 diff passwd /etc/passwd"
99 if [[ $? != 0 ]]; then
100 cti_fail "FAIL: file xattr not retain when it copy from mount point to local tmpfs"
101 return
102 else
103 cti_report "PASS: file xattr retain when it copy from mount point to local tmpfs"
104 fi
105
106 cti_execute_cmd "rm -rf $TDIR/*"
107
108 smbmount_clean $TMNT
109 cti_pass "$tc_id: PASS"