]>
git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/xattr/xattr_004_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) 2013, 2016 by Delphix. All rights reserved.
30 .
$STF_SUITE/include
/libtest.shlib
31 .
$STF_SUITE/tests
/functional
/xattr
/xattr_common.kshlib
36 # Creating files on ufs|ext and tmpfs, and copying those files to ZFS with
37 # appropriate cp flags, the xattrs will still be readable.
40 # 1. Create files in ufs|ext and tmpfs with xattrs
41 # 2. Copy those files to zfs
42 # 3. Ensure the xattrs can be read and written
43 # 4. Do the same in reverse.
46 # we need to be able to create zvols to hold our test ufs|ext filesystem.
47 verify_runnable
"global"
49 # Make sure we clean up properly
51 if ismounted
/tmp
/$NEWFS_DEFAULT_FS.$$
$NEWFS_DEFAULT_FS; then
52 log_must umount
/tmp
/$NEWFS_DEFAULT_FS.$$
53 log_must
rm -rf /tmp
/$NEWFS_DEFAULT_FS.$$
57 log_assert
"Files from $NEWFS_DEFAULT_FS,tmpfs with xattrs copied to zfs retain xattr info."
60 # Create a ufs|ext file system that we can work in
61 log_must zfs create
-V128m $TESTPOOL/$TESTFS/zvol
63 log_must
eval "new_fs $ZVOL_DEVDIR/$TESTPOOL/$TESTFS/zvol > /dev/null 2>&1"
65 log_must mkdir
/tmp
/$NEWFS_DEFAULT_FS.$$
67 log_must mount
-o user_xattr \
68 $ZVOL_DEVDIR/$TESTPOOL/$TESTFS/zvol
/tmp
/$NEWFS_DEFAULT_FS.$$
70 # Create files in ext and tmpfs, and set some xattrs on them.
71 # Use small values for xattrs for ext compatibility.
72 log_must
touch /tmp
/$NEWFS_DEFAULT_FS.$$
/$NEWFS_DEFAULT_FS-file.$$
74 log_must
touch /tmp
/tmpfs-file.$$
75 echo "TEST XATTR" >/tmp
/xattr1
76 echo "1234567890" >/tmp
/xattr2
77 log_must attr
-q -s xattr1 \
78 /tmp
/$NEWFS_DEFAULT_FS.$$
/$NEWFS_DEFAULT_FS-file.$$
</tmp
/xattr1
79 log_must attr
-q -s xattr2
/tmp
/tmpfs-file.$$
</tmp
/xattr2
81 # copy those files to ZFS
82 log_must
cp -a /tmp
/$NEWFS_DEFAULT_FS.$$
/$NEWFS_DEFAULT_FS-file.$$ \
84 log_must
cp -a /tmp
/tmpfs-file.$$
$TESTDIR
86 # ensure the xattr information has been copied correctly
87 log_must
eval "attr -q -g xattr1 $TESTDIR/$NEWFS_DEFAULT_FS-file.$$ \
90 log_must
diff /tmp
/xattr1.$$
/tmp
/xattr1
91 log_must
eval "attr -q -g xattr2 $TESTDIR/tmpfs-file.$$ >/tmp/xattr2.$$"
92 log_must
diff /tmp
/xattr2.$$
/tmp
/xattr2
93 log_must
rm /tmp
/xattr1
/tmp
/xattr1.$$
/tmp
/xattr2
/tmp
/xattr2.$$
95 log_must umount
/tmp
/$NEWFS_DEFAULT_FS.$$
97 log_must mount
$ZVOL_DEVDIR/$TESTPOOL/$TESTFS/zvol \
98 /tmp
/$NEWFS_DEFAULT_FS.$$
100 # Create files in ufs and tmpfs, and set some xattrs on them.
101 log_must
touch /tmp
/$NEWFS_DEFAULT_FS.$$
/$NEWFS_DEFAULT_FS-file.$$
102 log_must
touch /tmp
/tmpfs-file.$$
104 log_must runat
/tmp
/$NEWFS_DEFAULT_FS.$$
/$NEWFS_DEFAULT_FS-file.$$ \
106 log_must runat
/tmp
/tmpfs-file.$$
cp /etc
/group .
108 # copy those files to ZFS
109 log_must
cp -@
/tmp
/$NEWFS_DEFAULT_FS.$$
/$NEWFS_DEFAULT_FS-file.$$ \
111 log_must
cp -@
/tmp
/tmpfs-file.$$
$TESTDIR
113 # ensure the xattr information has been copied correctly
114 log_must runat
$TESTDIR/$NEWFS_DEFAULT_FS-file.$$ \
115 diff passwd
/etc
/passwd
116 log_must runat
$TESTDIR/tmpfs-file.$$
diff group
/etc
/group
118 log_must umount
/tmp
/$NEWFS_DEFAULT_FS.$$
121 log_pass
"Files from $NEWFS_DEFAULT_FS,tmpfs with xattrs copied to zfs retain xattr info."