1166065Spjd#!/bin/sh 2166065Spjd# $FreeBSD: releng/10.2/tools/regression/pjdfstest/tests/truncate/08.t 210984 2010-08-06 23:58:54Z pjd $ 3166065Spjd 4166065Spjddesc="truncate returns EPERM if the named file has its immutable or append-only flag set" 5166065Spjd 6166065Spjddir=`dirname $0` 7166065Spjd. ${dir}/../misc.sh 8166065Spjd 9166065Spjdrequire chflags 10166065Spjd 11210984Spjdcase "${os}:${fs}" in 12210984SpjdFreeBSD:ZFS) 13210984Spjd echo "1..22" 14210984Spjd ;; 15210984SpjdFreeBSD:UFS) 16210984Spjd echo "1..44" 17210984Spjd ;; 18210984Spjd*) 19210984Spjd quick_exit 20210984Spjdesac 21166065Spjd 22166065Spjdn0=`namegen` 23166065Spjd 24166065Spjdexpect 0 create ${n0} 0644 25166065Spjdexpect 0 chflags ${n0} SF_IMMUTABLE 26166065Spjdexpect EPERM truncate ${n0} 123 27166065Spjdexpect 0 stat ${n0} size 28166065Spjdexpect 0 chflags ${n0} none 29166065Spjdexpect 0 truncate ${n0} 123 30210984Spjdexpect 123 stat ${n0} size 31166065Spjdexpect 0 unlink ${n0} 32166065Spjd 33166065Spjdexpect 0 create ${n0} 0644 34210984Spjdexpect 0 chflags ${n0} SF_NOUNLINK 35210984Spjdexpect 0 truncate ${n0} 123 36210984Spjdexpect 123 stat ${n0} size 37166065Spjdexpect 0 chflags ${n0} none 38166065Spjdexpect 0 unlink ${n0} 39166065Spjd 40166065Spjdexpect 0 create ${n0} 0644 41166065Spjdexpect 0 chflags ${n0} SF_APPEND 42210984Spjdtodo FreeBSD:ZFS "Truncating a file protected by SF_APPEND should return EPERM." 43166065Spjdexpect EPERM truncate ${n0} 123 44210984Spjdtodo FreeBSD:ZFS "Truncating a file protected by SF_APPEND should return EPERM." 45166065Spjdexpect 0 stat ${n0} size 46166065Spjdexpect 0 chflags ${n0} none 47166065Spjdexpect 0 truncate ${n0} 123 48210984Spjdexpect 123 stat ${n0} size 49166065Spjdexpect 0 unlink ${n0} 50166065Spjd 51210984Spjdcase "${os}:${fs}" in 52210984SpjdFreeBSD:UFS) 53210984Spjd expect 0 create ${n0} 0644 54210984Spjd expect 0 chflags ${n0} UF_IMMUTABLE 55210984Spjd expect EPERM truncate ${n0} 123 56210984Spjd expect 0 stat ${n0} size 57210984Spjd expect 0 chflags ${n0} none 58210984Spjd expect 0 truncate ${n0} 123 59210984Spjd expect 123 stat ${n0} size 60210984Spjd expect 0 unlink ${n0} 61166065Spjd 62210984Spjd expect 0 create ${n0} 0644 63210984Spjd expect 0 chflags ${n0} UF_NOUNLINK 64210984Spjd expect 0 truncate ${n0} 123 65210984Spjd expect 123 stat ${n0} size 66210984Spjd expect 0 chflags ${n0} none 67210984Spjd expect 0 unlink ${n0} 68166065Spjd 69210984Spjd expect 0 create ${n0} 0644 70210984Spjd expect 0 chflags ${n0} UF_APPEND 71210984Spjd expect EPERM truncate ${n0} 123 72210984Spjd expect 0 stat ${n0} size 73210984Spjd expect 0 chflags ${n0} none 74210984Spjd expect 0 truncate ${n0} 123 75210984Spjd expect 123 stat ${n0} size 76210984Spjd expect 0 unlink ${n0} 77210984Spjd ;; 78210984Spjdesac 79