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