summaryrefslogtreecommitdiff
path: root/gnu/libexec/uucp/libunix/bytfre.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1995-10-18 08:53:40 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1995-10-18 08:53:40 +0000
commitd6583bb2a13f329cf0332ef2570eb8bb8fc0e39c (patch)
treeece253b876159b39c620e62b6c9b1174642e070e /gnu/libexec/uucp/libunix/bytfre.c
initial import of NetBSD tree
Diffstat (limited to 'gnu/libexec/uucp/libunix/bytfre.c')
-rw-r--r--gnu/libexec/uucp/libunix/bytfre.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/gnu/libexec/uucp/libunix/bytfre.c b/gnu/libexec/uucp/libunix/bytfre.c
new file mode 100644
index 00000000000..3091e7aaa3a
--- /dev/null
+++ b/gnu/libexec/uucp/libunix/bytfre.c
@@ -0,0 +1,27 @@
+/* bytfre.c
+ Get the number of bytes free on a file system. */
+
+#include "uucp.h"
+
+#include "system.h"
+#include "sysdep.h"
+#include "fsusg.h"
+
+#if HAVE_LIMITS_H
+#include <limits.h>
+#else
+#define LONG_MAX 2147483647
+#endif
+
+long
+csysdep_bytes_free (zfile)
+ const char *zfile;
+{
+ struct fs_usage s;
+
+ if (get_fs_usage ((char *) zfile, (char *) NULL, &s) < 0)
+ return -1;
+ if (s.fsu_bavail >= LONG_MAX / (long) 512)
+ return LONG_MAX;
+ return s.fsu_bavail * (long) 512;
+}