changeset 871:b15ad609365e

Solaris recommends using statvfs() instead of statfs()
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 04 Apr 2011 05:49:45 +0000
parents 59c4fac42fb5
children 13debcad9757
files compat.c
diffstat 1 files changed, 8 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/compat.c	Mon Apr 04 04:37:05 2011 +0000
+++ b/compat.c	Mon Apr 04 05:49:45 2011 +0000
@@ -15,7 +15,7 @@
 #include <sys/mnttab.h>
 #include <sys/param.h>
 #include <sys/mount.h>
-#include <sys/statfs.h>
+#include <sys/statvfs.h>
 #else
 #include <mntent.h>
 #include <sys/vfs.h>
@@ -117,7 +117,7 @@
 #elif defined(__sun__)
 	FILE *fp = fopen("/etc/mnttab", "r");
 	struct mnttab mnt;
-	struct statfs sfs;
+	struct statvfs sfs;
 	int index = 1;
 
 	if(fp)
@@ -130,9 +130,9 @@
 
 				if(mnt.mnt_mountp)
 				{
-					if(!statfs(mnt.mnt_mountp, &sfs, sizeof(struct statfs), 0))
+					if(!statvfs(mnt.mnt_mountp, &sfs))
 					{
-						size = (long double)((double)sfs.f_bsize * (double)sfs.f_bfree);
+						size = (long double)((double)sfs.f_bsize * (double)sfs.f_bavail);
 					}
 				}
 				fclose(fp);
@@ -219,7 +219,7 @@
 #elif defined(__sun__)
 	FILE *fp = fopen("/etc/mnttab", "r");
 	struct mnttab mnt;
-	struct statfs sfs;
+	struct statvfs sfs;
 	int index = 1;
 
 	if(fp)
@@ -232,7 +232,7 @@
 
 				if(mnt.mnt_mountp)
 				{
-					if(!statfs(mnt.mnt_mountp, &sfs, sizeof(struct statfs), 0))
+					if(!statvfs(mnt.mnt_mountp, &sfs))
 					{
 						size = (long double)((double)sfs.f_bsize * (double)sfs.f_blocks);
 					}
@@ -318,7 +318,7 @@
 #elif defined(__sun__)
 	FILE *fp = fopen("/etc/mnttab", "r");
 	struct mnttab mnt;
-	struct statfs sfs;
+	struct statvfs sfs;
 	int index = 1;
 
 	if(fp)
@@ -330,7 +330,7 @@
 				fclose(fp);
 				if(mnt.mnt_mountp)
 				{
-					if(!statfs(mnt.mnt_mountp, &sfs, sizeof(struct statfs), 0) && sfs.f_blocks)
+					if(!statvfs(mnt.mnt_mountp, &sfs) && sfs.f_blocks)
 						return 1;
 				}
 				return 0;