]>
git.proxmox.com Git - mirror_zfs-debian.git/blob - tests/zfs-tests/tests/functional/xattr/xattr_011_pos.ksh
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.
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.
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]
22 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 # Use is subject to license terms.
27 # Copyright (c) 2012, 2016 by Delphix. All rights reserved.
31 # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
34 .
$STF_SUITE/include
/libtest.shlib
35 .
$STF_SUITE/tests
/functional
/xattr
/xattr_common.kshlib
40 # Basic applications work with xattrs: cpio cp find mv pax tar
43 # 1. For each application
44 # 2. Create an xattr and archive/move/copy/find files with xattr support
45 # 3. Also check that when appropriate flag is not used, the xattr
51 log_must
rm $TESTDIR/myfile.$$
54 log_assert
"Basic applications work with xattrs: cpio cp find mv pax tar"
57 # Create a file, and set an xattr on it. This file is used in several of the
58 # test scenarios below.
59 log_must
touch $TESTDIR/myfile.$$
60 create_xattr
$TESTDIR/myfile.$$ passwd
/etc
/passwd
63 # For the archive applications below (tar, cpio, pax)
64 # we create two archives, one with xattrs, one without
65 # and try various cpio options extracting the archives
66 # with and without xattr support, checking for correct behaviour
69 log_note
"Checking cpio - unsupported"
71 log_note
"Checking cpio"
72 log_must
touch $TESTDIR/cpio.$$
73 create_xattr
$TESTDIR/cpio.$$ passwd
/etc
/passwd
74 echo $TESTDIR/cpio.$$ |
cpio -o@
> /tmp
/xattr.$$.
cpio
75 echo $TESTDIR/cpio.$$ |
cpio -o > /tmp
/noxattr.$$.
cpio
77 # we should have no xattr here
78 log_must
cpio -iu < /tmp
/xattr.$$.
cpio
79 log_mustnot
eval "runat $TESTDIR/cpio.$$ cat passwd > /dev/null 2>&1"
81 # we should have an xattr here
82 log_must
cpio -iu@
< /tmp
/xattr.$$.
cpio
83 log_must
eval "runat $TESTDIR/cpio.$$ cat passwd > /dev/null 2>&1"
85 # we should have no xattr here
86 log_must
cpio -iu < /tmp
/noxattr.$$.
cpio
87 log_mustnot
eval "runat $TESTDIR/cpio.$$ cat passwd > /dev/null 2>&1"
89 # we should have no xattr here
90 log_must
cpio -iu@
< /tmp
/noxattr.$$.
cpio
91 log_mustnot
eval "runat $TESTDIR/cpio.$$ cat passwd > /dev/null 2>&1"
92 log_must
rm $TESTDIR/cpio.$$
/tmp
/xattr.$$.
cpio /tmp
/noxattr.$$.
cpio
95 log_note
"Checking cp"
96 # check that with the right flag, the xattr is preserved
98 log_must
cp -a $TESTDIR/myfile.$$
$TESTDIR/myfile2.$$
100 compare_xattrs
$TESTDIR/myfile.$$
$TESTDIR/myfile2.$$ passwd
101 log_must
rm $TESTDIR/myfile2.$$
103 # without the right flag, there should be no xattr
104 log_must
cp $TESTDIR/myfile.$$
$TESTDIR/myfile2.$$
105 log_mustnot attr
-q -g passwd
$TESTDIR/myfile2.$$
106 log_must
rm $TESTDIR/myfile2.$$
108 log_must
cp -@
$TESTDIR/myfile.$$
$TESTDIR/myfile2.$$
110 compare_xattrs
$TESTDIR/myfile.$$
$TESTDIR/myfile2.$$ passwd
111 log_must
rm $TESTDIR/myfile2.$$
113 # without the right flag, there should be no xattr
114 log_must
cp $TESTDIR/myfile.$$
$TESTDIR/myfile2.$$
115 log_mustnot
eval "runat $TESTDIR/myfile2.$$ ls passwd > /dev/null 2>&1"
116 log_must
rm $TESTDIR/myfile2.$$
119 # create a file without xattrs, and check that find -xattr only finds
120 # our test file that has an xattr.
122 log_note
"Checking find - unsupported"
124 log_note
"Checking find"
125 log_must mkdir
$TESTDIR/noxattrs
126 log_must
touch $TESTDIR/noxattrs
/no-xattr
128 find $TESTDIR -xattr |
grep myfile.$$
130 log_fail
"find -xattr didn't find our file that had an xattr."
131 find $TESTDIR -xattr |
grep no-xattr
133 log_fail
"find -xattr found a file that didn't have an xattr."
134 log_must
rm -rf $TESTDIR/noxattrs
137 log_note
"Checking mv"
138 # mv doesn't have any flags to preserve/ommit xattrs - they're
140 log_must
touch $TESTDIR/mvfile.$$
141 create_xattr
$TESTDIR/mvfile.$$ passwd
/etc
/passwd
142 log_must
mv $TESTDIR/mvfile.$$
$TESTDIR/mvfile2.$$
143 verify_xattr
$TESTDIR/mvfile2.$$ passwd
/etc
/passwd
144 log_must
rm $TESTDIR/mvfile2.$$
147 log_note
"Checking pax - unsupported"
149 log_note
"Checking pax"
150 log_must
touch $TESTDIR/pax.$$
151 create_xattr
$TESTDIR/pax.$$ passwd
/etc
/passwd
152 log_must pax
-w -f $TESTDIR/noxattr.pax
$TESTDIR/pax.$$
153 log_must pax
-w@
-f $TESTDIR/xattr.pax
$TESTDIR/pax.$$
154 log_must
rm $TESTDIR/pax.$$
156 # we should have no xattr here
157 log_must pax
-r -f $TESTDIR/noxattr.pax
158 log_mustnot
eval "runat $TESTDIR/pax.$$ cat passwd > /dev/null 2>&1"
159 log_must
rm $TESTDIR/pax.$$
161 # we should have no xattr here
162 log_must pax
-r@
-f $TESTDIR/noxattr.pax
163 log_mustnot
eval "runat $TESTDIR/pax.$$ cat passwd > /dev/null 2>&1"
164 log_must
rm $TESTDIR/pax.$$
166 # we should have an xattr here
167 log_must pax
-r@
-f $TESTDIR/xattr.pax
168 verify_xattr
$TESTDIR/pax.$$ passwd
/etc
/passwd
169 log_must
rm $TESTDIR/pax.$$
171 # we should have no xattr here
172 log_must pax
-r -f $TESTDIR/xattr.pax
$TESTDIR
173 log_mustnot
eval "runat $TESTDIR/pax.$$ cat passwd > /dev/null 2>&1"
174 log_must
rm $TESTDIR/pax.$$
$TESTDIR/noxattr.pax
$TESTDIR/xattr.pax
177 log_note
"Checking tar"
179 log_must
touch $TESTDIR/tar.$$
180 create_xattr
$TESTDIR/tar.$$ passwd
/etc
/passwd
184 log_must
tar -cf noxattr.
tar tar.$$
185 log_must
tar --xattrs -cf xattr.
tar tar.$$
186 log_must
rm $TESTDIR/tar.$$
188 # we should have no xattr here
189 log_must
tar --no-xattrs -xf xattr.
tar
190 log_mustnot attr
-q -g passwd
$TESTDIR/tar.$$
191 log_must
rm $TESTDIR/tar.$$
193 # we should have an xattr here
194 log_must
tar --xattrs -xf xattr.
tar
195 verify_xattr
tar.$$ passwd
/etc
/passwd
196 log_must
rm $TESTDIR/tar.$$
198 # we should have no xattr here
199 log_must
tar --no-xattrs -xf $TESTDIR/noxattr.
tar
200 log_mustnot attr
-q -g passwd
$TESTDIR/tar.$$
201 log_must
rm $TESTDIR/tar.$$
203 # we should have no xattr here
204 log_must
tar --xattrs -xf $TESTDIR/noxattr.
tar
205 log_mustnot attr
-q -g passwd
$TESTDIR/tar.$$
206 log_must
rm $TESTDIR/tar.$$
$TESTDIR/noxattr.
tar $TESTDIR/xattr.
tar
208 log_must
touch $TESTDIR/tar.$$
209 create_xattr
$TESTDIR/tar.$$ passwd
/etc
/passwd
213 log_must
tar cf noxattr.
tar tar.$$
214 log_must
tar c@f xattr.
tar tar.$$
215 log_must
rm $TESTDIR/tar.$$
217 # we should have no xattr here
218 log_must
tar xf xattr.
tar
219 log_mustnot
eval "runat $TESTDIR/tar.$$ cat passwd > /dev/null 2>&1"
220 log_must
rm $TESTDIR/tar.$$
222 # we should have an xattr here
223 log_must
tar x@f xattr.
tar
224 verify_xattr
tar.$$ passwd
/etc
/passwd
225 log_must
rm $TESTDIR/tar.$$
227 # we should have no xattr here
228 log_must
tar xf
$TESTDIR/noxattr.
tar
229 log_mustnot
eval "runat $TESTDIR/tar.$$ cat passwd > /dev/null 2>&1"
230 log_must
rm $TESTDIR/tar.$$
232 # we should have no xattr here
233 log_must
tar x@f
$TESTDIR/noxattr.
tar
234 log_mustnot
eval "runat $TESTDIR/tar.$$ cat passwd > /dev/null 2>&1"
235 log_must
rm $TESTDIR/tar.$$
$TESTDIR/noxattr.
tar $TESTDIR/xattr.
tar
238 log_assert
"Basic applications work with xattrs: cpio cp find mv pax tar"