Bug #53061 [Opn]: filesystem functions deal poorly with out of disk space conditions

From: Date: Fri, 15 Oct 2010 00:47:12 +0000
Subject: Bug #53061 [Opn]: filesystem functions deal poorly with out of disk space conditions
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-155192@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=53061&edit=1

 ID:                 53061
 User updated by:    crrodriguez at opensuse dot org
 Reported by:        crrodriguez at opensuse dot org
 Summary:            filesystem functions deal poorly with out of disk
                     space conditions
 Status:             Open
 Type:               Bug
 Package:            Filesystem function related
 Operating System:   *nix
 PHP Version:        5.3SVN-2010-10-14 (SVN)
 Block user comment: N

 New Comment:

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



<?php

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

int(1003520)
bool(true)
bool(true)

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.


Previous Comments:
------------------------------------------------------------------------
[2010-10-14 07:00:13] cataphract@php.net

Why would fflush return false? Nothing was written by fwrite, so the
flush is a no-op.

------------------------------------------------------------------------
[2010-10-14 06:35:11] crrodriguez at opensuse dot org

Description:
------------
Filesystem functions have IMHO the wrong behaviuor on disk-full
conditions

Test script:
---------------
<?php

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

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

Actual result:
--------------
int(0)
bool(true)
bool(true)



------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=53061&edit=1


Thread (5 messages)

« previous php.bugs (#155192) next »