This is the mail archive of the
cygwin
mailing list for the Cygwin project.
bug in rename(2)
- From: ericblake at comcast dot net (Eric Blake)
- To: cygwin at cygwin dot com
- Date: Thu, 14 Apr 2005 15:48:28 +0000
- Subject: bug in rename(2)
Coreutils testsuite found another bug, this time in rename(2), as tested on the 20050412 snapshot:
$ cd /cygdrive/c # local NTFS drive
$ mknod fifo p
$ ls -lF fifo
prw-rw-rw- 1 eblake Domain Users 102 Apr 14 09:27 fifo|
$ mv fifo /cygdrive/u # remote NFS drive
$ ls -lF /cygdrive/u/fifo
-r--r--r-- 1 eblake Domain Users 102 Apr 14 09:27 /cygdrive/u/fifo
Oops - the rename succeeded but changed the file type; if this can't be made to work cross device, it would be better if it failed with EXDEV; mv(1) will then live up to its requirements and gracefully handle the EXDEV by creating a fifo on the destination before unlinking it on the source.
$ mkfifo fifo
$ ls -liF fifo
673851094245318183 prw-rw-rw- 1 eblake Domain Users 102 Apr 14 09:41 fifo|
$ mv fifo fifo1
$ ls -liF fifo1
673851094245318183 -r--r--r-- 1 eblake Domain Users 102 Apr 14 09:41 fifo1
Oops - now we are on the same device, and mv(1) defers to rename(2) for semantics. Rename is not permitted to change file types, and on the same device, is not permitted to fail with EXDEV. At least it preserved the inode, as required.
--
Eric Blake
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/