1#!/bin/sh 2# $FreeBSD: head/tools/regression/pjdfstest/tests/open/11.t 211352 2010-08-15 21:24:17Z pjd $ 3 4desc="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" 5 6dir=`dirname $0` 7. ${dir}/../misc.sh 8 9require chflags 10 11case "${os}:${fs}" in 12FreeBSD:ZFS) 13 echo "1..12" 14 ;; 15FreeBSD:UFS) 16 echo "1..24" 17 ;; 18*) 19 quick_exit 20esac 21 22n0=`namegen` 23 24expect 0 create ${n0} 0644 25expect 0 chflags ${n0} SF_APPEND 26expect 0 open ${n0} O_WRONLY,O_APPEND 27expect 0 open ${n0} O_RDWR,O_APPEND 28expect EPERM open ${n0} O_WRONLY 29expect EPERM open ${n0} O_RDWR 30todo FreeBSD:ZFS "When fle is protected by SF_APPEND, open(O_TRUNC) should return EPERM." 31expect EPERM open ${n0} O_RDONLY,O_TRUNC 32todo FreeBSD:ZFS "When fle is protected by SF_APPEND, open(O_TRUNC) should return EPERM." 33expect EPERM open ${n0} O_RDONLY,O_APPEND,O_TRUNC 34todo FreeBSD:ZFS "When fle is protected by SF_APPEND, open(O_TRUNC) should return EPERM." 35expect EPERM open ${n0} O_WRONLY,O_APPEND,O_TRUNC 36todo FreeBSD:ZFS "When fle is protected by SF_APPEND, open(O_TRUNC) should return EPERM." 37expect EPERM open ${n0} O_RDWR,O_APPEND,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_APPEND 45 expect 0 open ${n0} O_WRONLY,O_APPEND 46 expect 0 open ${n0} O_RDWR,O_APPEND 47 expect EPERM open ${n0} O_WRONLY 48 expect EPERM open ${n0} O_RDWR 49 expect EPERM open ${n0} O_RDONLY,O_TRUNC 50 expect EPERM open ${n0} O_RDONLY,O_APPEND,O_TRUNC 51 expect EPERM open ${n0} O_WRONLY,O_APPEND,O_TRUNC 52 expect EPERM open ${n0} O_RDWR,O_APPEND,O_TRUNC 53 expect 0 chflags ${n0} none 54 expect 0 unlink ${n0} 55 ;; 56esac 57