1#!/bin/sh 2# $FreeBSD: head/tools/regression/pjdfstest/tests/rename/07.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 'from' argument has its immutable or append-only flag set" 5 6dir=`dirname $0` 7. ${dir}/../misc.sh 8 9require chflags 10 11case "${os}:${fs}" in 12FreeBSD:ZFS) 13 flags1="SF_IMMUTABLE SF_APPEND" 14 flags2="SF_NOUNLINK" 15 echo "1..128" 16 ;; 17FreeBSD:UFS) 18 flags1="SF_IMMUTABLE SF_APPEND UF_IMMUTABLE UF_APPEND" 19 flags2="SF_NOUNLINK UF_NOUNLINK" 20 echo "1..212" 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} ${n0}/${n1} 34 for flag in ${flags1}; do 35 expect 0 chflags ${n0} ${flag} 36 expect ${flag} stat ${n0} flags 37 [ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM." 38 expect EPERM rename ${n0}/${n1} ${n2} 39 [ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM." 40 expect ENOENT rename ${n2} ${n0}/${n1} 41 done 42 expect 0 chflags ${n0} none 43 if [ "${type}" = "dir" ]; then 44 expect 0 rmdir ${n0}/${n1} 45 else 46 expect 0 unlink ${n0}/${n1} 47 fi 48done 49 50for type in regular dir fifo block char socket symlink; do 51 create_file ${type} ${n0}/${n1} 52 for flag in ${flags2}; do 53 expect 0 chflags ${n0} ${flag} 54 expect ${flag} stat ${n0} flags 55 expect 0 rename ${n0}/${n1} ${n2} 56 expect 0 rename ${n2} ${n0}/${n1} 57 done 58 expect 0 chflags ${n0} none 59 if [ "${type}" = "dir" ]; then 60 expect 0 rmdir ${n0}/${n1} 61 else 62 expect 0 unlink ${n0}/${n1} 63 fi 64done 65 66expect 0 rmdir ${n0} 67