xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/xattr/xattr_004_pos.ksh (revision 5f82aa32fbc5dc2c59bca6ff315f44a4c4c9ea86)
1#!/bin/ksh -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
26#
27# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
28#
29
30. $STF_SUITE/include/libtest.shlib
31. $STF_SUITE/tests/functional/xattr/xattr_common.kshlib
32
33#
34# DESCRIPTION:
35#
36# Creating files on ufs and tmpfs, and copying those files to ZFS with
37# appropriate cp flags, the xattrs will still be readable.
38#
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.
44#
45
46# we need to be able to create zvols to hold our test
47# ufs filesystem.
48verify_runnable "global"
49
50# Make sure we clean up properly
51function cleanup {
52
53	if [ $( ismounted /tmp/ufs.$$ ufs ) ]
54	then
55		log_must umount /tmp/ufs.$$
56		log_must rm -rf /tmp/ufs.$$
57	fi
58}
59
60log_assert "Files from ufs,tmpfs with xattrs copied to zfs retain xattr info."
61log_onexit cleanup
62
63# Create a UFS file system that we can work in
64log_must zfs create -V128m $TESTPOOL/$TESTFS/zvol
65log_must eval "echo y | newfs /dev/zvol/dsk/$TESTPOOL/$TESTFS/zvol > /dev/null 2>&1"
66
67log_must mkdir /tmp/ufs.$$
68log_must mount /dev/zvol/dsk/$TESTPOOL/$TESTFS/zvol /tmp/ufs.$$
69
70# Create files in ufs and tmpfs, and set some xattrs on them.
71log_must touch /tmp/ufs.$$/ufs-file.$$
72log_must touch /tmp/tmpfs-file.$$
73
74log_must runat /tmp/ufs.$$/ufs-file.$$ cp /etc/passwd .
75log_must runat /tmp/tmpfs-file.$$ cp /etc/group .
76
77# copy those files to ZFS
78log_must cp -@ /tmp/ufs.$$/ufs-file.$$ $TESTDIR
79log_must cp -@ /tmp/tmpfs-file.$$ $TESTDIR
80
81# ensure the xattr information has been copied correctly
82log_must runat $TESTDIR/ufs-file.$$ diff passwd /etc/passwd
83log_must runat $TESTDIR/tmpfs-file.$$ diff group /etc/group
84
85log_must umount /tmp/ufs.$$
86log_pass "Files from ufs,tmpfs with xattrs copied to zfs retain xattr info."
87