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