LinuxSA Mailing list archives
Index:
[thread]
[date]
[subject]
[author]
From: Daryl Tester <dt@picknowl.com.au>
To : Jake Hawkes <jake@infinitylimited.net>
Date: Fri, 28 Apr 2000 08:24:14 +0930
Re: Protecting files against power failure
Jake Hawkes wrote:
> could someone walk through this one?
> exec 5>foo 6<foo
setup file descriptor #5 as output to file foo, #6 as input from file foo.
> ls -l / >&5
ls -l of / (of course :-), and redirect the output to file descriptor #5.
> ls -l foo
foo's size at this point should be non-zero, and contain the contents
of the "ls -l /".
> rm foo
Delete the file. The file foo is no longer accessible[1].
> cat <&6
What's this?? Black Unix Magic! We can still retrieve the contents
of file foo (not really[1]), even though it's been deleted! Well
I never! (despite the rumours).
Regards,
Daryl "Caffeine Depleted" Tester
[1] The file is no longer accessible from the Unix file namespace,
but as David's demo so eloquently shows, if you still have an
open file descriptor to the file you can access its contents.
Once the number of links drops to zero (ie, the last descriptor
to the deleted file has been closed), the file space is reclaimed.
This is the magic of decoupling the name of the file from its inode,
and gives us other joyous oddities like hard links. One day, NTFS
may catch up, but don't hold your breath.
--
LinuxSA WWW: http://www.linuxsa.org.au/ IRC: #linuxsa on irc.linux.org.au
To unsubscribe from the LinuxSA list:
mail linuxsa-request@linuxsa.org.au with "unsubscribe" as the subject
Index:
[thread]
[date]
[subject]
[author]
Return to the LinuxSA Mailing List Information Page