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