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