]> granicus.if.org Git - zfs/commitdiff
Enable xattr tests
authorBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 19 May 2017 00:22:04 +0000 (20:22 -0400)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 22 May 2017 16:34:42 +0000 (12:34 -0400)
Updated the xattr_common.ksh helper functions to use the attr
command on Linux to manipulate xattrs.  Added an xattr.cfg file
and reworked the user/group functionality to be consist with
the existing delegate test cases.  The intent of each test
case was preserved.

* xattr_001_pos, xattr_002_neg - Updated to verity xattr=on
  and xattr=sa sytle xattrs.

* xattr_003_neg - Use user_run helper instead of su.

* xattr_004_pos - Updated to work with ext2 xattrs.

* xattr_007_neg - Updated to use attr instead of runat.

* xattr_008_pos, xattr_009_neg8_pos, xattr_010_neg -
  Test cases disables since they aren't applicable to Linux.

* xattr_011_pos - Updated to expected behavior from GNU
  versions of the tested utilities.

* xattr_012_pos - Updated to use xattrtest to create many
  small xattrs instead of a single large one.

* xattr_013_pos - Updated to use attr instead of runat.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #6128

17 files changed:
tests/runfiles/linux.run
tests/zfs-tests/tests/functional/xattr/Makefile.am
tests/zfs-tests/tests/functional/xattr/cleanup.ksh
tests/zfs-tests/tests/functional/xattr/setup.ksh
tests/zfs-tests/tests/functional/xattr/xattr.cfg [new file with mode: 0644]
tests/zfs-tests/tests/functional/xattr/xattr_001_pos.ksh
tests/zfs-tests/tests/functional/xattr/xattr_002_neg.ksh
tests/zfs-tests/tests/functional/xattr/xattr_003_neg.ksh
tests/zfs-tests/tests/functional/xattr/xattr_004_pos.ksh
tests/zfs-tests/tests/functional/xattr/xattr_007_neg.ksh
tests/zfs-tests/tests/functional/xattr/xattr_008_pos.ksh
tests/zfs-tests/tests/functional/xattr/xattr_009_neg.ksh
tests/zfs-tests/tests/functional/xattr/xattr_010_neg.ksh
tests/zfs-tests/tests/functional/xattr/xattr_011_pos.ksh
tests/zfs-tests/tests/functional/xattr/xattr_012_pos.ksh
tests/zfs-tests/tests/functional/xattr/xattr_013_pos.ksh
tests/zfs-tests/tests/functional/xattr/xattr_common.kshlib

index 55fdd5dbeb047d1930812fc90db7d2126f022f04..e83a9ed0f369d618b31245c027ad02a594c572ee 100644 (file)
@@ -547,11 +547,11 @@ tests = ['vdev_zaps_001_pos', 'vdev_zaps_002_pos', 'vdev_zaps_003_pos',
 [tests/functional/write_dirs]
 tests = ['write_dirs_001_pos', 'write_dirs_002_pos']
 
-#[tests/functional/xattr]
-#tests = ['xattr_001_pos', 'xattr_002_neg', 'xattr_003_neg', 'xattr_004_pos',
-#    'xattr_005_pos', 'xattr_006_pos', 'xattr_007_neg', 'xattr_008_pos',
-#    'xattr_009_neg', 'xattr_010_neg', 'xattr_011_pos', 'xattr_012_pos',
-#    'xattr_013_pos']
+[tests/functional/xattr]
+tests = ['xattr_001_pos', 'xattr_002_neg', 'xattr_003_neg', 'xattr_004_pos',
+    'xattr_005_pos', 'xattr_006_pos', 'xattr_007_neg', 'xattr_008_pos',
+    'xattr_009_neg', 'xattr_010_neg', 'xattr_011_pos', 'xattr_012_pos',
+    'xattr_013_pos']
 
 [tests/functional/zvol/zvol_ENOSPC]
 tests = ['zvol_ENOSPC_001_pos']
index ac2cb54b5bdd44b9573cc02599e5a226a22ae525..e404e84b1694a2488205699534739f2ffeccf67f 100644 (file)
@@ -3,6 +3,7 @@ dist_pkgdata_SCRIPTS = \
        xattr_common.kshlib \
        setup.ksh \
        cleanup.ksh \
+       xattr.cfg \
        xattr_001_pos.ksh \
        xattr_002_neg.ksh \
        xattr_003_neg.ksh \
index 10cd733d21fd3d21fefc40b5b96735272cfb2590..5f0a846165c5d27405e598798efc514c14cf8bc5 100755 (executable)
 #
 
 . $STF_SUITE/include/libtest.shlib
+. $STF_SUITE/tests/functional/xattr/xattr_common.kshlib
 
-ZFS_USER=$(cat /tmp/zfs-xattr-test-user.txt)
-rm /tmp/zfs-xattr-test-user.txt
+del_user $ZFS_USER
+del_group $ZFS_GROUP
 
 USES_NIS=$(cat /tmp/zfs-xattr-test-nis.txt)
 rm /tmp/zfs-xattr-test-nis.txt
 
-del_user $ZFS_USER
-
 if [ "${USES_NIS}" == "true" ]
 then
     svcadm enable svc:/network/nis/client:default
index ac82c5919118d5450128ec8a6f59b998444966bc..64f89a3d0afdd105ba2785e0b95142b7cedea833 100755 (executable)
 #
 
 . $STF_SUITE/include/libtest.shlib
+. $STF_SUITE/tests/functional/xattr/xattr_common.kshlib
 
 # if we're running NIS, turn it off until we clean up
 # (it can cause useradd to take a long time, hitting our TIMEOUT)
-USES_NIS=false
-svcs svc:/network/nis/client:default | grep online > /dev/null
-if [ $? -eq 0 ]
-then
-       svcadm disable -t svc:/network/nis/client:default
-       USES_NIS=true
-fi
-
-# Make sure we use a brand new user for this
-ZFS_USER=zxtr
-ZFS_GROUP=staff
-while [ -z "${FOUND}" ]
-do
-       COUNT=0
-       USER_EXISTS=$( grep $ZFS_USER /etc/passwd )
-       if [ ! -z "${USER_EXISTS}" ]
+if is_linux; then
+       USED_NIS=false
+else
+       USES_NIS=false
+       svcs svc:/network/nis/client:default | grep online > /dev/null
+       if [ $? -eq 0 ]
        then
-               ZFS_USER="${ZFS_USER}${COUNT}"
-               COUNT=$(( $COUNT + 1 ))
-       else
-               FOUND="true"
+               svcadm disable -t svc:/network/nis/client:default
+               USES_NIS=true
        fi
-done
+fi
 
+# Make sure we use a brand new user for this
+log_must add_group $ZFS_GROUP
 log_must add_user $ZFS_GROUP $ZFS_USER
 
 echo $ZFS_USER > /tmp/zfs-xattr-test-user.txt
diff --git a/tests/zfs-tests/tests/functional/xattr/xattr.cfg b/tests/zfs-tests/tests/functional/xattr/xattr.cfg
new file mode 100644 (file)
index 0000000..5f47562
--- /dev/null
@@ -0,0 +1,30 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2017 by Lawrence Livermore National Security, LLC.
+# Use is subject to license terms.
+#
+
+export NISSTAFILE=/var/tmp/nis_state
+
+export ZFS_USER=zxtr
+export ZFS_GROUP=zfsgrp
index adb5132f28ffffee7b96711c3f75789eb441c699..ffb7004385280ea8a27e2605ebcb24c3550f1ca1 100755 (executable)
@@ -52,12 +52,18 @@ function cleanup {
        fi
 }
 
+set -A args "on" "sa"
+
 log_assert "Create/read/write/append of xattrs works"
 log_onexit cleanup
 
-log_must touch $TESTDIR/myfile.$$
-create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
-verify_write_xattr $TESTDIR/myfile.$$ passwd
-delete_xattr $TESTDIR/myfile.$$ passwd
+for arg in ${args[*]}; do
+       log_must zfs set xattr=$arg $TESTPOOL
+
+       log_must touch $TESTDIR/myfile.$$
+       create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
+       verify_write_xattr $TESTDIR/myfile.$$ passwd
+       delete_xattr $TESTDIR/myfile.$$ passwd
+done
 
 log_pass "Create/read/write of xattrs works"
index 99212a011066db51b44eba78a51e5f2115b71d84..e379d1586ea907bdacd2bea1e377cb309360313c 100755 (executable)
@@ -46,11 +46,17 @@ function cleanup {
 
 }
 
+set -A args "on" "sa"
+
 log_assert "A read of a non-existent xattr fails"
 log_onexit cleanup
 
-# create a file
-log_must touch $TESTDIR/myfile.$$
-log_mustnot eval "cat $TESTDIR/myfile.$$ not-here.txt > /dev/null 2>&1"
+for arg in ${args[*]}; do
+       log_must zfs set xattr=$arg $TESTPOOL
+
+       # create a file
+       log_must touch $TESTDIR/myfile.$$
+       log_mustnot eval "cat $TESTDIR/myfile.$$ not-here.txt > /dev/null 2>&1"
 
-log_pass "A read of a non-existent xattr fails"
+       log_pass "A read of a non-existent xattr fails"
+done
index 28fae8e6574f853f0a224799a13b4254794b6c81..a56fce4eaba1772f1c46e7dc064073f73a9560de 100755 (executable)
@@ -56,7 +56,21 @@ log_must touch $TESTDIR/myfile.$$
 create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
 
 log_must chmod 000 $TESTDIR/myfile.$$
-log_mustnot su $ZFS_USER -c "runat $TESTDIR/myfile.$$ cat passwd"
-log_mustnot su $ZFS_USER -c "runat $TESTDIR/myfile.$$ cp /etc/passwd ."
+if is_linux; then
+       user_run $ZFS_USER eval \
+           "attr -q -g passwd $TESTDIR/myfile.$$ >/tmp/passwd.$$"
+       log_mustnot diff /etc/passwd /tmp/passwd.$$
+       log_must rm /tmp/passwd.$$
+
+       user_run $ZFS_USER eval \
+           "attr -q -s passwd $TESTDIR/myfile.$$ </etc/group"
+       log_must chmod 644 $TESTDIR/myfile.$$
+       attr -q -g passwd $TESTDIR/myfile.$$ >/tmp/passwd.$$
+       log_must diff /etc/passwd /tmp/passwd.$$
+       log_must rm /tmp/passwd.$$
+else
+       log_mustnot su $ZFS_USER -c "runat $TESTDIR/myfile.$$ cat passwd"
+       log_mustnot su $ZFS_USER -c "runat $TESTDIR/myfile.$$ cp /etc/passwd ."
+fi
 
 log_pass "read/write xattr on a file with no permissions fails"
index 921526315141c489cc76826d34f9c2c54e5f4f59..e5f61d3bfa718c341c63512d0da5254e20580eb0 100755 (executable)
@@ -50,8 +50,7 @@ verify_runnable "global"
 # Make sure we clean up properly
 function cleanup {
 
-       if [ $( ismounted /tmp/$NEWFS_DEFAULT_FS.$$ $NEWFS_DEFAULT_FS ) ]
-       then
+       if ismounted /tmp/$NEWFS_DEFAULT_FS.$$ $NEWFS_DEFAULT_FS; then
                log_must umount /tmp/$NEWFS_DEFAULT_FS.$$
                log_must rm -rf /tmp/$NEWFS_DEFAULT_FS.$$
        fi
@@ -63,25 +62,62 @@ log_onexit cleanup
 # Create a UFS|EXT2 file system that we can work in
 log_must zfs create -V128m $TESTPOOL/$TESTFS/zvol
 block_device_wait
-log_must eval "echo y | $NEWFS $ZVOL_DEVDIR/$TESTPOOL/$TESTFS/zvol > /dev/null 2>&1"
+log_must eval "echo y | newfs $ZVOL_DEVDIR/$TESTPOOL/$TESTFS/zvol > /dev/null 2>&1"
 
 log_must mkdir /tmp/$NEWFS_DEFAULT_FS.$$
-log_must mount $ZVOL_DEVDIR/$TESTPOOL/$TESTFS/zvol /tmp/$NEWFS_DEFAULT_FS.$$
+if is_linux; then
+       log_must mount -o user_xattr \
+           $ZVOL_DEVDIR/$TESTPOOL/$TESTFS/zvol /tmp/$NEWFS_DEFAULT_FS.$$
 
-# Create files in ufs|ext2 and tmpfs, and set some xattrs on them.
-log_must touch /tmp/$NEWFS_DEFAULT_FS.$$/$NEWFS_DEFAULT_FS-file.$$
-log_must touch /tmp/tmpfs-file.$$
+       # Create files in ext2 and tmpfs, and set some xattrs on them.
+       # Use small values for xattrs for ext2 compatibility.
+       log_must touch /tmp/$NEWFS_DEFAULT_FS.$$/$NEWFS_DEFAULT_FS-file.$$
 
-log_must runat /tmp/$NEWFS_DEFAULT_FS.$$/$NEWFS_DEFAULT_FS-file.$$ cp /etc/passwd .
-log_must runat /tmp/tmpfs-file.$$ cp /etc/group .
+       log_must touch /tmp/tmpfs-file.$$
+       echo "TEST XATTR" >/tmp/xattr1
+       echo "1234567890" >/tmp/xattr2
+       log_must attr -q -s xattr1 \
+           /tmp/$NEWFS_DEFAULT_FS.$$/$NEWFS_DEFAULT_FS-file.$$ </tmp/xattr1
+       log_must attr -q -s xattr2 /tmp/tmpfs-file.$$ </tmp/xattr2
 
-# copy those files to ZFS
-log_must cp -@ /tmp/$NEWFS_DEFAULT_FS.$$/$NEWFS_DEFAULT_FS-file.$$ $TESTDIR
-log_must cp -@ /tmp/tmpfs-file.$$ $TESTDIR
+       # copy those files to ZFS
+       log_must cp -a /tmp/$NEWFS_DEFAULT_FS.$$/$NEWFS_DEFAULT_FS-file.$$ \
+           $TESTDIR
+       log_must cp -a /tmp/tmpfs-file.$$ $TESTDIR
 
-# ensure the xattr information has been copied correctly
-log_must runat $TESTDIR/$NEWFS_DEFAULT_FS-file.$$ diff passwd /etc/passwd
-log_must runat $TESTDIR/tmpfs-file.$$ diff group /etc/group
+       # ensure the xattr information has been copied correctly
+       log_must eval "attr -q -g xattr1 $TESTDIR/$NEWFS_DEFAULT_FS-file.$$ \
+           >/tmp/xattr1.$$"
+
+       log_must diff /tmp/xattr1.$$ /tmp/xattr1
+       log_must eval "attr -q -g xattr2 $TESTDIR/tmpfs-file.$$ >/tmp/xattr2.$$"
+       log_must diff /tmp/xattr2.$$ /tmp/xattr2
+       log_must rm /tmp/xattr1 /tmp/xattr1.$$ /tmp/xattr2 /tmp/xattr2.$$
+
+       log_must umount /tmp/$NEWFS_DEFAULT_FS.$$
+else
+       log_must mount $ZVOL_DEVDIR/$TESTPOOL/$TESTFS/zvol \
+           /tmp/$NEWFS_DEFAULT_FS.$$
+
+       # Create files in ufs and tmpfs, and set some xattrs on them.
+       log_must touch /tmp/$NEWFS_DEFAULT_FS.$$/$NEWFS_DEFAULT_FS-file.$$
+       log_must touch /tmp/tmpfs-file.$$
+
+       log_must runat /tmp/$NEWFS_DEFAULT_FS.$$/$NEWFS_DEFAULT_FS-file.$$ \
+            cp /etc/passwd .
+       log_must runat /tmp/tmpfs-file.$$ cp /etc/group .
+
+       # copy those files to ZFS
+       log_must cp -@ /tmp/$NEWFS_DEFAULT_FS.$$/$NEWFS_DEFAULT_FS-file.$$ \
+           $TESTDIR
+       log_must cp -@ /tmp/tmpfs-file.$$ $TESTDIR
+
+       # ensure the xattr information has been copied correctly
+       log_must runat $TESTDIR/$NEWFS_DEFAULT_FS-file.$$ \
+           diff passwd /etc/passwd
+       log_must runat $TESTDIR/tmpfs-file.$$ diff group /etc/group
+
+       log_must umount /tmp/$NEWFS_DEFAULT_FS.$$
+fi
 
-log_must umount /tmp/$NEWFS_DEFAULT_FS.$$
 log_pass "Files from $NEWFS_DEFAULT_FS,tmpfs with xattrs copied to zfs retain xattr info."
index 6b3feeafc05bc63cc08cfbec8b9da2a03f8a15c0..977434cebeb91582f6831314731339e7525ad434 100755 (executable)
@@ -69,13 +69,22 @@ log_must touch $TESTDIR/myfile2.$$
 log_must zfs snapshot $TESTPOOL/$TESTFS@snap
 
 # we shouldn't be able to alter the first file's xattr
-log_mustnot eval " runat $TESTDIR/.zfs/snapshot/snap/myfile.$$ \
-    cp /etc/passwd .  >/tmp/output.$$  2>&1"
-log_must grep  -i  Read-only  /tmp/output.$$
+if is_linux; then
+       log_mustnot eval "attr -s cp $TESTDIR/.zfs/snapshot/snap/myfile.$$ \
+            </etc/passwd  >/tmp/output.$$  2>&1"
+       log_must grep  -i  Read-only  /tmp/output.$$
+       log_must eval "attr -q -l $TESTDIR/.zfs/snapshot/snap/myfile2.$$ \
+           >/tmp/output.$$  2>&1"
+       log_must eval "attr -q -l $TESTDIR/myfile2.$$ >/tmp/expected_output.$$"
+else
+       log_mustnot eval " runat $TESTDIR/.zfs/snapshot/snap/myfile.$$ \
+           cp /etc/passwd .  >/tmp/output.$$  2>&1"
+       log_must grep  -i  Read-only  /tmp/output.$$
+       log_must eval "runat $TESTDIR/.zfs/snapshot/snap/myfile2.$$  \
+           ls >/tmp/output.$$  2>&1"
+       create_expected_output  /tmp/expected_output.$$ SUNWattr_ro SUNWattr_rw
+fi
 
-log_must eval "runat $TESTDIR/.zfs/snapshot/snap/myfile2.$$  \
-    ls >/tmp/output.$$  2>&1"
-create_expected_output  /tmp/expected_output.$$ SUNWattr_ro SUNWattr_rw
 log_must diff /tmp/output.$$ /tmp/expected_output.$$
 
 log_pass "create/write xattr on a snapshot fails"
index 20319967c2e99ac18dc760f64832dec52a0914d6..735f1859a70621cd6620061aabc3064d73d2fead 100755 (executable)
@@ -49,6 +49,10 @@ function cleanup {
        done
 }
 
+if is_linux; then
+       log_unsupported "Test case isn't applicable to Linux"
+fi
+
 log_assert "special . and .. dirs work as expected for xattrs"
 log_onexit cleanup
 
index 6a953cf8417869541fe4c85ffc9198513a959c09..ea5b40eec97f40bdd3e40a7007d725d0f34bcbde 100755 (executable)
 #      3. Verify we're unable to create a hard link
 #
 
+if is_linux; then
+       log_unsupported "Test case isn't applicable to Linux"
+fi
+
 function cleanup {
 
        log_must rm $TESTDIR/myfile.$$
index 43502bfff28b48d601231fc4f3f8b834d4083daf..db218c43418ae13f31247f2e2e331fe4e8a37f3a 100755 (executable)
 #
 #
 
+if is_linux; then
+       log_unsupported "Test case isn't applicable to Linux"
+fi
+
 function cleanup {
 
        log_must rm $TESTDIR/myfile.$$
index 12f067489f20f49f8b862d43facb6e64cf84c9ac..9276d3a1af5612f3d262e27c5121747a5c0ff152 100755 (executable)
@@ -65,60 +65,74 @@ create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
 # and try various cpio options extracting the archives
 # with and without xattr support, checking for correct behaviour
 
-
-log_note "Checking cpio"
-log_must touch $TESTDIR/cpio.$$
-create_xattr $TESTDIR/cpio.$$ passwd /etc/passwd
-echo $TESTDIR/cpio.$$ | cpio -o@ > /tmp/xattr.$$.cpio
-echo $TESTDIR/cpio.$$ | cpio -o > /tmp/noxattr.$$.cpio
-
-# we should have no xattr here
-log_must cpio -iu < /tmp/xattr.$$.cpio
-log_mustnot eval "runat $TESTDIR/cpio.$$ cat passwd > /dev/null 2>&1"
-
-# we should have an xattr here
-log_must cpio -iu@ < /tmp/xattr.$$.cpio
-log_must eval "runat $TESTDIR/cpio.$$ cat passwd > /dev/null 2>&1"
-
-# we should have no xattr here
-log_must cpio -iu < /tmp/noxattr.$$.cpio
-log_mustnot eval "runat $TESTDIR/cpio.$$ cat passwd > /dev/null 2>&1"
-
-# we should have no xattr here
-log_must cpio -iu@ < /tmp/noxattr.$$.cpio
-log_mustnot eval "runat $TESTDIR/cpio.$$ cat passwd > /dev/null 2>&1"
-log_must rm $TESTDIR/cpio.$$ /tmp/xattr.$$.cpio /tmp/noxattr.$$.cpio
-
-
+if is_linux; then
+       log_note "Checking cpio - unsupported"
+else
+       log_note "Checking cpio"
+       log_must touch $TESTDIR/cpio.$$
+       create_xattr $TESTDIR/cpio.$$ passwd /etc/passwd
+       echo $TESTDIR/cpio.$$ | cpio -o@ > /tmp/xattr.$$.cpio
+       echo $TESTDIR/cpio.$$ | cpio -o > /tmp/noxattr.$$.cpio
+
+       # we should have no xattr here
+       log_must cpio -iu < /tmp/xattr.$$.cpio
+       log_mustnot eval "runat $TESTDIR/cpio.$$ cat passwd > /dev/null 2>&1"
+
+       # we should have an xattr here
+       log_must cpio -iu@ < /tmp/xattr.$$.cpio
+       log_must eval "runat $TESTDIR/cpio.$$ cat passwd > /dev/null 2>&1"
+
+       # we should have no xattr here
+       log_must cpio -iu < /tmp/noxattr.$$.cpio
+       log_mustnot eval "runat $TESTDIR/cpio.$$ cat passwd > /dev/null 2>&1"
+
+       # we should have no xattr here
+       log_must cpio -iu@ < /tmp/noxattr.$$.cpio
+       log_mustnot eval "runat $TESTDIR/cpio.$$ cat passwd > /dev/null 2>&1"
+       log_must rm $TESTDIR/cpio.$$ /tmp/xattr.$$.cpio /tmp/noxattr.$$.cpio
+fi
 
 log_note "Checking cp"
 # check that with the right flag, the xattr is preserved
-log_must cp -@ $TESTDIR/myfile.$$ $TESTDIR/myfile2.$$
-compare_xattrs $TESTDIR/myfile.$$ $TESTDIR/myfile2.$$ passwd
-log_must rm $TESTDIR/myfile2.$$
+if is_linux; then
+       log_must cp -a $TESTDIR/myfile.$$ $TESTDIR/myfile2.$$
 
-# without the right flag, there should be no xattr
-log_must cp $TESTDIR/myfile.$$ $TESTDIR/myfile2.$$
-log_mustnot eval "runat $TESTDIR/myfile2.$$ ls passwd > /dev/null 2>&1"
-log_must rm $TESTDIR/myfile2.$$
+       compare_xattrs $TESTDIR/myfile.$$ $TESTDIR/myfile2.$$ passwd
+       log_must rm $TESTDIR/myfile2.$$
 
+       # without the right flag, there should be no xattr
+       log_must cp $TESTDIR/myfile.$$ $TESTDIR/myfile2.$$
+       log_mustnot attr -q -g passwd $TESTDIR/myfile2.$$
+       log_must rm $TESTDIR/myfile2.$$
+else
+       log_must cp -@ $TESTDIR/myfile.$$ $TESTDIR/myfile2.$$
 
+       compare_xattrs $TESTDIR/myfile.$$ $TESTDIR/myfile2.$$ passwd
+       log_must rm $TESTDIR/myfile2.$$
+
+       # without the right flag, there should be no xattr
+       log_must cp $TESTDIR/myfile.$$ $TESTDIR/myfile2.$$
+       log_mustnot eval "runat $TESTDIR/myfile2.$$ ls passwd > /dev/null 2>&1"
+       log_must rm $TESTDIR/myfile2.$$
+fi
 
-log_note "Checking find"
 # create a file without xattrs, and check that find -xattr only finds
 # our test file that has an xattr.
-log_must mkdir $TESTDIR/noxattrs
-log_must touch $TESTDIR/noxattrs/no-xattr
-
-find $TESTDIR -xattr | grep myfile.$$
-[[ $? -ne 0 ]] && \
-       log_fail "find -xattr didn't find our file that had an xattr."
-find $TESTDIR -xattr | grep no-xattr
-[[ $? -eq 0 ]] && \
-       log_fail "find -xattr found a file that didn't have an xattr."
-log_must rm -rf $TESTDIR/noxattrs
-
-
+if is_linux; then
+       log_note "Checking find - unsupported"
+else
+       log_note "Checking find"
+       log_must mkdir $TESTDIR/noxattrs
+       log_must touch $TESTDIR/noxattrs/no-xattr
+
+       find $TESTDIR -xattr | grep myfile.$$
+       [[ $? -ne 0 ]] && \
+               log_fail "find -xattr didn't find our file that had an xattr."
+       find $TESTDIR -xattr | grep no-xattr
+       [[ $? -eq 0 ]] && \
+               log_fail "find -xattr found a file that didn't have an xattr."
+       log_must rm -rf $TESTDIR/noxattrs
+fi
 
 log_note "Checking mv"
 # mv doesn't have any flags to preserve/ommit xattrs - they're
@@ -129,65 +143,96 @@ log_must mv $TESTDIR/mvfile.$$ $TESTDIR/mvfile2.$$
 verify_xattr $TESTDIR/mvfile2.$$ passwd /etc/passwd
 log_must rm $TESTDIR/mvfile2.$$
 
-
-log_note "Checking pax"
-log_must touch $TESTDIR/pax.$$
-create_xattr $TESTDIR/pax.$$ passwd /etc/passwd
-log_must pax -w -f $TESTDIR/noxattr.pax $TESTDIR/pax.$$
-log_must pax -w@ -f $TESTDIR/xattr.pax $TESTDIR/pax.$$
-log_must rm $TESTDIR/pax.$$
-
-# we should have no xattr here
-log_must pax -r -f $TESTDIR/noxattr.pax
-log_mustnot eval "runat $TESTDIR/pax.$$ cat passwd > /dev/null 2>&1"
-log_must rm $TESTDIR/pax.$$
-
-# we should have no xattr here
-log_must pax -r@ -f $TESTDIR/noxattr.pax
-log_mustnot eval "runat $TESTDIR/pax.$$ cat passwd > /dev/null 2>&1"
-log_must rm $TESTDIR/pax.$$
-
-
-# we should have an xattr here
-log_must pax -r@ -f $TESTDIR/xattr.pax
-verify_xattr $TESTDIR/pax.$$ passwd /etc/passwd
-log_must rm $TESTDIR/pax.$$
-
-# we should have no xattr here
-log_must pax -r -f $TESTDIR/xattr.pax $TESTDIR
-log_mustnot eval "runat $TESTDIR/pax.$$ cat passwd > /dev/null 2>&1"
-log_must rm $TESTDIR/pax.$$ $TESTDIR/noxattr.pax $TESTDIR/xattr.pax
-
+if is_linux; then
+       log_note "Checking pax - unsupported"
+else
+       log_note "Checking pax"
+       log_must touch $TESTDIR/pax.$$
+       create_xattr $TESTDIR/pax.$$ passwd /etc/passwd
+       log_must pax -w -f $TESTDIR/noxattr.pax $TESTDIR/pax.$$
+       log_must pax -w@ -f $TESTDIR/xattr.pax $TESTDIR/pax.$$
+       log_must rm $TESTDIR/pax.$$
+
+       # we should have no xattr here
+       log_must pax -r -f $TESTDIR/noxattr.pax
+       log_mustnot eval "runat $TESTDIR/pax.$$ cat passwd > /dev/null 2>&1"
+       log_must rm $TESTDIR/pax.$$
+
+       # we should have no xattr here
+       log_must pax -r@ -f $TESTDIR/noxattr.pax
+       log_mustnot eval "runat $TESTDIR/pax.$$ cat passwd > /dev/null 2>&1"
+       log_must rm $TESTDIR/pax.$$
+
+       # we should have an xattr here
+       log_must pax -r@ -f $TESTDIR/xattr.pax
+       verify_xattr $TESTDIR/pax.$$ passwd /etc/passwd
+       log_must rm $TESTDIR/pax.$$
+
+       # we should have no xattr here
+       log_must pax -r -f $TESTDIR/xattr.pax $TESTDIR
+       log_mustnot eval "runat $TESTDIR/pax.$$ cat passwd > /dev/null 2>&1"
+       log_must rm $TESTDIR/pax.$$ $TESTDIR/noxattr.pax $TESTDIR/xattr.pax
+fi
 
 log_note "Checking tar"
-log_must touch $TESTDIR/tar.$$
-create_xattr $TESTDIR/tar.$$ passwd /etc/passwd
-
-log_must cd $TESTDIR
-
-log_must tar cf noxattr.tar tar.$$
-log_must tar c@f xattr.tar tar.$$
-log_must rm $TESTDIR/tar.$$
-
-# we should have no xattr here
-log_must tar xf xattr.tar
-log_mustnot eval "runat $TESTDIR/tar.$$ cat passwd > /dev/null 2>&1"
-log_must rm $TESTDIR/tar.$$
-
-# we should have an xattr here
-log_must tar x@f xattr.tar
-verify_xattr tar.$$ passwd /etc/passwd
-log_must rm $TESTDIR/tar.$$
-
-# we should have no xattr here
-log_must tar xf $TESTDIR/noxattr.tar
-log_mustnot eval "runat $TESTDIR/tar.$$ cat passwd > /dev/null 2>&1"
-log_must rm $TESTDIR/tar.$$
-
-# we should have no xattr here
-log_must tar x@f $TESTDIR/noxattr.tar
-log_mustnot eval "runat $TESTDIR/tar.$$ cat passwd > /dev/null 2>&1"
-log_must rm $TESTDIR/tar.$$ $TESTDIR/noxattr.tar $TESTDIR/xattr.tar
-
+if is_linux; then
+       log_must touch $TESTDIR/tar.$$
+       create_xattr $TESTDIR/tar.$$ passwd /etc/passwd
+
+       log_must cd $TESTDIR
+
+       log_must tar -cf noxattr.tar tar.$$
+       log_must tar --xattrs -cf xattr.tar tar.$$
+       log_must rm $TESTDIR/tar.$$
+
+       # we should have no xattr here
+       log_must tar --no-xattrs -xf xattr.tar
+       log_mustnot attr -q -g passwd $TESTDIR/tar.$$
+       log_must rm $TESTDIR/tar.$$
+
+       # we should have an xattr here
+       log_must tar --xattrs -xf xattr.tar
+       verify_xattr tar.$$ passwd /etc/passwd
+       log_must rm $TESTDIR/tar.$$
+
+       # we should have no xattr here
+       log_must tar --no-xattrs -xf $TESTDIR/noxattr.tar
+       log_mustnot attr -q -g passwd $TESTDIR/tar.$$
+       log_must rm $TESTDIR/tar.$$
+
+       # we should have no xattr here
+       log_must tar --xattrs -xf $TESTDIR/noxattr.tar
+       log_mustnot attr -q -g passwd $TESTDIR/tar.$$
+       log_must rm $TESTDIR/tar.$$ $TESTDIR/noxattr.tar $TESTDIR/xattr.tar
+else
+       log_must touch $TESTDIR/tar.$$
+       create_xattr $TESTDIR/tar.$$ passwd /etc/passwd
+
+       log_must cd $TESTDIR
+
+       log_must tar cf noxattr.tar tar.$$
+       log_must tar c@f xattr.tar tar.$$
+       log_must rm $TESTDIR/tar.$$
+
+       # we should have no xattr here
+       log_must tar xf xattr.tar
+       log_mustnot eval "runat $TESTDIR/tar.$$ cat passwd > /dev/null 2>&1"
+       log_must rm $TESTDIR/tar.$$
+
+       # we should have an xattr here
+       log_must tar x@f xattr.tar
+       verify_xattr tar.$$ passwd /etc/passwd
+       log_must rm $TESTDIR/tar.$$
+
+       # we should have no xattr here
+       log_must tar xf $TESTDIR/noxattr.tar
+       log_mustnot eval "runat $TESTDIR/tar.$$ cat passwd > /dev/null 2>&1"
+       log_must rm $TESTDIR/tar.$$
+
+       # we should have no xattr here
+       log_must tar x@f $TESTDIR/noxattr.tar
+       log_mustnot eval "runat $TESTDIR/tar.$$ cat passwd > /dev/null 2>&1"
+       log_must rm $TESTDIR/tar.$$ $TESTDIR/noxattr.tar $TESTDIR/xattr.tar
+fi
 
 log_assert "Basic applications work with xattrs: cpio cp find mv pax tar"
index 26d6bd7dd75b178b617d33e63957acfc49b97993..7241caf8eb63a70a478e64016f34dab8661eeb76 100755 (executable)
@@ -79,10 +79,16 @@ fi
 
 FS_SIZE=$(zfs get -p -H -o value used $TESTPOOL/$TESTFS)
 
-log_must runat $TESTDIR/myfile.$$ mkfile 200m xattr
+if is_linux; then
+       # Linux setxattr() syscalls limits individual xattrs to 64k.  Create
+       # 100 files, with 128 xattrs each of size 16k.  100*128*16k=200m
+       log_must xattrtest -k -f 100 -x 128 -s 16384 -p $TESTDIR
+else
+       log_must runat $TESTDIR/myfile.$$ mkfile 200m xattr
+fi
 
 #Make sure the newly created file is counted into zpool usage
-log_must sync
+sync_pool
 
 # now check to see if our pool disk usage has increased
 if is_global_zone
index 50b8ffbfaca12c5c314a7e90ef5bfa1b349da80d..e9eed69552c83a9d8b0479a69909e6524914df78 100755 (executable)
@@ -65,13 +65,25 @@ log_must umount $TESTDIR
 log_must zfs mount -o noxattr $TESTPOOL/$TESTFS
 
 # check that we can't perform xattr operations
-log_mustnot eval "runat $TESTDIR/myfile.$$ cat passwd > /dev/null 2>&1"
-log_mustnot eval "runat $TESTDIR/myfile.$$ rm passwd > /dev/null 2>&1"
-log_mustnot eval "runat $TESTDIR/myfile.$$ cp /etc/passwd . > /dev/null 2>&1"
-
-log_must touch $TESTDIR/new.$$
-log_mustnot eval "runat $TESTDIR/new.$$ cp /etc/passwd . > /dev/null 2>&1"
-log_mustnot eval "runat $TESTDIR/new.$$ rm passwd > /dev/null 2>&1"
+if is_linux; then
+       log_mustnot attr -q -g passwd $TESTDIR/myfile.$$
+       log_mustnot attr -q -r passwd $TESTDIR/myfile.$$
+       log_mustnot attr -q -s passwd $TESTDIR/myfile.$$ </etc/passwd
+
+       log_must touch $TESTDIR/new.$$
+       log_mustnot attr -q -s passwd $TESTDIR/new.$$ </etc/passwd
+       log_mustnot attr -q -r passwd $TESTDIR/new.$$
+else
+       log_mustnot eval "runat $TESTDIR/myfile.$$ cat passwd > /dev/null 2>&1"
+       log_mustnot eval "runat $TESTDIR/myfile.$$ rm passwd > /dev/null 2>&1"
+       log_mustnot eval "runat $TESTDIR/myfile.$$ cp /etc/passwd . \
+           > /dev/null 2>&1"
+
+       log_must touch $TESTDIR/new.$$
+       log_mustnot eval "runat $TESTDIR/new.$$ cp /etc/passwd . \
+           > /dev/null 2>&1"
+       log_mustnot eval "runat $TESTDIR/new.$$ rm passwd > /dev/null 2>&1"
+fi
 
 # now mount the filesystem again as normal
 log_must umount $TESTDIR
@@ -82,7 +94,11 @@ verify_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
 
 # there should be no xattr on the file we created while the fs was mounted
 # -o noxattr
-log_mustnot eval "runat $TESTDIR/new.$$ cat passwd > /dev/null 2>&1"
+if is_linux; then
+       log_mustnot attr -q -g passwd $TESTDIR/new.$$
+else
+       log_mustnot eval "runat $TESTDIR/new.$$ cat passwd > /dev/null 2>&1"
+fi
 create_xattr $TESTDIR/new.$$ passwd /etc/passwd
 
 log_pass "The noxattr mount option functions as expected"
index 56710093406c174a2595a30c637300b7973a32a1..d2399310b59eba5bdd6e15200bc51b33dcef17a3 100644 (file)
@@ -29,6 +29,7 @@
 #
 
 . $STF_SUITE/include/libtest.shlib
+. $STF_SUITE/tests/functional/xattr/xattr.cfg
 
 # a function that takes a file, then creates and verifies
 # an xattr on that file. The xattr_contents is the file
@@ -38,10 +39,15 @@ function create_xattr { # filename xattr_name xattr_contents
        typeset XATTR_NAME=$2
        typeset XATTR_CONTENTS=$3
 
-       # read any empty xattr on that file
-       log_must runat $FILE ls
-       # create the xattr
-       log_must runat $FILE cp $XATTR_CONTENTS $XATTR_NAME
+       if is_linux; then
+               log_mustnot attr -q -g $XATTR_NAME $FILE
+               log_must attr -q -s $XATTR_NAME $FILE < $XATTR_CONTENTS
+       else
+               # read any empty xattr on that file
+               log_must runat $FILE ls
+               # create the xattr
+               log_must runat $FILE cp $XATTR_CONTENTS $XATTR_NAME
+       fi
 
        verify_xattr $FILE $XATTR_NAME $XATTR_CONTENTS
 }
@@ -53,8 +59,13 @@ function compare_xattrs { # filename1 filename2 xattr_name
        typeset FILE2=$2
        typeset XATTR_NAME=$3
 
-       runat $FILE1 cat $XATTR_NAME > /tmp/file1.$$
-       runat $FILE2 cat $XATTR_NAME > /tmp/file2.$$
+       if is_linux; then
+               attr -q -g $XATTR_NAME $FILE1 >/tmp/file1.$$
+               attr -q -g $XATTR_NAME $FILE2 >/tmp/file2.$$
+       else
+               runat $FILE1 cat $XATTR_NAME > /tmp/file1.$$
+               runat $FILE2 cat $XATTR_NAME > /tmp/file2.$$
+       fi
 
        log_must diff /tmp/file1.$$ /tmp/file2.$$
        log_must rm /tmp/file1.$$ /tmp/file2.$$
@@ -66,7 +77,14 @@ function verify_xattr { # filename xattr_name xattr_contents
        typeset XATTR_CONTENTS=$3
 
        # read the xattr, writing it to a temp file
-       log_must eval "runat $FILE cat $XATTR_NAME > /tmp/$XATTR_NAME.$$ 2>&1"
+       if is_linux; then
+               log_must eval \
+                   "attr -q -g $XATTR_NAME $FILE >/tmp/$XATTR_NAME.$$"
+       else
+               log_must eval \
+                   "runat $FILE cat $XATTR_NAME >/tmp/$XATTR_NAME.$$ 2>&1"
+       fi
+
        log_must diff $XATTR_CONTENTS /tmp/$XATTR_NAME.$$
        rm /tmp/$XATTR_NAME.$$
 }
@@ -76,8 +94,13 @@ function delete_xattr { # filename xattr_name
         typeset XATTR_NAME=$2
 
         # delete the xattr
-        log_must runat $FILE rm $XATTR_NAME
-        log_mustnot eval "runat $FILE ls $XATTR_NAME > /dev/null 2>&1"
+        if is_linux; then
+               log_must attr -r $XATTR_NAME $FILE
+               log_mustnot attr -q -g $XATTR_NAME $FILE
+       else
+               log_must runat $FILE rm $XATTR_NAME
+               log_mustnot eval "runat $FILE ls $XATTR_NAME > /dev/null 2>&1"
+       fi
 }
 
 # not sure about this : really this should be testing write/append
@@ -85,8 +108,15 @@ function verify_write_xattr { # filename xattr_name
         typeset FILE=$1
         typeset XATTR_NAME=$2
 
-        log_must eval "runat $FILE dd if=/etc/passwd of=$XATTR_NAME"
-        log_must eval "runat $FILE cat $XATTR_NAME > /tmp/$XATTR_NAME.$$ 2>&1"
+       if is_linux; then
+                log_must attr -q -s $XATTR_NAME $FILE < /etc/passwd
+               log_must eval \
+                   "attr -q -g $XATTR_NAME $FILE >/tmp/$XATTR_NAME.$$"
+       else
+               log_must eval "runat $FILE dd if=/etc/passwd of=$XATTR_NAME"
+               log_must eval \
+                   "runat $FILE cat $XATTR_NAME > /tmp/$XATTR_NAME.$$ 2>&1"
+       fi
         log_must dd if=/etc/passwd of=/tmp/passwd_dd.$$
         log_must diff /tmp/passwd_dd.$$ /tmp/$XATTR_NAME.$$
         log_must rm /tmp/passwd_dd.$$ /tmp/$XATTR_NAME.$$