read() on a deleted file

Fasihullah Askiri fasihullah.askiri at gmail.com
Thu Jan 3 11:12:40 UTC 2008


Thanx for the response. That is why I tried shred-ding the file. I
believe that shred overwrites the file inode, if so, shred should have
led to failures of read() which is not the case. How does that happen?


On Jan 3, 2008 4:19 PM, Alex Bligh <alex at alex.org.uk> wrote:
>
>
> --On 3 January 2008 16:00:22 +0530 Fasihullah Askiri
> <fasihullah.askiri at gmail.com> wrote:
>
> > I have a doubt regarding the behaviour of read() on an ext3
> > filesystem. To elucidate my doubts, I wrote a small program opens a
> > file and reads one byte at a time and sleeps for a while. I deleted
> > the file while the read was still in progress and I noticed that the
> > read still succeeds. How does this work? Does the kernel not free the
> > inode when the file is deleted but there is a pending read? To check
> > this, instead of deleting, I tried shred-ding the file, the read still
> > gets the correct data.
>
> That's standard UNIX behaviour. The file exists on disk until all
> references to it have disappeared (references including the open
> file handle). All you do by typing "rm" is delete a reference/link to
> it from a particular directory, not (necessarily) delete the file.
> That's why the system call is called "unlink".
>
> Alex
>



-- 
Keep Running.... And Relish the run...
+Fasih




More information about the Ext3-users mailing list