summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2014-07-05 07:58:42 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2014-07-05 07:58:42 +0000
commit0bd3e1f2ac4acf59d3be3b9c32f704e3a3dfd662 (patch)
tree5c469551955572b457b97be4208568c36cf4a31e /usr.bin
parent784fb4e3483269b305e48e7d0b39177ecddb3351 (diff)
Assume BSD44: statfs()
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/rdist/filesys.h27
-rw-r--r--usr.bin/rdist/os-openbsd.h7
-rw-r--r--usr.bin/rdistd/filesys.c41
3 files changed, 11 insertions, 64 deletions
diff --git a/usr.bin/rdist/filesys.h b/usr.bin/rdist/filesys.h
index 59ff2c00cfc..a5e24617d59 100644
--- a/usr.bin/rdist/filesys.h
+++ b/usr.bin/rdist/filesys.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: filesys.h,v 1.2 2003/06/03 02:56:14 millert Exp $ */
+/* $OpenBSD: filesys.h,v 1.3 2014/07/05 07:58:41 guenther Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
@@ -90,31 +90,6 @@
#endif /* NCR */
/*
- * Stat Filesystem
- */
-#if defined(STATFS_TYPE)
-# if defined(ultrix)
- typedef struct fs_data statfs_t;
-# define f_bavail fd_req.bfreen
-# define f_bsize fd_req.bsize
-# define f_ffree fd_req.gfree
-# elif defined(_AIX) || STATFS_TYPE == STATFS_SYSV
-# include <sys/statfs.h>
- typedef struct statfs statfs_t;
-# define f_bavail f_bfree
-# elif defined(SVR4)
-# include <sys/statvfs.h>
- typedef struct statvfs statfs_t;
-# define statfs(mp,sb) statvfs(mp,sb)
-# elif STATFS_TYPE == STATFS_44BSD || STATFS_TYPE == STATFS_OSF1
- typedef struct statfs statfs_t;
-# else
-# include <sys/vfs.h>
- typedef struct statfs statfs_t;
-# endif
-#endif /* STATFS_TYPE */
-
-/*
* Mount Entry definetions
*/
#ifndef METYPE_OTHER
diff --git a/usr.bin/rdist/os-openbsd.h b/usr.bin/rdist/os-openbsd.h
index 5ddef01ffa5..b3e0109c592 100644
--- a/usr.bin/rdist/os-openbsd.h
+++ b/usr.bin/rdist/os-openbsd.h
@@ -29,7 +29,7 @@
*/
/*
- * $OpenBSD: os-openbsd.h,v 1.20 2014/07/05 07:25:27 guenther Exp $
+ * $OpenBSD: os-openbsd.h,v 1.21 2014/07/05 07:58:41 guenther Exp $
*/
/*
@@ -56,11 +56,6 @@
#define FSI_TYPE FSI_GETFSSTAT
/*
- * Select the type of statfs() system call (if any).
- */
-#define STATFS_TYPE STATFS_44BSD
-
-/*
* Use f_fstypename in struct statfs.
*/
#define HAVE_FSTYPENAME 1
diff --git a/usr.bin/rdistd/filesys.c b/usr.bin/rdistd/filesys.c
index 0b0ee06e9fe..f13e6343d43 100644
--- a/usr.bin/rdistd/filesys.c
+++ b/usr.bin/rdistd/filesys.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: filesys.c,v 1.13 2014/07/05 06:33:54 guenther Exp $ */
+/* $OpenBSD: filesys.c,v 1.14 2014/07/05 07:58:41 guenther Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
@@ -404,9 +404,9 @@ is_symlinked(char *path, struct stat *statbuf, int *isvalid)
int
getfilesysinfo(char *file, int64_t *freespace, int64_t *freefiles)
{
-#if defined(STATFS_TYPE)
- static statfs_t statfsbuf;
+ struct statfs statfsbuf;
char *mntpt;
+ int64_t val;
int t, r;
/*
@@ -418,19 +418,7 @@ getfilesysinfo(char *file, int64_t *freespace, int64_t *freefiles)
return(-1);
}
- /*
- * Stat the filesystem (system specific)
- */
-#if STATFS_TYPE == STATFS_SYSV
- r = statfs(mntpt, &statfsbuf, sizeof(statfs_t), 0);
-#endif
-#if STATFS_TYPE == STATFS_BSD || STATFS_TYPE == STATFS_44BSD
r = statfs(mntpt, &statfsbuf);
-#endif
-#if STATFS_TYPE == STATFS_OSF1
- r = statfs(mntpt, &statfsbuf, sizeof(statfs_t));
-#endif
-
if (r < 0) {
error("%s: Cannot statfs filesystem: %s.", mntpt, SYSERR);
return(-1);
@@ -440,26 +428,15 @@ getfilesysinfo(char *file, int64_t *freespace, int64_t *freefiles)
* If values are < 0, then assume the value is unsupported
* or unavailable for that filesystem type.
*/
+ val = -1;
if (statfsbuf.f_bavail >= 0)
- *freespace = (statfsbuf.f_bavail * (statfsbuf.f_bsize / 512))
- / 2;
+ val = (statfsbuf.f_bavail * (statfsbuf.f_bsize / 512)) / 2;
+ *freespace = val;
- /*
- * BROKEN_STATFS means that statfs() does not set fields
- * to < 0 if the field is unsupported for the filesystem type.
- */
-#if defined(BROKEN_STATFS)
- if (statfsbuf.f_favail > 0)
-#else
+ val = -1;
if (statfsbuf.f_favail >= 0)
-#endif /* BROKEN_STATFS */
- *freefiles = statfsbuf.f_favail;
-
-#else /* !STATFS_TYPE */
-
- *freespace = *freefiles = -1;
-
-#endif /* STATFS_TYPE */
+ val = statfsbuf.f_favail;
+ *freefiles = val;
return(0);
}