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 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