php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39520 disk_free_space uses f_frsize but it should use f_bsize
Submitted: 2006-11-15 05:26 UTC Modified: 2006-11-16 15:47 UTC
From: david at triax dot jp Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.2.0 OS: RedHat Enterprise ES 4
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: david at triax dot jp
New email:
PHP Version: OS:

 

 [2006-11-15 05:26 UTC] david at triax dot jp
Description:
------------
Using disk_free_space() on an NFS mount produced incorrect results so checking with strace, it seems PHP is ignoring the value of f_bsize and either using f_frsize or just using a fixed blocksize of 4096. I haven't checked the source code yet. Calling stat() on the same path shows the correct blocksize for the filesystem, in my case 32768, and so dividing the output of disk_free_space() by 4096 and multiplying by the result of stat()'s blksize element.


Expected result:
----------------
I expected the value of disk_free_space() to use the same block size as reproted by stat() on the same path.

Actual result:
--------------
disk_free_space() seems to use a fixed 4096 byte block size.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-15 09:53 UTC] tony2001@php.net
No, you are wrong. See lines 365-369 here: http://cvs.php.net/viewvc.cgi/php-src/ext/standard/filestat.c?view=annotate

 [2006-11-15 11:35 UTC] david at triax dot jp
As I wrote initially, it is either using f_frsize or just using a fixed blocksize and as you point out it's using f_frsize, and that is wrong. It should use f_bsize when calculating free space.
 [2006-11-16 03:41 UTC] david at triax dot jp
This is not a bogus bug. Please reread.
 [2006-11-16 03:42 UTC] david at triax dot jp
This is not a bogus bug. Please reread.
 [2006-11-16 03:46 UTC] david at triax dot jp
Changed the subject to reflect the actual bug. From the stat(2) man page, fr_size is "the 'preferred' block-size for efficient file system I/O." This means that it's *not* the blocksize of the actual device and is not useful for calculating the size of the device.
 [2006-11-16 15:47 UTC] iliaa@php.net
I've checked the current behavior against other applications 
and utilities that calculate free disk space and PHP's 
approach is perfectly inline with what other people are doing.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 21:01:34 2025 UTC