summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2014-01-17 18:10:58 +1100
committerDarren Tucker <dtucker@zip.com.au>2014-01-17 18:10:58 +1100
commita5cf1e220def07290260e4125e74f41ac75cf88d (patch)
tree990b73a34c1f425de38cccf83e2aa386ec7a6af1
parent1357d71d7b6d269969520aaa3e84d312ec971d5b (diff)
- (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@
-rw-r--r--ChangeLog4
-rw-r--r--configure.ac5
-rw-r--r--openbsd-compat/bsd-statvfs.c55
-rw-r--r--openbsd-compat/bsd-statvfs.h9
4 files changed, 63 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index d3a15e4d3..70dad451b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -32,6 +32,10 @@
32 openbsd-compat/openssl-compat.h] Add compatibility layer for older 32 openbsd-compat/openssl-compat.h] Add compatibility layer for older
33 openssl versions. ok djm@ 33 openssl versions. ok djm@
34 - (dtucker) Fix typo in #ifndef. 34 - (dtucker) Fix typo in #ifndef.
35 - (dtucker) [configure.ac openbsd-compat/bsd-statvfs.c
36 openbsd-compat/bsd-statvfs.h] Implement enough of statvfs on top of statfs
37 to be useful (and for the regression tests to pass) on platforms that
38 have statfs and fstatfs. ok djm@
35 39
3620140118 4020140118
37 - (djm) OpenBSD CVS Sync 41 - (djm) OpenBSD CVS Sync
diff --git a/configure.ac b/configure.ac
index 2ac3afa38..c97e12f34 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
1# $Id: configure.ac,v 1.551 2014/01/17 06:32:30 dtucker Exp $ 1# $Id: configure.ac,v 1.552 2014/01/17 07:10:58 dtucker Exp $
2# 2#
3# Copyright (c) 1999-2004 Damien Miller 3# Copyright (c) 1999-2004 Damien Miller
4# 4#
@@ -15,7 +15,7 @@
15# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 16
17AC_INIT([OpenSSH], [Portable], [openssh-unix-dev@mindrot.org]) 17AC_INIT([OpenSSH], [Portable], [openssh-unix-dev@mindrot.org])
18AC_REVISION($Revision: 1.551 $) 18AC_REVISION($Revision: 1.552 $)
19AC_CONFIG_SRCDIR([ssh.c]) 19AC_CONFIG_SRCDIR([ssh.c])
20AC_LANG([C]) 20AC_LANG([C])
21 21
@@ -1585,6 +1585,7 @@ AC_CHECK_FUNCS([ \
1585 fchmod \ 1585 fchmod \
1586 fchown \ 1586 fchown \
1587 freeaddrinfo \ 1587 freeaddrinfo \
1588 fstatfs \
1588 fstatvfs \ 1589 fstatvfs \
1589 futimes \ 1590 futimes \
1590 getaddrinfo \ 1591 getaddrinfo \
diff --git a/openbsd-compat/bsd-statvfs.c b/openbsd-compat/bsd-statvfs.c
index 844d5b464..2b1da80ec 100644
--- a/openbsd-compat/bsd-statvfs.c
+++ b/openbsd-compat/bsd-statvfs.c
@@ -1,7 +1,7 @@
1/* $Id: bsd-statvfs.c,v 1.1 2008/06/08 17:32:29 dtucker Exp $ */ 1/* $Id: bsd-statvfs.c,v 1.2 2014/01/17 07:10:59 dtucker Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2008 Darren Tucker <dtucker@zip.com.au> 4 * Copyright (c) 2008,2014 Darren Tucker <dtucker@zip.com.au>
5 * 5 *
6 * Permission to use, copy, modify, and distribute this software for any 6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above 7 * purpose with or without fee is hereby granted, provided that the above
@@ -18,20 +18,65 @@
18 18
19#include "includes.h" 19#include "includes.h"
20 20
21#if !defined(HAVE_STATVFS) || !defined(HAVE_FSTATVFS)
22
23#include <sys/param.h>
24#ifdef HAVE_SYS_MOUNT_H
25# include <sys/mount.h>
26#endif
27
21#include <errno.h> 28#include <errno.h>
22 29
23#ifndef HAVE_STATVFS 30static void
31copy_statfs_to_statvfs(struct statvfs *to, struct statfs *from)
32{
33 to->f_bsize = from->f_bsize;
34 to->f_frsize = from->f_bsize; /* no exact equivalent */
35 to->f_blocks = from->f_blocks;
36 to->f_bfree = from->f_bfree;
37 to->f_bavail = from->f_bavail;
38 to->f_files = from->f_files;
39 to->f_ffree = from->f_ffree;
40 to->f_favail = from->f_ffree; /* no exact equivalent */
41 to->f_fsid = 0; /* XXX fix me */
42 to->f_flag = from->f_flags;
43 to->f_namemax = MNAMELEN;
44}
45
46# ifndef HAVE_STATVFS
24int statvfs(const char *path, struct statvfs *buf) 47int statvfs(const char *path, struct statvfs *buf)
25{ 48{
49# ifdef HAVE_STATFS
50 struct statfs fs;
51
52 memset(&fs, 0, sizeof(fs));
53 if (statfs(path, &fs) == -1)
54 return -1;
55 copy_statfs_to_statvfs(buf, &fs);
56 return 0;
57# else
26 errno = ENOSYS; 58 errno = ENOSYS;
27 return -1; 59 return -1;
60# endif
28} 61}
29#endif 62# endif
30 63
31#ifndef HAVE_FSTATVFS 64# ifndef HAVE_FSTATVFS
32int fstatvfs(int fd, struct statvfs *buf) 65int fstatvfs(int fd, struct statvfs *buf)
33{ 66{
67# ifdef HAVE_FSTATFS
68 struct statfs fs;
69
70 memset(&fs, 0, sizeof(fs));
71 if (fstatfs(fd, &fs) == -1)
72 return -1;
73 copy_statfs_to_statvfs(buf, &fs);
74 return 0;
75# else
34 errno = ENOSYS; 76 errno = ENOSYS;
35 return -1; 77 return -1;
78# endif
36} 79}
80# endif
81
37#endif 82#endif
diff --git a/openbsd-compat/bsd-statvfs.h b/openbsd-compat/bsd-statvfs.h
index da215ffc6..057407cc8 100644
--- a/openbsd-compat/bsd-statvfs.h
+++ b/openbsd-compat/bsd-statvfs.h
@@ -1,7 +1,7 @@
1/* $Id: bsd-statvfs.h,v 1.1 2008/06/08 17:32:29 dtucker Exp $ */ 1/* $Id: bsd-statvfs.h,v 1.2 2014/01/17 07:10:59 dtucker Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2008 Darren Tucker <dtucker@zip.com.au> 4 * Copyright (c) 2008,2014 Darren Tucker <dtucker@zip.com.au>
5 * 5 *
6 * Permission to use, copy, modify, and distribute this software for any 6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above 7 * purpose with or without fee is hereby granted, provided that the above
@@ -20,11 +20,14 @@
20 20
21#include <sys/types.h> 21#include <sys/types.h>
22 22
23#ifdef HAVE_SYS_MOUNT_H
24#include <sys/mount.h>
25#endif
23#ifdef HAVE_SYS_STATFS_H 26#ifdef HAVE_SYS_STATFS_H
24#include <sys/statfs.h> 27#include <sys/statfs.h>
25#endif 28#endif
26 29
27#ifndef HAVE_STATVFS 30#if !defined(HAVE_STATVFS) || !defined(HAVE_FSTATVFS)
28 31
29#ifndef HAVE_FSBLKCNT_T 32#ifndef HAVE_FSBLKCNT_T
30typedef unsigned long fsblkcnt_t; 33typedef unsigned long fsblkcnt_t;