Re: PHP 4.0 Bug #8027 Updated: diskfreespace always return 0 in FreeBSD
| From: | Jani Taskinen | Date: | Wed, 20 Dec 2000 01:31:38 +0000 |
| Subject: | Re: PHP 4.0 Bug #8027 Updated: diskfreespace always return 0 in FreeBSD | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-41880@lists.php.net to get a copy of this message | ||
On 12 Dec 2000 stas@php.net wrote:
>ID: 8027
>Updated by: stas
>Reported By: akss@programmer.net
>Old-Status: Open
>Status: Analyzed
>Bug Type: Filesystem function related
>Assigned To:
>Comments:
>
>The proposed patch won't help, since BSD has no statfs.h and
>statvfs.h and PHP for some reason checks for that. Actually,
>FreeBSD needs sys/param.h and sys/mount.h, as stated in man,
>but not stat[v]fs.h. Maybe somebody of configure wizards can
>look at it.
I'm not any configure wizard but this (untested) patch should do it:
Index: filestat.c
===================================================================
RCS file: /repository/php4/ext/standard/filestat.c,v
retrieving revision 1.51
diff -u -r1.51 filestat.c
--- filestat.c 2000/12/07 12:09:38 1.51
+++ filestat.c 2000/12/20 01:27:16
@@ -45,6 +45,11 @@
# include <sys/statfs.h>
#endif
+#if defined(__FreeBSD__)
+# include <sys/param.h>
+# include <sys/mount.h>
+#endif
+
#if HAVE_PWD_H
# ifdef PHP_WIN32
# include "win32/pwd.h"
@@ -151,7 +156,7 @@
#else /* not - WINDOWS */
#if defined(HAVE_SYS_STATVFS_H) && defined(HAVE_STATVFS)
struct statvfs buf;
-#elif defined(HAVE_SYS_STATFS_H) && defined(HAVE_STATFS)
+#elif (defined(HAVE_SYS_STATFS_H) && defined(HAVE_STATFS)) || defined(__FreeBSD__)
struct statfs buf;
#endif
double bytesfree = 0;
@@ -214,7 +219,7 @@
} else {
bytesfree = (((double)buf.f_bavail) *
((double)buf.f_bsize));
}
-#elif defined(HAVE_SYS_STATFS_H) && defined(HAVE_STATFS)
+#elif (defined(HAVE_SYS_STATFS_H) && defined(HAVE_STATFS)) || defined(__FreeBSD__)
if (statfs((*path)->value.str.val,&buf)) RETURN_FALSE;
bytesfree = (((double)buf.f_bsize) * ((double)buf.f_bavail));
#endif