xref: /freebsd/tests/sys/cddl/zfs/tests/acl/cifs/cifs.kshlib (revision e0c4386e)
1# vim: filetype=sh
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
23#
24# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
25# Use is subject to license terms.
26
27. $STF_SUITE/include/libtest.kshlib
28
29function cifs_supported
30{
31     	if check_version "5.11" ; then
32		fs_prop_exist "sharesmb"
33		return $?
34	fi
35	return 1
36}
37
38#
39# Create a file or direcotry
40#
41# $1: The type specified, "file" or "dir"
42# $2: The given node name
43# $3: Owner of the node
44#
45function create_object
46{
47	typeset type=$1
48	typeset object=$2
49	typeset owner=$3
50
51	destroy_object $object
52
53	case $type in
54		dir)
55			$MKDIR -p $object
56			;;
57		file)
58			$ECHO "ZFS test suites" > $object
59			;;
60	esac
61
62	if [[ -n $owner ]]; then
63		$CHOWN $owner $object
64	fi
65	return 0
66}
67
68#
69# Destroy the given node(s)
70#
71# $@: The node(s) need to be destroyed
72#
73function destroy_object
74{
75	for object in $@ ; do
76		if [[ -e $object ]]; then
77
78			# clear_attribute is a common function name,
79			# but each case should have their own implement.
80			log_must clear_attribute $object
81			log_must $RM -rf $object
82		fi
83	done
84	return 0
85}
86
87