Bug #40633 [Opn->Nab]: disk_free_space returns a bad result on filesystems with negative free space
| From: | cmb@php.net | Date: | Mon, 10 May 2021 15:24:25 +0000 |
| Subject: | Bug #40633 [Opn->Nab]: disk_free_space returns a bad result on filesystems with negative free space | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-233767@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=40633&edit=1
ID: 40633
Updated by: cmb@php.net
Reported by: adam-phpbugs at adam dot gs
Summary: disk_free_space returns a bad result on filesystems
with negative free space
-Status: Open
+Status: Not a bug
Type: Bug
Package: Filesystem function related
Operating System: FreeBSD
PHP Version: 5.2.1
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
f_bfree and f_bavail are of type fsblkcnt_t, and according to
POSIX shall be defined as unsigned integer type[1], so this
doesn't look like a PHP bug.
[1] <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html>
Previous Comments:
------------------------------------------------------------------------
[2009-10-16 04:29:56] perryc at gmail dot com
Remarkably on a completely different machine, version of FreeBSD, available disk space, etc I get
the same return value from disk_free_space() (albeit with slightly better precision):
Oct 15 2009 21:21:51 disk_free_space(): 3.7778931862952E+22
The reporter's remarks about negative free space are correct.
------------------------------------------------------------------------
[2007-04-26 23:18:13] adam-phpbugs at adam dot gs
For some reason I didn't get any notification of stas's message.
this is FreeBSD 6.2-STABLE
<pre>
struct statvfs {
fsblkcnt_t f_bavail; /* Number of blocks */
fsblkcnt_t f_bfree;
fsblkcnt_t f_blocks;
fsfilcnt_t f_favail; /* Number of files (e.g., inodes) */
fsfilcnt_t f_ffree;
fsfilcnt_t f_files;
unsigned long f_bsize; /* Size of blocks counted above */
unsigned long f_flag;
unsigned long f_frsize; /* Size of fragments */
unsigned long f_fsid; /* Not meaningful */
unsigned long f_namemax; /* Same as pathconf(_PC_NAME_MAX) */
};</pre>
http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/sys/statvfs.h
for cvs/changelog (make sure your looking at 6.2-RELEASE) branch, there may be differences.
------------------------------------------------------------------------
[2007-04-10 20:58:25] stas@php.net
Funny thing is that PHP doesn't use any unsigned numbers on the way - it translates it directly
from system call int64 to double. I guess version of the system and header file defining struct
statvfs would be useful.
------------------------------------------------------------------------
[2007-02-26 15:44:08] tony2001@php.net
Please provide an SSH account on a machine where I can reproduce it.
------------------------------------------------------------------------
[2007-02-26 13:33:03] adam-phpbugs at adam dot gs
changing OS to FreeBSD
------------------------------------------------------------------------
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=40633
--
Edit this bug report at https://bugs.php.net/bug.php?id=40633&edit=1