xref: /freebsd/contrib/pjdfstest/tests/open/09.t (revision 97549c34ecaf74580941fdc9c5bd1050e4b1f6ce)
1#!/bin/sh
2# $FreeBSD: head/tools/regression/pjdfstest/tests/open/09.t 211352 2010-08-15 21:24:17Z pjd $
3
4desc="O_CREAT is specified, the file does not exist, and the directory in which it is 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:ZFS)
13	echo "1..17"
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 open ${n0}/${n1} O_RDONLY,O_CREAT 0644
28expect 0 unlink ${n0}/${n1}
29
30expect 0 chflags ${n0} SF_IMMUTABLE
31expect EPERM open ${n0}/${n1} O_RDONLY,O_CREAT 0644
32expect 0 chflags ${n0} none
33expect 0 open ${n0}/${n1} O_RDONLY,O_CREAT 0644
34expect 0 unlink ${n0}/${n1}
35
36expect 0 chflags ${n0} SF_NOUNLINK
37expect 0 open ${n0}/${n1} O_RDONLY,O_CREAT 0644
38expect 0 chflags ${n0} none
39expect 0 unlink ${n0}/${n1}
40
41expect 0 chflags ${n0} SF_APPEND
42expect 0 open ${n0}/${n1} O_RDONLY,O_CREAT 0644
43expect 0 chflags ${n0} none
44expect 0 unlink ${n0}/${n1}
45
46case "${os}:${fs}" in
47FreeBSD:UFS)
48	expect 0 chflags ${n0} UF_IMMUTABLE
49	expect EPERM open ${n0}/${n1} O_RDONLY,O_CREAT 0644
50	expect 0 chflags ${n0} none
51	expect 0 open ${n0}/${n1} O_RDONLY,O_CREAT 0644
52	expect 0 unlink ${n0}/${n1}
53
54	expect 0 chflags ${n0} UF_NOUNLINK
55	expect 0 symlink test ${n0}/${n1}
56	expect 0 chflags ${n0} none
57	expect 0 unlink ${n0}/${n1}
58
59	expect 0 chflags ${n0} UF_APPEND
60	expect 0 open ${n0}/${n1} O_RDONLY,O_CREAT 0644
61	expect 0 chflags ${n0} none
62	expect 0 unlink ${n0}/${n1}
63	;;
64esac
65
66expect 0 rmdir ${n0}
67