summaryrefslogtreecommitdiff
path: root/openbsd-compat
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@dtucker.net>2019-10-28 16:09:04 +1100
committerDarren Tucker <dtucker@dtucker.net>2019-10-28 16:27:53 +1100
commitd561b0b2fa2531b4cc3bc70a7d657c6485c9fd0b (patch)
treedd65310dd68efa3a4f6e1ddf613caa60adee5ab6 /openbsd-compat
parent2912596aecfcf48e5115c7a906d1e664f7717a4b (diff)
Make sure we have struct statfs before using.
Diffstat (limited to 'openbsd-compat')
-rw-r--r--openbsd-compat/bsd-statvfs.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/openbsd-compat/bsd-statvfs.c b/openbsd-compat/bsd-statvfs.c
index e3bd87d98..10d876439 100644
--- a/openbsd-compat/bsd-statvfs.c
+++ b/openbsd-compat/bsd-statvfs.c
@@ -29,6 +29,11 @@
29# define MNAMELEN 32 29# define MNAMELEN 32
30#endif 30#endif
31 31
32#ifdef HAVE_STRUCT_STATFS_F_FILES
33# define HAVE_STRUCT_STATFS
34#endif
35
36#ifdef HAVE_STRUCT_STATFS
32static void 37static void
33copy_statfs_to_statvfs(struct statvfs *to, struct statfs *from) 38copy_statfs_to_statvfs(struct statvfs *to, struct statfs *from)
34{ 39{
@@ -48,11 +53,12 @@ copy_statfs_to_statvfs(struct statvfs *to, struct statfs *from)
48#endif 53#endif
49 to->f_namemax = MNAMELEN; 54 to->f_namemax = MNAMELEN;
50} 55}
56#endif
51 57
52# ifndef HAVE_STATVFS 58# ifndef HAVE_STATVFS
53int statvfs(const char *path, struct statvfs *buf) 59int statvfs(const char *path, struct statvfs *buf)
54{ 60{
55# ifdef HAVE_STATFS 61# if defined(HAVE_STATFS) && defined(HAVE_STRUCT_STATFS)
56 struct statfs fs; 62 struct statfs fs;
57 63
58 memset(&fs, 0, sizeof(fs)); 64 memset(&fs, 0, sizeof(fs));
@@ -70,7 +76,7 @@ int statvfs(const char *path, struct statvfs *buf)
70# ifndef HAVE_FSTATVFS 76# ifndef HAVE_FSTATVFS
71int fstatvfs(int fd, struct statvfs *buf) 77int fstatvfs(int fd, struct statvfs *buf)
72{ 78{
73# ifdef HAVE_FSTATFS 79# if defined(HAVE_FSTATFS) && defined(HAVE_STRUCT_STATFS)
74 struct statfs fs; 80 struct statfs fs;
75 81
76 memset(&fs, 0, sizeof(fs)); 82 memset(&fs, 0, sizeof(fs));