xref: /freebsd/contrib/pjdfstest/tests/rmdir/09.t (revision b9f654b163bce26de79705e77b872427c9f2afa1)
1#!/bin/sh
2# vim: filetype=sh noexpandtab ts=8 sw=8
3# $FreeBSD: head/tools/regression/pjdfstest/tests/rmdir/09.t 211352 2010-08-15 21:24:17Z pjd $
4
5desc="rmdir returns EPERM if the named directory has its immutable, undeletable or append-only flag set"
6
7dir=`dirname $0`
8. ${dir}/../misc.sh
9
10require chflags
11
12case "${os}:${fs}" in
13FreeBSD:ZFS)
14	echo "1..15"
15	;;
16FreeBSD:UFS)
17	echo "1..30"
18	;;
19*)
20	quick_exit
21esac
22
23n0=`namegen`
24
25expect 0 mkdir ${n0} 0755
26expect 0 chflags ${n0} SF_IMMUTABLE
27expect EPERM rmdir ${n0}
28expect 0 chflags ${n0} none
29expect 0 rmdir ${n0}
30
31expect 0 mkdir ${n0} 0755
32expect 0 chflags ${n0} SF_NOUNLINK
33expect EPERM rmdir ${n0}
34expect 0 chflags ${n0} none
35expect 0 rmdir ${n0}
36
37expect 0 mkdir ${n0} 0755
38expect 0 chflags ${n0} SF_APPEND
39todo FreeBSD:ZFS "Removing a directory protected by SF_APPEND should return EPERM."
40expect EPERM rmdir ${n0}
41todo FreeBSD:ZFS "Removing a directory protected by SF_APPEND should return EPERM."
42expect 0 chflags ${n0} none
43todo FreeBSD:ZFS "Removing a directory protected by SF_APPEND should return EPERM."
44expect 0 rmdir ${n0}
45
46case "${os}:${fs}" in
47FreeBSD:UFS)
48	expect 0 mkdir ${n0} 0755
49	expect 0 chflags ${n0} UF_IMMUTABLE
50	expect EPERM rmdir ${n0}
51	expect 0 chflags ${n0} none
52	expect 0 rmdir ${n0}
53
54	expect 0 mkdir ${n0} 0755
55	expect 0 chflags ${n0} UF_NOUNLINK
56	expect EPERM rmdir ${n0}
57	expect 0 chflags ${n0} none
58	expect 0 rmdir ${n0}
59
60	expect 0 mkdir ${n0} 0755
61	expect 0 chflags ${n0} UF_APPEND
62	expect EPERM rmdir ${n0}
63	expect 0 chflags ${n0} none
64	expect 0 rmdir ${n0}
65	;;
66esac
67