1166065Spjd#!/bin/sh 2166065Spjd# $FreeBSD: releng/10.3/tools/regression/pjdfstest/tests/rename/07.t 211186 2010-08-11 17:34:58Z pjd $ 3166065Spjd 4166065Spjddesc="rename returns EPERM if the parent directory of the file pointed at by the 'from' argument 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 flags1="SF_IMMUTABLE SF_APPEND" 14210984Spjd flags2="SF_NOUNLINK" 15211156Spjd echo "1..128" 16210984Spjd ;; 17210984SpjdFreeBSD:UFS) 18210984Spjd flags1="SF_IMMUTABLE SF_APPEND UF_IMMUTABLE UF_APPEND" 19210984Spjd flags2="SF_NOUNLINK UF_NOUNLINK" 20211156Spjd echo "1..212" 21210984Spjd ;; 22210984Spjd*) 23210984Spjd quick_exit 24210984Spjdesac 25166065Spjd 26166065Spjdn0=`namegen` 27166065Spjdn1=`namegen` 28166065Spjdn2=`namegen` 29166065Spjd 30166065Spjdexpect 0 mkdir ${n0} 0755 31166065Spjd 32211186Spjdfor type in regular dir fifo block char socket symlink; do 33211186Spjd create_file ${type} ${n0}/${n1} 34211186Spjd for flag in ${flags1}; do 35211186Spjd expect 0 chflags ${n0} ${flag} 36211186Spjd expect ${flag} stat ${n0} flags 37211186Spjd [ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM." 38211186Spjd expect EPERM rename ${n0}/${n1} ${n2} 39211186Spjd [ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM." 40211186Spjd expect ENOENT rename ${n2} ${n0}/${n1} 41211186Spjd done 42211186Spjd expect 0 chflags ${n0} none 43211186Spjd if [ "${type}" = "dir" ]; then 44211186Spjd expect 0 rmdir ${n0}/${n1} 45211186Spjd else 46211186Spjd expect 0 unlink ${n0}/${n1} 47211186Spjd fi 48166065Spjddone 49166065Spjd 50211186Spjdfor type in regular dir fifo block char socket symlink; do 51211186Spjd create_file ${type} ${n0}/${n1} 52211186Spjd for flag in ${flags2}; do 53211186Spjd expect 0 chflags ${n0} ${flag} 54211186Spjd expect ${flag} stat ${n0} flags 55211186Spjd expect 0 rename ${n0}/${n1} ${n2} 56211186Spjd expect 0 rename ${n2} ${n0}/${n1} 57211186Spjd done 58211186Spjd expect 0 chflags ${n0} none 59211186Spjd if [ "${type}" = "dir" ]; then 60211186Spjd expect 0 rmdir ${n0}/${n1} 61211186Spjd else 62211186Spjd expect 0 unlink ${n0}/${n1} 63211186Spjd fi 64166065Spjddone 65166065Spjd 66166065Spjdexpect 0 rmdir ${n0} 67