[Linux-disciples] Paranoid file locking

Stephen R Laniel steve at laniels.org
Fri Mar 25 20:20:02 EST 2005


On Fri, Mar 25, 2005 at 07:59:38PM -0500, Adam Rosi-Kessel wrote:
> I believe if you rename a file that is otherwise open, no harm is
> done--the open file handle isn't linked to a filename.

Could you clarify? Let's say this sequence happens:

1) Daemon opens a file A.
2) Daemon starts writing to A.
3) I rename A.
4) Daemon keeps writing to A.
5) Daemon closes A.

What happens to the data from steps 4) and 5)? It's sitting
in a buffer that never gets written to disk, one assumes,
and when the handle is closed the data disappears.

But let's say A is a *large* file. The kernel buffers up
some data to write, and presumably it doesn't wait for many
megabytes to get buffered before it writes to disk. So if A
is large, I assume steps 1) and 2) above will have written
some data to A before I renamed it, yes?

-- 
Stephen R. Laniel
steve at laniels.org
+(617) 308-5571
http://laniels.org/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.bostoncoop.net/pipermail/linux-disciples/attachments/20050325/ab8b0168/attachment.pgp


More information about the Linux-disciples mailing list