Bug #63908 [Nab]: file_put_contents is not atomic.
Edit report at https://bugs.php.net/bug.php?id=63908&edit=1
ID: 63908
Updated by: rasmus@php.net
Reported by: awm086 at gmail dot com
Summary: file_put_contents is not atomic.
Status: Not a bug
Type: Bug
Package: Filesystem function related
Operating System: LINUX
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Well, if the disk is truly full, the tempnam() function wouldn't be able to
create the file. There is such thing as a "full directory"
Previous Comments:
------------------------------------------------------------------------
[2013-01-08 00:35:43] Awm086 at gmail dot com
Sorry I meant tempnam does creat a file even if the directory is full.
------------------------------------------------------------------------
[2013-01-08 00:22:20] rasmus@php.net
You mean tempnam and no, not at all. tempnam() creates an empty file, it doesn't
put anything in it. You can't check disk space, create a file and write to it,
all in one atomic operation.
------------------------------------------------------------------------
[2013-01-07 23:48:20] awm086 at gmail dot com
I noticed that function tempname does the same thing. Is that the case?
------------------------------------------------------------------------
[2013-01-06 00:33:34] rasmus@php.net
http://lxr.php.net/xref/PHP_5_4/ext/standard/file.c#564
------------------------------------------------------------------------
[2013-01-06 00:24:42] awm086 at gmail dot com
Where can I find the C implementation of the function. I am just curious now.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=63908
--
Edit this bug report at https://bugs.php.net/bug.php?id=63908&edit=1
Thread (10 messages)