1#!/bin/sh 2# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/08.t 211352 2010-08-15 21:24:17Z pjd $ 3 4desc="rename returns EPERM if the parent directory of the file pointed at by the 'to' argument has its immutable flag set" 5 6dir=`dirname $0` 7. ${dir}/../misc.sh 8 9require chflags 10 11case "${os}:${fs}" in 12FreeBSD:ZFS) 13 flags1="SF_IMMUTABLE" 14 flags2="SF_NOUNLINK SF_APPEND" 15 echo "1..128" 16 ;; 17FreeBSD:UFS) 18 flags1="SF_IMMUTABLE UF_IMMUTABLE" 19 flags2="SF_NOUNLINK SF_APPEND UF_NOUNLINK UF_APPEND" 20 echo "1..219" 21 ;; 22*) 23 quick_exit 24esac 25 26n0=`namegen` 27n1=`namegen` 28n2=`namegen` 29 30expect 0 mkdir ${n0} 0755 31 32for type in regular dir fifo block char socket symlink; do 33 create_file ${type} ${n1} 34 for flag in ${flags1}; do 35 expect 0 chflags ${n0} ${flag} 36 expect ${flag} stat ${n0} flags 37 expect EPERM rename ${n1} ${n0}/${n2} 38 done 39 expect 0 chflags ${n0} none 40 if [ "${type}" = "dir" ]; then 41 expect 0 rmdir ${n1} 42 else 43 expect 0 unlink ${n1} 44 fi 45done 46 47for type in regular dir fifo block char socket symlink; do 48 create_file ${type} ${n1} 49 for flag in ${flags2}; do 50 expect 0 chflags ${n0} ${flag} 51 expect ${flag} stat ${n0} flags 52 expect 0 rename ${n1} ${n0}/${n2} 53 expect 0 chflags ${n0} none 54 expect 0 rename ${n0}/${n2} ${n1} 55 done 56 if [ "${type}" = "dir" ]; then 57 expect 0 rmdir ${n1} 58 else 59 expect 0 unlink ${n1} 60 fi 61done 62 63expect 0 rmdir ${n0} 64