1#!/usr/local/bin/ksh93 -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# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23# Use is subject to license terms.
24#
25# ident	"@(#)xattr_004_pos.ksh	1.1	07/02/06 SMI"
26#
27
28# $FreeBSD$
29
30. $STF_SUITE/include/libtest.kshlib
31. $STF_SUITE/tests/xattr/xattr_common.kshlib
32
33################################################################################
34#
35# __stc_assertion_start
36#
37# ID:  xattr_004_pos
38#
39# DESCRIPTION:
40#
41# Creating files on ufs and tmpfs, and copying those files to ZFS with
42# appropriate cp flags, the xattrs will still be readable.
43#
44# STRATEGY:
45#	1. Create files in ufs and tmpfs with xattrs
46#       2. Copy those files to zfs
47#	3. Ensure the xattrs can be read and written
48#	4. Do the same in reverse.
49#
50# TESTABILITY: explicit
51#
52# TEST_AUTOMATION_LEVEL: automated
53#
54# CODING_STATUS: COMPLETED (2006-12-05)
55#
56# __stc_assertion_end
57#
58################################################################################
59
60# we need to be able to create zvols to hold our test
61# ufs filesystem.
62verify_runnable "global"
63
64# Make sure we clean up properly
65function cleanup {
66
67	if [ $( ismounted $TMPDIR/ufs.${TESTCASE_ID} ufs ) ]
68	then
69		log_must $UMOUNT $TMPDIR/ufs.${TESTCASE_ID}
70		log_must $RM -rf $TMPDIR/ufs.${TESTCASE_ID}
71	fi
72}
73
74log_assert "Files from ufs,tmpfs with xattrs copied to zfs retain xattr info."
75log_onexit cleanup
76
77test_requires RUNAT
78
79# Create a UFS file system that we can work in
80log_must $ZFS create -V128m $TESTPOOL/$TESTFS/zvol
81log_must eval "$ECHO y | $NEWFS /dev/zvol/$TESTPOOL/$TESTFS/zvol > /dev/null 2>&1"
82
83log_must $MKDIR $TMPDIR/ufs.${TESTCASE_ID}
84log_must $MOUNT /dev/zvol/$TESTPOOL/$TESTFS/zvol $TMPDIR/ufs.${TESTCASE_ID}
85
86# Create files in ufs and tmpfs, and set some xattrs on them.
87log_must $TOUCH $TMPDIR/ufs.${TESTCASE_ID}/ufs-file.${TESTCASE_ID}
88log_must $TOUCH $TMPDIR/tmpfs-file.${TESTCASE_ID}
89
90log_must $RUNAT $TMPDIR/ufs.${TESTCASE_ID}/ufs-file.${TESTCASE_ID} $CP /etc/passwd .
91log_must $RUNAT $TMPDIR/tmpfs-file.${TESTCASE_ID} $CP /etc/group .
92
93# copy those files to ZFS
94log_must $CP -@ $TMPDIR/ufs.${TESTCASE_ID}/ufs-file.${TESTCASE_ID} $TESTDIR
95log_must $CP -@ $TMPDIR/tmpfs-file.${TESTCASE_ID} $TESTDIR
96
97# ensure the xattr information has been copied correctly
98log_must $RUNAT $TESTDIR/ufs-file.${TESTCASE_ID} $DIFF passwd /etc/passwd
99log_must $RUNAT $TESTDIR/tmpfs-file.${TESTCASE_ID} $DIFF group /etc/group
100
101log_must $UMOUNT $TMPDIR/ufs.${TESTCASE_ID}
102log_pass "Files from ufs,tmpfs with xattrs copied to zfs retain xattr info."
103