Unbreak getTcpTable() on Linux-based systems and make it work on BSD
[wine] / libs / port / statfs.c
1 /*
2  * statfs function
3  *
4  * Copyright 1996 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 #ifdef __BEOS__
25 #include <be/kernel/fs_info.h>
26 #include <be/kernel/OS.h>
27 #endif
28
29 #include <errno.h>
30 #ifdef HAVE_SYS_PARAM_H
31 # include <sys/param.h>
32 #endif
33 #ifdef STATFS_DEFINED_BY_SYS_VFS
34 # include <sys/vfs.h>
35 #else
36 # ifdef STATFS_DEFINED_BY_SYS_MOUNT
37 #  include <sys/mount.h>
38 # else
39 #  ifdef STATFS_DEFINED_BY_SYS_STATFS
40 #   include <sys/statfs.h>
41 #  endif
42 # endif
43 #endif
44
45 #ifndef HAVE_STATFS
46 int statfs(const char *name, struct statfs *info)
47 {
48 #ifdef __BEOS__
49     dev_t mydev;
50     fs_info fsinfo;
51
52     if(!info) {
53         errno = ENOSYS;
54         return -1;
55     }
56
57     if ((mydev = dev_for_path(name)) < 0) {
58         errno = ENOSYS;
59         return -1;
60     }
61
62     if (fs_stat_dev(mydev,&fsinfo) < 0) {
63         errno = ENOSYS;
64         return -1;
65     }
66
67     info->f_bsize = fsinfo.block_size;
68     info->f_blocks = fsinfo.total_blocks;
69     info->f_bfree = fsinfo.free_blocks;
70     return 0;
71 #else /* defined(__BEOS__) */
72     errno = ENOSYS;
73     return -1;
74 #endif /* defined(__BEOS__) */
75 }
76 #endif /* !defined(HAVE_STATFS) */