7290 ZFS test suite needs to control what utilities it can run
[unleashed.git] / usr / src / test / zfs-tests / tests / functional / xattr / xattr_004_pos.ksh
blob2234336e7be8506f827479e0eb626dfe09957785
1 #!/bin/ksh -p
3 # CDDL HEADER START
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]
20 # CDDL HEADER END
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
34 # DESCRIPTION:
36 # Creating files on ufs and tmpfs, and copying those files to ZFS with
37 # appropriate cp flags, the xattrs will still be readable.
39 # STRATEGY:
40 # 1. Create files in ufs 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
47 # ufs filesystem.
48 verify_runnable "global"
50 # Make sure we clean up properly
51 function cleanup {
53 if [ $( ismounted /tmp/ufs.$$ ufs ) ]
54 then
55 log_must umount /tmp/ufs.$$
56 log_must rm -rf /tmp/ufs.$$
60 log_assert "Files from ufs,tmpfs with xattrs copied to zfs retain xattr info."
61 log_onexit cleanup
63 # Create a UFS file system that we can work in
64 log_must zfs create -V128m $TESTPOOL/$TESTFS/zvol
65 log_must eval "echo y | newfs /dev/zvol/dsk/$TESTPOOL/$TESTFS/zvol > /dev/null 2>&1"
67 log_must mkdir /tmp/ufs.$$
68 log_must mount /dev/zvol/dsk/$TESTPOOL/$TESTFS/zvol /tmp/ufs.$$
70 # Create files in ufs and tmpfs, and set some xattrs on them.
71 log_must touch /tmp/ufs.$$/ufs-file.$$
72 log_must touch /tmp/tmpfs-file.$$
74 log_must runat /tmp/ufs.$$/ufs-file.$$ cp /etc/passwd .
75 log_must runat /tmp/tmpfs-file.$$ cp /etc/group .
77 # copy those files to ZFS
78 log_must cp -@ /tmp/ufs.$$/ufs-file.$$ $TESTDIR
79 log_must cp -@ /tmp/tmpfs-file.$$ $TESTDIR
81 # ensure the xattr information has been copied correctly
82 log_must runat $TESTDIR/ufs-file.$$ diff passwd /etc/passwd
83 log_must runat $TESTDIR/tmpfs-file.$$ diff group /etc/group
85 log_must umount /tmp/ufs.$$
86 log_pass "Files from ufs,tmpfs with xattrs copied to zfs retain xattr info."