1166065Spjd#!/bin/sh 2166065Spjd# $FreeBSD$ 3166065Spjd 4166065Spjddesc="rename changes file name" 5166065Spjd 6166065Spjddir=`dirname $0` 7166065Spjd. ${dir}/../misc.sh 8166065Spjd 9211186Spjdecho "1..150" 10166065Spjd 11166065Spjdn0=`namegen` 12166065Spjdn1=`namegen` 13166065Spjdn2=`namegen` 14166065Spjdn3=`namegen` 15166065Spjd 16166065Spjdexpect 0 mkdir ${n3} 0755 17166065Spjdcdir=`pwd` 18166065Spjdcd ${n3} 19166065Spjd 20211186Spjdfor type in regular fifo block char socket; do 21211186Spjd create_file ${type} ${n0} 0644 22211186Spjd expect ${type},0644,1 lstat ${n0} type,mode,nlink 23211186Spjd inode=`${fstest} lstat ${n0} inode` 24211186Spjd expect 0 rename ${n0} ${n1} 25211186Spjd expect ENOENT lstat ${n0} type,mode,nlink 26211186Spjd expect ${type},${inode},0644,1 lstat ${n1} type,inode,mode,nlink 27211186Spjd expect 0 link ${n1} ${n0} 28211186Spjd expect ${type},${inode},0644,2 lstat ${n0} type,inode,mode,nlink 29211186Spjd expect ${type},${inode},0644,2 lstat ${n1} type,inode,mode,nlink 30211186Spjd expect 0 rename ${n1} ${n2} 31211186Spjd expect ${type},${inode},0644,2 lstat ${n0} type,inode,mode,nlink 32211186Spjd expect ENOENT lstat ${n1} type,mode,nlink 33211186Spjd expect ${type},${inode},0644,2 lstat ${n2} type,inode,mode,nlink 34211186Spjd expect 0 unlink ${n0} 35211186Spjd expect 0 unlink ${n2} 36211186Spjddone 37166065Spjd 38166065Spjdexpect 0 mkdir ${n0} 0755 39166065Spjdexpect dir,0755 lstat ${n0} type,mode 40166065Spjdinode=`${fstest} lstat ${n0} inode` 41166065Spjdexpect 0 rename ${n0} ${n1} 42166065Spjdexpect ENOENT lstat ${n0} type,mode 43166065Spjdexpect dir,${inode},0755 lstat ${n1} type,inode,mode 44166065Spjdexpect 0 rmdir ${n1} 45166065Spjd 46166065Spjdexpect 0 create ${n0} 0644 47166065Spjdrinode=`${fstest} lstat ${n0} inode` 48166065Spjdexpect regular,0644 lstat ${n0} type,mode 49166065Spjdexpect 0 symlink ${n0} ${n1} 50166065Spjdsinode=`${fstest} lstat ${n1} inode` 51166065Spjdexpect regular,${rinode},0644 stat ${n1} type,inode,mode 52166065Spjdexpect symlink,${sinode} lstat ${n1} type,inode 53166065Spjdexpect 0 rename ${n1} ${n2} 54166065Spjdexpect regular,${rinode},0644 stat ${n0} type,inode,mode 55166065Spjdexpect ENOENT lstat ${n1} type,mode 56166065Spjdexpect symlink,${sinode} lstat ${n2} type,inode 57166065Spjdexpect 0 unlink ${n0} 58166065Spjdexpect 0 unlink ${n2} 59166065Spjd 60166065Spjd# successful rename(2) updates ctime. 61211186Spjdfor type in regular dir fifo block char socket symlink; do 62211186Spjd create_file ${type} ${n0} 63211186Spjd ctime1=`${fstest} lstat ${n0} ctime` 64211186Spjd sleep 1 65211186Spjd expect 0 rename ${n0} ${n1} 66211186Spjd ctime2=`${fstest} lstat ${n1} ctime` 67211186Spjd test_check $ctime1 -lt $ctime2 68211186Spjd if [ "${type}" = "dir" ]; then 69211186Spjd expect 0 rmdir ${n1} 70211186Spjd else 71211186Spjd expect 0 unlink ${n1} 72211186Spjd fi 73211186Spjddone 74166065Spjd 75166065Spjd# unsuccessful link(2) does not update ctime. 76211186Spjdfor type in regular dir fifo block char socket symlink; do 77211186Spjd create_file ${type} ${n0} 78211186Spjd ctime1=`${fstest} lstat ${n0} ctime` 79211186Spjd sleep 1 80211186Spjd expect EACCES -u 65534 rename ${n0} ${n1} 81211186Spjd ctime2=`${fstest} lstat ${n0} ctime` 82211186Spjd test_check $ctime1 -eq $ctime2 83211186Spjd if [ "${type}" = "dir" ]; then 84211186Spjd expect 0 rmdir ${n0} 85211186Spjd else 86211186Spjd expect 0 unlink ${n0} 87211186Spjd fi 88211186Spjddone 89166065Spjd 90166065Spjdcd ${cdir} 91166065Spjdexpect 0 rmdir ${n3} 92