siliconmike wrote:
What would happen on Linux if:
$F=fopen("hello","wb");
lock $F
write to $F
rename "hello" as "mango"
close $F
Will mango contain upto date data ? Or will the rename cause it to
contain incomplete data ?
(I could have checked, but don't have Linux with me.)
Mike
A program in Linux uses the directory only to obtain the position of the
file on disk, that position is called an "inode".
So the file can be deleted or renamed even as it is being read/written. The
person doing the reading and writing is not affected by the fact that the
directory is entry is gone or renamed, they can continue to use the open
file handle.
However, once the last person with the file open closes it, then:
1) if it was deleted, nobody sees it anymore
2) if it was renamed, they have to use the new name
--
Kenneth Downs
Secure Data Software, Inc.
(Ken)nneth@(Sec)ure(Dat)a(.com)