1271294Sngie#!/bin/sh 2271294Sngie# $FreeBSD: head/tools/regression/pjdfstest/tests/open/11.t 211352 2010-08-15 21:24:17Z pjd $ 3271294Sngie 4271294Sngiedesc="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" 5271294Sngie 6271294Sngiedir=`dirname $0` 7271294Sngie. ${dir}/../misc.sh 8271294Sngie 9271294Sngierequire chflags 10271294Sngie 11271294Sngiecase "${os}:${fs}" in 12271294SngieFreeBSD:ZFS) 13271294Sngie echo "1..12" 14271294Sngie ;; 15271294SngieFreeBSD:UFS) 16271294Sngie echo "1..24" 17271294Sngie ;; 18271294Sngie*) 19271294Sngie quick_exit 20271294Sngieesac 21271294Sngie 22271294Sngien0=`namegen` 23271294Sngie 24271294Sngieexpect 0 create ${n0} 0644 25271294Sngieexpect 0 chflags ${n0} SF_APPEND 26271294Sngieexpect 0 open ${n0} O_WRONLY,O_APPEND 27271294Sngieexpect 0 open ${n0} O_RDWR,O_APPEND 28271294Sngieexpect EPERM open ${n0} O_WRONLY 29271294Sngieexpect EPERM open ${n0} O_RDWR 30271294Sngietodo FreeBSD:ZFS "When fle is protected by SF_APPEND, open(O_TRUNC) should return EPERM." 31271294Sngieexpect EPERM open ${n0} O_RDONLY,O_TRUNC 32271294Sngietodo FreeBSD:ZFS "When fle is protected by SF_APPEND, open(O_TRUNC) should return EPERM." 33271294Sngieexpect EPERM open ${n0} O_RDONLY,O_APPEND,O_TRUNC 34271294Sngietodo FreeBSD:ZFS "When fle is protected by SF_APPEND, open(O_TRUNC) should return EPERM." 35271294Sngieexpect EPERM open ${n0} O_WRONLY,O_APPEND,O_TRUNC 36271294Sngietodo FreeBSD:ZFS "When fle is protected by SF_APPEND, open(O_TRUNC) should return EPERM." 37271294Sngieexpect EPERM open ${n0} O_RDWR,O_APPEND,O_TRUNC 38271294Sngieexpect 0 chflags ${n0} none 39271294Sngieexpect 0 unlink ${n0} 40271294Sngie 41271294Sngiecase "${os}:${fs}" in 42271294SngieFreeBSD:UFS) 43271294Sngie expect 0 create ${n0} 0644 44271294Sngie expect 0 chflags ${n0} UF_APPEND 45271294Sngie expect 0 open ${n0} O_WRONLY,O_APPEND 46271294Sngie expect 0 open ${n0} O_RDWR,O_APPEND 47271294Sngie expect EPERM open ${n0} O_WRONLY 48271294Sngie expect EPERM open ${n0} O_RDWR 49271294Sngie expect EPERM open ${n0} O_RDONLY,O_TRUNC 50271294Sngie expect EPERM open ${n0} O_RDONLY,O_APPEND,O_TRUNC 51271294Sngie expect EPERM open ${n0} O_WRONLY,O_APPEND,O_TRUNC 52271294Sngie expect EPERM open ${n0} O_RDWR,O_APPEND,O_TRUNC 53271294Sngie expect 0 chflags ${n0} none 54271294Sngie expect 0 unlink ${n0} 55271294Sngie ;; 56271294Sngieesac 57