1#!/bin/sh
| 1#!/bin/sh
|
2# $FreeBSD: head/tools/regression/fstest/tests/rename/06.t 211156 2010-08-10 22:57:43Z pjd $
| 2# $FreeBSD: head/tools/regression/fstest/tests/rename/06.t 211186 2010-08-11 17:34:58Z pjd $
|
3 4desc="rename returns EPERM if the file pointed at by the 'from' argument has its immutable, undeletable or append-only flag set" 5 6dir=`dirname $0` 7. ${dir}/../misc.sh 8 9require chflags 10 11case "${os}:${fs}" in 12FreeBSD:ZFS) 13 flags="SF_IMMUTABLE SF_NOUNLINK SF_APPEND"
| 3 4desc="rename returns EPERM if the file pointed at by the 'from' argument has its immutable, undeletable or append-only flag set" 5 6dir=`dirname $0` 7. ${dir}/../misc.sh 8 9require chflags 10 11case "${os}:${fs}" in 12FreeBSD:ZFS) 13 flags="SF_IMMUTABLE SF_NOUNLINK SF_APPEND"
|
14 echo "1..105"
| 14 echo "1..195"
|
15 ;; 16FreeBSD:UFS) 17 flags="SF_IMMUTABLE SF_NOUNLINK SF_APPEND UF_IMMUTABLE UF_NOUNLINK UF_APPEND"
| 15 ;; 16FreeBSD:UFS) 17 flags="SF_IMMUTABLE SF_NOUNLINK SF_APPEND UF_IMMUTABLE UF_NOUNLINK UF_APPEND"
|
18 echo "1..189"
| 18 echo "1..351"
|
19 ;; 20*) 21 quick_exit 22esac 23 24n0=`namegen` 25n1=`namegen` 26
| 19 ;; 20*) 21 quick_exit 22esac 23 24n0=`namegen` 25n1=`namegen` 26
|
27expect 0 create ${n0} 0644 28for flag in ${flags}; do 29 expect 0 chflags ${n0} ${flag} 30 expect ${flag} stat ${n0} flags 31 [ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM." 32 expect EPERM rename ${n0} ${n1} 33 [ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM." 34 expect ENOENT rename ${n1} ${n0} 35done 36expect 0 chflags ${n0} none 37expect 0 unlink ${n0}
| 27for type in regular dir fifo block char socket symlink; do 28 if [ "${type}" != "symlink" ]; then 29 create_file ${type} ${n0} 30 for flag in ${flags}; do 31 expect 0 chflags ${n0} ${flag} 32 expect ${flag} stat ${n0} flags 33 [ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM." 34 expect EPERM rename ${n0} ${n1} 35 [ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM." 36 expect ENOENT rename ${n1} ${n0} 37 done 38 expect 0 chflags ${n0} none 39 if [ "${type}" = "dir" ]; then 40 expect 0 rmdir ${n0} 41 else 42 expect 0 unlink ${n0} 43 fi 44 fi
|
38
| 45
|
39expect 0 mkdir ${n0} 0755 40for flag in ${flags}; do 41 expect 0 chflags ${n0} ${flag} 42 expect ${flag} stat ${n0} flags 43 [ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a directory protected by SF_APPEND should return EPERM." 44 expect EPERM rename ${n0} ${n1} 45 [ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a directory protected by SF_APPEND should return EPERM." 46 expect ENOENT rename ${n1} ${n0}
| 46 create_file ${type} ${n0} 47 for flag in ${flags}; do 48 expect 0 lchflags ${n0} ${flag} 49 expect ${flag} lstat ${n0} flags 50 [ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM." 51 expect EPERM rename ${n0} ${n1} 52 [ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a file protected by SF_APPEND should return EPERM." 53 expect ENOENT rename ${n1} ${n0} 54 done 55 expect 0 lchflags ${n0} none 56 if [ "${type}" = "dir" ]; then 57 expect 0 rmdir ${n0} 58 else 59 expect 0 unlink ${n0} 60 fi
|
47done
| 61done
|
48expect 0 chflags ${n0} none 49expect 0 rmdir ${n0} 50 51expect 0 mkfifo ${n0} 0644 52for flag in ${flags}; do 53 expect 0 chflags ${n0} ${flag} 54 expect ${flag} stat ${n0} flags 55 [ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a fifo protected by SF_APPEND should return EPERM." 56 expect EPERM rename ${n0} ${n1} 57 [ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a fifo protected by SF_APPEND should return EPERM." 58 expect ENOENT rename ${n1} ${n0} 59done 60expect 0 chflags ${n0} none 61expect 0 unlink ${n0} 62 63expect 0 mknod ${n0} b 0644 1 2 64for flag in ${flags}; do 65 expect 0 chflags ${n0} ${flag} 66 expect ${flag} stat ${n0} flags 67 [ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a device protected by SF_APPEND should return EPERM." 68 expect EPERM rename ${n0} ${n1} 69 [ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a device protected by SF_APPEND should return EPERM." 70 expect ENOENT rename ${n1} ${n0} 71done 72expect 0 chflags ${n0} none 73expect 0 unlink ${n0} 74 75expect 0 mknod ${n0} c 0644 1 2 76for flag in ${flags}; do 77 expect 0 chflags ${n0} ${flag} 78 expect ${flag} stat ${n0} flags 79 [ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a device protected by SF_APPEND should return EPERM." 80 expect EPERM rename ${n0} ${n1} 81 [ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a device protected by SF_APPEND should return EPERM." 82 expect ENOENT rename ${n1} ${n0} 83done 84expect 0 chflags ${n0} none 85expect 0 unlink ${n0} 86 87expect 0 bind ${n0} 88for flag in ${flags}; do 89 expect 0 chflags ${n0} ${flag} 90 expect ${flag} stat ${n0} flags 91 [ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a socket protected by SF_APPEND should return EPERM." 92 expect EPERM rename ${n0} ${n1} 93 [ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a socket protected by SF_APPEND should return EPERM." 94 expect ENOENT rename ${n1} ${n0} 95done 96expect 0 chflags ${n0} none 97expect 0 unlink ${n0} 98 99expect 0 symlink ${n1} ${n0} 100for flag in ${flags}; do 101 expect 0 lchflags ${n0} ${flag} 102 expect ${flag} lstat ${n0} flags 103 [ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a symlink protected by SF_APPEND should return EPERM." 104 expect EPERM rename ${n0} ${n1} 105 [ "${flag}" = "SF_APPEND" ] && todo FreeBSD:ZFS "Renaming a symlink protected by SF_APPEND should return EPERM." 106 expect ENOENT rename ${n1} ${n0} 107done 108expect 0 lchflags ${n0} none 109expect 0 unlink ${n0}
| |
| |