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