changeset 42:eb003f77538c

Added the filesystem functions for Solaris.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 23 Oct 2001 18:38:34 +0000
parents af0a78aa0d45
children 5bc43ed67700
files compat.c
diffstat 1 files changed, 102 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/compat.c	Tue Oct 23 18:37:46 2001 +0000
+++ b/compat.c	Tue Oct 23 18:38:34 2001 +0000
@@ -10,6 +10,11 @@
 #include <sys/param.h>
 #include <sys/ucred.h>
 #include <sys/mount.h>
+#elif defined(__sun__)
+#include <sys/mnttab.h>
+#include <sys/param.h>
+#include <sys/mount.h>
+#include <sys/statfs.h>
 #else
 #include <mntent.h>
 #include <sys/vfs.h>
@@ -24,7 +29,7 @@
 	struct timespec req;
 
 	req.tv_sec = 0;
-	req.tv_nsec = period * 1000000;
+	req.tv_nsec = period * 10000000;
 
 	nanosleep(&req, NULL);
 #else
@@ -253,6 +258,33 @@
 			return (fsp->f_bsize * fsp->f_bavail) / 1024;
 	}
 	return 0;
+#elif defined(__sun__)
+	FILE *fp = fopen("/etc/mnttab", "r");
+	struct mnttab mnt;
+	struct statfs sfs;
+	int index = 1;
+
+	if(fp)
+	{
+		while((getmntent(fp, &mnt) == 0))
+		{
+			if(index == drive)
+			{
+				long long size = 0;
+
+				if(mnt.mnt_mountp)
+				{
+					statfs(mnt.mnt_mountp, &sfs, sizeof(struct statfs), 0);
+					size = sfs.f_bsize * (sfs.f_bfree / 1024);
+				}
+				fclose(fp);
+				return size;
+			}
+			index++;          
+		}
+		fclose(fp);
+	}
+	return 0;
 #else
 	FILE *fp = setmntent(MOUNTED, "r");
 	struct mntent *mnt;
@@ -334,6 +366,33 @@
 			return (fsp->f_bsize * fsp->f_blocks) / 1024;
 	}
 	return 0;
+#elif defined(__sun__)
+	FILE *fp = fopen("/etc/mnttab", "r");
+	struct mnttab mnt;
+	struct statfs sfs;
+	int index = 1;
+
+	if(fp)
+	{
+		while(getmntent(fp, &mnt) == 0)
+		{
+			if(index == drive)
+			{
+				long long size = 0;
+
+				if(mnt.mnt_mountp)
+				{
+					statfs(mnt.mnt_mountp, &sfs, sizeof(struct statfs), 0);
+					size = sfs.f_bsize * (sfs.f_blocks / 1024);
+				}
+				fclose(fp);
+				return size;
+			}
+			index++;          
+		}
+		fclose(fp);
+	}
+	return 0;
 #else
 	FILE *fp = setmntent(MOUNTED, "r");
 	struct mntent *mnt;
@@ -400,6 +459,31 @@
 			return 1;
 	}
 	return 0;
+#elif defined(__sun__)
+	FILE *fp = fopen("/etc/mnttab", "r");
+	struct mnttab mnt;
+	struct statfs sfs;
+	int index = 1;
+
+	if(fp)
+	{
+		while(getmntent(fp, &mnt) == 0)
+		{
+			if(index == drive)
+			{
+				fclose(fp);
+				if(mnt.mnt_mountp)
+				{
+					statfs(mnt.mnt_mountp, &sfs, sizeof(struct statfs), 0);
+					if(sfs.f_blocks)
+						return 1;
+				}
+				return 0;
+			}
+			index++;          
+		}
+		fclose(fp);
+	}
 #else
 	FILE *fp = setmntent(MOUNTED, "r");
 	struct mntent *mnt;
@@ -445,6 +529,23 @@
 		if(index == drive)
 			strncpy(buf, fsp->f_mntonname, len);
 	}
+#elif defined(__sun__)
+	FILE *fp = fopen("/etc/mnttab", "r");
+	struct mnttab mnt;
+	int index = 1;
+
+	strncpy(buf, "Unknown", len);
+
+	if(fp)
+	{
+		while(getmntent(fp, &mnt) == 0)
+		{
+			if(index == drive && mnt.mnt_mountp)
+				strncpy(buf, mnt.mnt_mountp, len);
+			index++;          
+		}
+		fclose(fp);
+	}
 #else
 	FILE *fp = setmntent(MOUNTED, "r");
 	struct mntent *mnt;