]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
- (dtucker) [configure.ac openbsd-compat/bsd-statvfs.c
authorDarren Tucker <dtucker@zip.com.au>
Fri, 17 Jan 2014 07:10:58 +0000 (18:10 +1100)
committerDarren Tucker <dtucker@zip.com.au>
Fri, 17 Jan 2014 07:10:58 +0000 (18:10 +1100)
   openbsd-compat/bsd-statvfs.h] Implement enough of statvfs on top of statfs
   to be useful (and for the regression tests to pass) on platforms that
   have statfs and fstatfs.  ok djm@

ChangeLog
configure.ac
openbsd-compat/bsd-statvfs.c
openbsd-compat/bsd-statvfs.h

index d3a15e4d3f8641d4ed036e6ce690a1b8e642bbc8..70dad451ba9b6c743a10ec612a3c102b2657a350 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
    openbsd-compat/openssl-compat.h]  Add compatibility layer for older
    openssl versions.  ok djm@
  - (dtucker) Fix typo in #ifndef.
+ - (dtucker) [configure.ac openbsd-compat/bsd-statvfs.c
+   openbsd-compat/bsd-statvfs.h] Implement enough of statvfs on top of statfs
+   to be useful (and for the regression tests to pass) on platforms that
+   have statfs and fstatfs.  ok djm@
 
 20140118
  - (djm) OpenBSD CVS Sync
index 2ac3afa38d0d701e0405a04d09ed1fc066b5f79b..c97e12f34ec7ccb94feed6dd7aca811ef2f11d67 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: configure.ac,v 1.551 2014/01/17 06:32:30 dtucker Exp $
+# $Id: configure.ac,v 1.552 2014/01/17 07:10:58 dtucker Exp $
 #
 # Copyright (c) 1999-2004 Damien Miller
 #
@@ -15,7 +15,7 @@
 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 AC_INIT([OpenSSH], [Portable], [openssh-unix-dev@mindrot.org])
-AC_REVISION($Revision: 1.551 $)
+AC_REVISION($Revision: 1.552 $)
 AC_CONFIG_SRCDIR([ssh.c])
 AC_LANG([C])
 
@@ -1585,6 +1585,7 @@ AC_CHECK_FUNCS([ \
        fchmod \
        fchown \
        freeaddrinfo \
+       fstatfs \
        fstatvfs \
        futimes \
        getaddrinfo \
index 844d5b464dfc12f840a38790ca589e60db3b1cfe..2b1da80ec8831aa85e8fea332b8ca134a6bc6621 100644 (file)
@@ -1,7 +1,7 @@
-/* $Id: bsd-statvfs.c,v 1.1 2008/06/08 17:32:29 dtucker Exp $ */
+/* $Id: bsd-statvfs.c,v 1.2 2014/01/17 07:10:59 dtucker Exp $ */
 
 /*
- * Copyright (c) 2008 Darren Tucker <dtucker@zip.com.au>
+ * Copyright (c) 2008,2014 Darren Tucker <dtucker@zip.com.au>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
 
 #include "includes.h"
 
+#if !defined(HAVE_STATVFS) || !defined(HAVE_FSTATVFS)
+
+#include <sys/param.h>
+#ifdef HAVE_SYS_MOUNT_H
+# include <sys/mount.h>
+#endif
+
 #include <errno.h>
 
-#ifndef HAVE_STATVFS
+static void
+copy_statfs_to_statvfs(struct statvfs *to, struct statfs *from)
+{
+       to->f_bsize = from->f_bsize;
+       to->f_frsize = from->f_bsize;   /* no exact equivalent */
+       to->f_blocks = from->f_blocks;
+       to->f_bfree = from->f_bfree;
+       to->f_bavail = from->f_bavail;
+       to->f_files = from->f_files;
+       to->f_ffree = from->f_ffree;
+       to->f_favail = from->f_ffree;   /* no exact equivalent */
+       to->f_fsid = 0;                 /* XXX fix me */
+       to->f_flag = from->f_flags;
+       to->f_namemax = MNAMELEN;
+}
+
+# ifndef HAVE_STATVFS
 int statvfs(const char *path, struct statvfs *buf)
 {
+#  ifdef HAVE_STATFS
+       struct statfs fs;
+
+       memset(&fs, 0, sizeof(fs));
+       if (statfs(path, &fs) == -1)
+               return -1;
+       copy_statfs_to_statvfs(buf, &fs);
+       return 0;
+#  else
        errno = ENOSYS;
        return -1;
+#  endif
 }
-#endif
+# endif
 
-#ifndef HAVE_FSTATVFS
+# ifndef HAVE_FSTATVFS
 int fstatvfs(int fd, struct statvfs *buf)
 {
+#  ifdef HAVE_FSTATFS
+       struct statfs fs;
+
+       memset(&fs, 0, sizeof(fs));
+       if (fstatfs(fd, &fs) == -1)
+               return -1;
+       copy_statfs_to_statvfs(buf, &fs);
+       return 0;
+#  else
        errno = ENOSYS;
        return -1;
+#  endif
 }
+# endif
+
 #endif
index da215ffc68d1fe5159282491a6951dfb40da3928..057407cc8a95659d58363321200df3cf96a24484 100644 (file)
@@ -1,7 +1,7 @@
-/* $Id: bsd-statvfs.h,v 1.1 2008/06/08 17:32:29 dtucker Exp $ */
+/* $Id: bsd-statvfs.h,v 1.2 2014/01/17 07:10:59 dtucker Exp $ */
 
 /*
- * Copyright (c) 2008 Darren Tucker <dtucker@zip.com.au>
+ * Copyright (c) 2008,2014 Darren Tucker <dtucker@zip.com.au>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
 
 #include <sys/types.h>
 
+#ifdef HAVE_SYS_MOUNT_H
+#include <sys/mount.h>
+#endif
 #ifdef HAVE_SYS_STATFS_H
 #include <sys/statfs.h>
 #endif
 
-#ifndef HAVE_STATVFS
+#if !defined(HAVE_STATVFS) || !defined(HAVE_FSTATVFS)
 
 #ifndef HAVE_FSBLKCNT_T
 typedef unsigned long fsblkcnt_t;