Fix TB_GETSTYLE message to return the style of the toolbar and not the
[wine] / libs / port / statvfs.c
1 /*
2  * statvfs function
3  *
4  * Copyright 2004 Alexandre Julliard
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include "config.h"
22 #include "wine/port.h"
23
24 #ifndef HAVE_STATVFS
25
26 #include <sys/types.h>
27 #include <sys/stat.h>
28 #include <errno.h>
29 #ifdef HAVE_SYS_PARAM_H
30 # include <sys/param.h>
31 #endif
32 #ifdef STATFS_DEFINED_BY_SYS_VFS
33 # include <sys/vfs.h>
34 #else
35 # ifdef STATFS_DEFINED_BY_SYS_MOUNT
36 #  include <sys/mount.h>
37 # else
38 #  ifdef STATFS_DEFINED_BY_SYS_STATFS
39 #   include <sys/statfs.h>
40 #  endif
41 # endif
42 #endif
43
44 int statvfs( const char *path, struct statvfs *buf )
45 {
46     int ret;
47 #ifdef HAVE_STATFS
48     struct statfs info;
49
50 /* FIXME: add autoconf check for this */
51 #if defined(__svr4__) || defined(_SCO_DS) || defined(__sun)
52     ret = statfs( path, &info, 0, 0 );
53 #else
54     ret = statfs( path, &info );
55 #endif
56     if (ret >= 0)
57     {
58         memset( buf, 0, sizeof(*buf) );
59         buf->f_bsize   = info.f_bsize;
60         buf->f_blocks  = info.f_blocks;
61         buf->f_files   = info.f_files;
62 #ifdef HAVE_STRUCT_STATFS_F_NAMELEN
63         buf->f_namemax = info.f_namelen;
64 #endif
65 #ifdef HAVE_STRUCT_STATFS_F_FRSIZE
66         buf->f_frsize  = info.f_frsize;
67 #else
68         buf->f_frsize  = info.f_bsize;
69 #endif
70 #ifdef HAVE_STRUCT_STATFS_F_BFREE
71         buf->f_bfree   = info.f_bfree;
72 #else
73         buf->f_bfree   = info.f_bavail;
74 #endif
75 #ifdef HAVE_STRUCT_STATFS_F_BAVAIL
76         buf->f_bavail  = info.f_bavail;
77 #else
78         buf->f_bavail  = info.f_bfree;
79 #endif
80 #ifdef HAVE_STRUCT_STATFS_F_FFREE
81         buf->f_ffree   = info.f_ffree;
82 #else
83         buf->f_ffree   = info.f_favail;
84 #endif
85 #ifdef HAVE_STRUCT_STATFS_F_FAVAIL
86         buf->f_favail  = info.f_favail;
87 #else
88         buf->f_favail  = info.f_ffree;
89 #endif
90     }
91 #else  /* HAVE_STATFS */
92     ret = -1;
93     errno = ENOSYS;
94 #endif  /* HAVE_STATFS */
95     return ret;
96 }
97
98 #endif /* HAVE_STATVFS */