Use statvfs instead of statfs, and provide a default implementation in
[wine/multimedia.git] / libs / port / statvfs.c
blobfc1f10bd8940bd7cdd95cb6a208b69d73695feb7
1 /*
2 * statvfs function
4 * Copyright 2004 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "config.h"
22 #include "wine/port.h"
24 #ifndef HAVE_STATVFS
26 #include <sys/types.h>
27 #include <sys/stat.h>
28 #ifdef HAVE_SYS_PARAM_H
29 # include <sys/param.h>
30 #endif
31 #ifdef STATFS_DEFINED_BY_SYS_VFS
32 # include <sys/vfs.h>
33 #else
34 # ifdef STATFS_DEFINED_BY_SYS_MOUNT
35 # include <sys/mount.h>
36 # else
37 # ifdef STATFS_DEFINED_BY_SYS_STATFS
38 # include <sys/statfs.h>
39 # endif
40 # endif
41 #endif
43 int statvfs( const char *path, struct statvfs *buf )
45 int ret;
46 struct statfs info;
48 /* FIXME: add autoconf check for this */
49 #if defined(__svr4__) || defined(_SCO_DS) || defined(__sun)
50 ret = statfs( path, &info, 0, 0 );
51 #else
52 ret = statfs( path, &info );
53 #endif
54 if (ret >= 0)
56 memset( buf, 0, sizeof(*buf) );
57 buf->f_bsize = info.f_bsize;
58 buf->f_blocks = info.f_blocks;
59 buf->f_files = info.f_files;
60 buf->f_namemax = info.f_namelen;
61 #ifdef HAVE_STRUCT_STATFS_F_FRSIZE
62 buf->f_frsize = info.f_frsize;
63 #else
64 buf->f_frsize = info.f_bsize;
65 #endif
66 #ifdef HAVE_STRUCT_STATFS_F_BFREE
67 buf->f_bfree = info.f_bfree;
68 #else
69 buf->f_bfree = info.f_bavail;
70 #endif
71 #ifdef HAVE_STRUCT_STATFS_F_BAVAIL
72 buf->f_bavail = info.f_bavail;
73 #else
74 buf->f_bavail = info.f_bfree;
75 #endif
76 #ifdef HAVE_STRUCT_STATFS_F_FFREE
77 buf->f_ffree = info.f_ffree;
78 #else
79 buf->f_ffree = info.f_favail;
80 #endif
81 #ifdef HAVE_STRUCT_STATFS_F_FAVAIL
82 buf->f_favail = info.f_favail;
83 #else
84 buf->f_favail = info.f_ffree;
85 #endif
87 return ret;
90 #endif /* HAVE_STATVFS */