|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53061 filesystem functions deal poorly with out of disk space conditions
Submitted: 2010-10-14 06:35 UTC Modified: 2010-11-20 00:07 UTC
From: crrodriguez at opensuse dot org Assigned:
Status: Wont fix Package: Filesystem function related
PHP Version: 5.3SVN-2010-10-14 (SVN) OS: *nix
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: crrodriguez at opensuse dot org
New email:
PHP Version: OS:


 [2010-10-14 06:35 UTC] crrodriguez at opensuse dot org
Filesystem functions have IMHO the wrong behaviuor on disk-full conditions

Test script:

$fp = fopen('/dev/full', 'wb');
var_dump(fwrite($fp, "fail"));

Expected result:
bool(false) and "warning ...No space left on device.. (aka, handle ENOSPC)

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-14 07:00 UTC]
Why would fflush return false? Nothing was written by fwrite, so the flush is a no-op.
 [2010-10-15 02:47 UTC] crrodriguez at opensuse dot org
A liltte bit better test case:

# dd if=/dev/zero of=/tmp/vfs bs=1024 count=1024
# losetup /dev/loop0 /tmp/vfs
# mkfs -t ext2 -m 1 -v /dev/loop0
# mkdir /mnt/vfs
# mount -t ext2 /dev/loop0 /mnt/vfs


$fp = fopen('/mnt/vfs/foo.txt', 'wb');
var_dump(fwrite($fp, str_repeat("fail", 1024000)));


ls -l /mnt/vfs/foo.txt 
-rw-r--r-- 1 root root 1003520 oct 14 21:43 /mnt/vfs/foo.txt

Partial data on disk, no warning or return values hinting the problem.
 [2010-10-16 02:18 UTC]
Well, there's the hint that the return value is smaller than strlen(str_repeat("fail", 1024000)) = 4096000.

I'm not sure if adding a warning here is appropriate, we try to avoid warnings in correct scripts so that programmers don't have to use "@" to have notice/warning free code. Even if we consider a disk full an exceptional circumstance that merited breaking this guideline, a warning would be of little use; unless the logs are in a separate filesystems, the warning message would not be able to be logged.

* We can't return false, because a part of the data may have been written and we need to return how much.
* A warning would be of no use in most circumstances.

Maybe we could return a false+warning if no data has been written, but it seems dangerous because sometimes programmers would be warned of an out-of-disk-space conditional and other times they wouldn't.
 [2010-11-20 00:07 UTC]
-Status: Open +Status: Wont fix
 [2010-11-20 00:07 UTC]
Closeing as Wont Fix per the exposed reasons.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jul 16 13:01:29 2024 UTC