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