xref: /freebsd/contrib/pjdfstest/tests/open/10.t (revision 59c8e88e72633afbc47a4ace0d2170d00d51f7dc)
1#!/bin/sh
2# vim: filetype=sh noexpandtab ts=8 sw=8
3# $FreeBSD: head/tools/regression/pjdfstest/tests/open/10.t 211352 2010-08-15 21:24:17Z pjd $
4
5desc="open returns EPERM when the named file has its immutable flag set and the file is to be modified"
6
7dir=`dirname $0`
8. ${dir}/../misc.sh
9
10require chflags
11
12case "${os}:${fs}" in
13FreeBSD:ZFS)
14	echo "1..14"
15	;;
16FreeBSD:UFS)
17	echo "1..28"
18	;;
19*)
20	quick_exit
21esac
22
23n0=`namegen`
24
25expect 0 create ${n0} 0644
26expect 0 chflags ${n0} SF_IMMUTABLE
27expect EPERM open ${n0} O_WRONLY
28expect EPERM open ${n0} O_RDWR
29expect EPERM open ${n0} O_RDONLY,O_TRUNC
30expect 0 chflags ${n0} none
31expect 0 unlink ${n0}
32
33expect 0 create ${n0} 0644
34expect 0 chflags ${n0} SF_NOUNLINK
35expect 0 open ${n0} O_WRONLY
36expect 0 open ${n0} O_RDWR
37expect 0 open ${n0} O_RDONLY,O_TRUNC
38expect 0 chflags ${n0} none
39expect 0 unlink ${n0}
40
41case "${os}:${fs}" in
42FreeBSD:UFS)
43	expect 0 create ${n0} 0644
44	expect 0 chflags ${n0} UF_IMMUTABLE
45	expect EPERM open ${n0} O_WRONLY
46	expect EPERM open ${n0} O_RDWR
47	expect EPERM open ${n0} O_RDONLY,O_TRUNC
48	expect 0 chflags ${n0} none
49	expect 0 unlink ${n0}
50
51	expect 0 create ${n0} 0644
52	expect 0 chflags ${n0} UF_NOUNLINK
53	expect 0 open ${n0} O_WRONLY
54	expect 0 open ${n0} O_RDWR
55	expect 0 open ${n0} O_RDONLY,O_TRUNC
56	expect 0 chflags ${n0} none
57	expect 0 unlink ${n0}
58	;;
59esac
60