1#!/bin/sh
| 1#!/bin/sh
|
2# $FreeBSD: head/tools/regression/fstest/tests/rename/00.t 211156 2010-08-10 22:57:43Z pjd $
| 2# $FreeBSD: head/tools/regression/fstest/tests/rename/00.t 211186 2010-08-11 17:34:58Z pjd $
|
3 4desc="rename changes file name" 5 6dir=`dirname $0` 7. ${dir}/../misc.sh 8
| 3 4desc="rename changes file name" 5 6dir=`dirname $0` 7. ${dir}/../misc.sh 8
|
9echo "1..145"
| 9echo "1..150"
|
10 11n0=`namegen` 12n1=`namegen` 13n2=`namegen` 14n3=`namegen` 15 16expect 0 mkdir ${n3} 0755 17cdir=`pwd` 18cd ${n3} 19
| 10 11n0=`namegen` 12n1=`namegen` 13n2=`namegen` 14n3=`namegen` 15 16expect 0 mkdir ${n3} 0755 17cdir=`pwd` 18cd ${n3} 19
|
20expect 0 create ${n0} 0644 21expect regular,0644,1 lstat ${n0} type,mode,nlink 22inode=`${fstest} lstat ${n0} inode` 23expect 0 rename ${n0} ${n1} 24expect ENOENT lstat ${n0} type,mode,nlink 25expect regular,${inode},0644,1 lstat ${n1} type,inode,mode,nlink 26expect 0 link ${n1} ${n0} 27expect regular,${inode},0644,2 lstat ${n0} type,inode,mode,nlink 28expect regular,${inode},0644,2 lstat ${n1} type,inode,mode,nlink 29expect 0 rename ${n1} ${n2} 30expect regular,${inode},0644,2 lstat ${n0} type,inode,mode,nlink 31expect ENOENT lstat ${n1} type,mode,nlink 32expect regular,${inode},0644,2 lstat ${n2} type,inode,mode,nlink 33expect 0 unlink ${n0} 34expect 0 unlink ${n2}
| 20for type in regular fifo block char socket; do 21 create_file ${type} ${n0} 0644 22 expect ${type},0644,1 lstat ${n0} type,mode,nlink 23 inode=`${fstest} lstat ${n0} inode` 24 expect 0 rename ${n0} ${n1} 25 expect ENOENT lstat ${n0} type,mode,nlink 26 expect ${type},${inode},0644,1 lstat ${n1} type,inode,mode,nlink 27 expect 0 link ${n1} ${n0} 28 expect ${type},${inode},0644,2 lstat ${n0} type,inode,mode,nlink 29 expect ${type},${inode},0644,2 lstat ${n1} type,inode,mode,nlink 30 expect 0 rename ${n1} ${n2} 31 expect ${type},${inode},0644,2 lstat ${n0} type,inode,mode,nlink 32 expect ENOENT lstat ${n1} type,mode,nlink 33 expect ${type},${inode},0644,2 lstat ${n2} type,inode,mode,nlink 34 expect 0 unlink ${n0} 35 expect 0 unlink ${n2} 36done
|
35 36expect 0 mkdir ${n0} 0755 37expect dir,0755 lstat ${n0} type,mode 38inode=`${fstest} lstat ${n0} inode` 39expect 0 rename ${n0} ${n1} 40expect ENOENT lstat ${n0} type,mode 41expect dir,${inode},0755 lstat ${n1} type,inode,mode 42expect 0 rmdir ${n1} 43
| 37 38expect 0 mkdir ${n0} 0755 39expect dir,0755 lstat ${n0} type,mode 40inode=`${fstest} lstat ${n0} inode` 41expect 0 rename ${n0} ${n1} 42expect ENOENT lstat ${n0} type,mode 43expect dir,${inode},0755 lstat ${n1} type,inode,mode 44expect 0 rmdir ${n1} 45
|
44expect 0 mkfifo ${n0} 0644 45expect fifo,0644,1 lstat ${n0} type,mode,nlink 46inode=`${fstest} lstat ${n0} inode` 47expect 0 rename ${n0} ${n1} 48expect ENOENT lstat ${n0} type,mode,nlink 49expect fifo,${inode},0644,1 lstat ${n1} type,inode,mode,nlink 50expect 0 link ${n1} ${n0} 51expect fifo,${inode},0644,2 lstat ${n0} type,inode,mode,nlink 52expect fifo,${inode},0644,2 lstat ${n1} type,inode,mode,nlink 53expect 0 rename ${n1} ${n2} 54expect fifo,${inode},0644,2 lstat ${n0} type,inode,mode,nlink 55expect ENOENT lstat ${n1} type,mode,nlink 56expect fifo,${inode},0644,2 lstat ${n2} type,inode,mode,nlink 57expect 0 unlink ${n0} 58expect 0 unlink ${n2} 59 60expect 0 mknod ${n0} b 0644 1 2 61expect block,0644,1 lstat ${n0} type,mode,nlink 62inode=`${fstest} lstat ${n0} inode` 63expect 0 rename ${n0} ${n1} 64expect ENOENT lstat ${n0} type,mode,nlink 65expect block,${inode},0644,1 lstat ${n1} type,inode,mode,nlink 66expect 0 link ${n1} ${n0} 67expect block,${inode},0644,2 lstat ${n0} type,inode,mode,nlink 68expect block,${inode},0644,2 lstat ${n1} type,inode,mode,nlink 69expect 0 rename ${n1} ${n2} 70expect block,${inode},0644,2 lstat ${n0} type,inode,mode,nlink 71expect ENOENT lstat ${n1} type,mode,nlink 72expect block,${inode},0644,2 lstat ${n2} type,inode,mode,nlink 73expect 0 unlink ${n0} 74expect 0 unlink ${n2} 75 76expect 0 mknod ${n0} c 0644 1 2 77expect char,0644,1 lstat ${n0} type,mode,nlink 78inode=`${fstest} lstat ${n0} inode` 79expect 0 rename ${n0} ${n1} 80expect ENOENT lstat ${n0} type,mode,nlink 81expect char,${inode},0644,1 lstat ${n1} type,inode,mode,nlink 82expect 0 link ${n1} ${n0} 83expect char,${inode},0644,2 lstat ${n0} type,inode,mode,nlink 84expect char,${inode},0644,2 lstat ${n1} type,inode,mode,nlink 85expect 0 rename ${n1} ${n2} 86expect char,${inode},0644,2 lstat ${n0} type,inode,mode,nlink 87expect ENOENT lstat ${n1} type,mode,nlink 88expect char,${inode},0644,2 lstat ${n2} type,inode,mode,nlink 89expect 0 unlink ${n0} 90expect 0 unlink ${n2} 91 92expect 0 -U 0133 bind ${n0} 93expect socket,0644,1 lstat ${n0} type,mode,nlink 94inode=`${fstest} lstat ${n0} inode` 95expect 0 rename ${n0} ${n1} 96expect ENOENT lstat ${n0} type,mode,nlink 97expect socket,${inode},0644,1 lstat ${n1} type,inode,mode,nlink 98expect 0 link ${n1} ${n0} 99expect socket,${inode},0644,2 lstat ${n0} type,inode,mode,nlink 100expect socket,${inode},0644,2 lstat ${n1} type,inode,mode,nlink 101expect 0 rename ${n1} ${n2} 102expect socket,${inode},0644,2 lstat ${n0} type,inode,mode,nlink 103expect ENOENT lstat ${n1} type,mode,nlink 104expect socket,${inode},0644,2 lstat ${n2} type,inode,mode,nlink 105expect 0 unlink ${n0} 106expect 0 unlink ${n2} 107
| |
108expect 0 create ${n0} 0644 109rinode=`${fstest} lstat ${n0} inode` 110expect regular,0644 lstat ${n0} type,mode 111expect 0 symlink ${n0} ${n1} 112sinode=`${fstest} lstat ${n1} inode` 113expect regular,${rinode},0644 stat ${n1} type,inode,mode 114expect symlink,${sinode} lstat ${n1} type,inode 115expect 0 rename ${n1} ${n2} 116expect regular,${rinode},0644 stat ${n0} type,inode,mode 117expect ENOENT lstat ${n1} type,mode 118expect symlink,${sinode} lstat ${n2} type,inode 119expect 0 unlink ${n0} 120expect 0 unlink ${n2} 121 122# successful rename(2) updates ctime.
| 46expect 0 create ${n0} 0644 47rinode=`${fstest} lstat ${n0} inode` 48expect regular,0644 lstat ${n0} type,mode 49expect 0 symlink ${n0} ${n1} 50sinode=`${fstest} lstat ${n1} inode` 51expect regular,${rinode},0644 stat ${n1} type,inode,mode 52expect symlink,${sinode} lstat ${n1} type,inode 53expect 0 rename ${n1} ${n2} 54expect regular,${rinode},0644 stat ${n0} type,inode,mode 55expect ENOENT lstat ${n1} type,mode 56expect symlink,${sinode} lstat ${n2} type,inode 57expect 0 unlink ${n0} 58expect 0 unlink ${n2} 59 60# successful rename(2) updates ctime.
|
123expect 0 create ${n0} 0644 124ctime1=`${fstest} stat ${n0} ctime` 125sleep 1 126expect 0 rename ${n0} ${n1} 127ctime2=`${fstest} stat ${n1} ctime` 128test_check $ctime1 -lt $ctime2 129expect 0 unlink ${n1}
| 61for type in regular dir fifo block char socket symlink; do 62 create_file ${type} ${n0} 63 ctime1=`${fstest} lstat ${n0} ctime` 64 sleep 1 65 expect 0 rename ${n0} ${n1} 66 ctime2=`${fstest} lstat ${n1} ctime` 67 test_check $ctime1 -lt $ctime2 68 if [ "${type}" = "dir" ]; then 69 expect 0 rmdir ${n1} 70 else 71 expect 0 unlink ${n1} 72 fi 73done
|
130
| 74
|
131expect 0 mkdir ${n0} 0755 132ctime1=`${fstest} stat ${n0} ctime` 133sleep 1 134expect 0 rename ${n0} ${n1} 135ctime2=`${fstest} stat ${n1} ctime` 136test_check $ctime1 -lt $ctime2 137expect 0 rmdir ${n1} 138 139expect 0 mkfifo ${n0} 0644 140ctime1=`${fstest} stat ${n0} ctime` 141sleep 1 142expect 0 rename ${n0} ${n1} 143ctime2=`${fstest} stat ${n1} ctime` 144test_check $ctime1 -lt $ctime2 145expect 0 unlink ${n1} 146 147expect 0 mknod ${n0} b 0644 1 2 148ctime1=`${fstest} stat ${n0} ctime` 149sleep 1 150expect 0 rename ${n0} ${n1} 151ctime2=`${fstest} stat ${n1} ctime` 152test_check $ctime1 -lt $ctime2 153expect 0 unlink ${n1} 154 155expect 0 mknod ${n0} c 0644 1 2 156ctime1=`${fstest} stat ${n0} ctime` 157sleep 1 158expect 0 rename ${n0} ${n1} 159ctime2=`${fstest} stat ${n1} ctime` 160test_check $ctime1 -lt $ctime2 161expect 0 unlink ${n1} 162 163expect 0 bind ${n0} 164ctime1=`${fstest} stat ${n0} ctime` 165sleep 1 166expect 0 rename ${n0} ${n1} 167ctime2=`${fstest} stat ${n1} ctime` 168test_check $ctime1 -lt $ctime2 169expect 0 unlink ${n1} 170 171expect 0 symlink ${n2} ${n0} 172ctime1=`${fstest} lstat ${n0} ctime` 173sleep 1 174expect 0 rename ${n0} ${n1} 175ctime2=`${fstest} lstat ${n1} ctime` 176test_check $ctime1 -lt $ctime2 177expect 0 unlink ${n1} 178
| |
179# unsuccessful link(2) does not update ctime.
| 75# unsuccessful link(2) does not update ctime.
|
180expect 0 create ${n0} 0644 181ctime1=`${fstest} stat ${n0} ctime` 182sleep 1 183expect EACCES -u 65534 rename ${n0} ${n1} 184ctime2=`${fstest} stat ${n0} ctime` 185test_check $ctime1 -eq $ctime2 186expect 0 unlink ${n0}
| 76for type in regular dir fifo block char socket symlink; do 77 create_file ${type} ${n0} 78 ctime1=`${fstest} lstat ${n0} ctime` 79 sleep 1 80 expect EACCES -u 65534 rename ${n0} ${n1} 81 ctime2=`${fstest} lstat ${n0} ctime` 82 test_check $ctime1 -eq $ctime2 83 if [ "${type}" = "dir" ]; then 84 expect 0 rmdir ${n0} 85 else 86 expect 0 unlink ${n0} 87 fi 88done
|
187
| 89
|
188expect 0 mkdir ${n0} 0755 189ctime1=`${fstest} stat ${n0} ctime` 190sleep 1 191expect EACCES -u 65534 rename ${n0} ${n1} 192ctime2=`${fstest} stat ${n0} ctime` 193test_check $ctime1 -eq $ctime2 194expect 0 rmdir ${n0} 195 196expect 0 mkfifo ${n0} 0644 197ctime1=`${fstest} stat ${n0} ctime` 198sleep 1 199expect EACCES -u 65534 rename ${n0} ${n1} 200ctime2=`${fstest} stat ${n0} ctime` 201test_check $ctime1 -eq $ctime2 202expect 0 unlink ${n0} 203 204expect 0 mknod ${n0} b 0644 1 2 205ctime1=`${fstest} stat ${n0} ctime` 206sleep 1 207expect EACCES -u 65534 rename ${n0} ${n1} 208ctime2=`${fstest} stat ${n0} ctime` 209test_check $ctime1 -eq $ctime2 210expect 0 unlink ${n0} 211 212expect 0 mknod ${n0} c 0644 1 2 213ctime1=`${fstest} stat ${n0} ctime` 214sleep 1 215expect EACCES -u 65534 rename ${n0} ${n1} 216ctime2=`${fstest} stat ${n0} ctime` 217test_check $ctime1 -eq $ctime2 218expect 0 unlink ${n0} 219 220expect 0 bind ${n0} 221ctime1=`${fstest} stat ${n0} ctime` 222sleep 1 223expect EACCES -u 65534 rename ${n0} ${n1} 224ctime2=`${fstest} stat ${n0} ctime` 225test_check $ctime1 -eq $ctime2 226expect 0 unlink ${n0} 227 228expect 0 symlink ${n2} ${n0} 229ctime1=`${fstest} lstat ${n0} ctime` 230sleep 1 231expect EACCES -u 65534 rename ${n0} ${n1} 232ctime2=`${fstest} lstat ${n0} ctime` 233test_check $ctime1 -eq $ctime2 234expect 0 unlink ${n0} 235
| |
236cd ${cdir} 237expect 0 rmdir ${n3}
| 90cd ${cdir} 91expect 0 rmdir ${n3}
|