Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/3d/fstatfs3d.c
1808 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1989-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Glenn Fowler <[email protected]> *
18
* David Korn <[email protected]> *
19
* Eduardo Krell <[email protected]> *
20
* *
21
***********************************************************************/
22
#pragma prototyped
23
24
#if defined(__STDPP__directive) && defined(__STDPP__hide)
25
__STDPP__directive pragma pp:hide fstatfs
26
#else
27
#define fstatfs ______fstatfs
28
#endif
29
#define _def_syscall_3d 1
30
31
#include "3d.h"
32
33
#if defined(fstatfs3d) && ( _sys_statfs || _sys_vfs || _sys_mount && _mem_f_files_statfs )
34
35
#include <cs_lib.h>
36
37
#if _sys_statfs
38
#include <sys/statfs.h>
39
#else
40
#if _sys_vfs
41
#include <sys/vfs.h>
42
#define _vfs_statfs 1
43
#else
44
#if _sys_mount
45
#if _lib_getmntinfo
46
#include <sys/param.h> /* expect some macro redefinitions here */
47
#endif
48
#include <sys/mount.h>
49
#endif
50
#endif
51
#endif
52
53
#undef _def_syscall_3d
54
#if defined(__STDPP__directive) && defined(__STDPP__hide)
55
__STDPP__directive pragma pp:nohide fstatfs
56
#else
57
#undef fstatfs
58
#endif
59
60
#include "FEATURE/syscall"
61
62
#if _vfs_statfs
63
#define VFS (fs)
64
#else
65
#define VFS (&vfs)
66
#endif
67
68
#if ARG3D_fstatfs == 4
69
70
int
71
fstatfs3d(int fd, struct statfs* fs, int size, int type)
72
{
73
#if FS
74
Mount_t* mp;
75
#if !_vfs_statfs
76
struct statvfs vfs;
77
#endif
78
79
if (!fscall(NiL, MSG_fstatfs, 0, fd, VFS, size, type))
80
{
81
#if !_vfs_statfs
82
if (!state.ret)
83
{
84
memset(fs, 0, sizeof(*fs));
85
fs->f_bsize = vfs.f_bsize;
86
fs->f_blocks = vfs.f_blocks;
87
fs->f_bfree = vfs.f_bfree;
88
fs->f_files = vfs.f_files;
89
fs->f_ffree = vfs.f_ffree;
90
}
91
#endif
92
return state.ret;
93
}
94
mp = monitored();
95
#endif
96
if (FSTATFS(fd, fs, size, type))
97
return -1;
98
#if FS
99
#if !_vfs_statfs
100
if (mp || state.global)
101
{
102
memset(&vfs, 0, sizeof(vfs));
103
vfs.f_bsize = fs->f_bsize;
104
vfs.f_blocks = fs->f_blocks;
105
vfs.f_bfree = fs->f_bfree;
106
vfs.f_files = fs->f_files;
107
vfs.f_ffree = fs->f_ffree;
108
}
109
#endif
110
if (mp)
111
fscall(mp, MSG_fstatfs, 0, fd, VFS, size, type);
112
for (mp = state.global; mp; mp = mp->global)
113
if (fssys(mp, MSG_fstatfs))
114
fscall(mp, MSG_fstatfs, 0, fd, VFS, size, type);
115
#endif
116
return 0;
117
}
118
119
#else
120
121
int
122
fstatfs3d(int fd, struct statfs* fs)
123
{
124
#if FS
125
Mount_t* mp;
126
#if !_vfs_statfs
127
struct statvfs vfs;
128
#endif
129
130
if (!fscall(NiL, MSG_fstatfs, 0, fd, VFS))
131
{
132
#if !_vfs_statfs
133
if (!state.ret)
134
{
135
memset(fs, 0, sizeof(*fs));
136
fs->f_bsize = vfs.f_bsize;
137
fs->f_blocks = vfs.f_blocks;
138
fs->f_bfree = vfs.f_bfree;
139
fs->f_files = vfs.f_files;
140
fs->f_ffree = vfs.f_ffree;
141
}
142
#endif
143
return state.ret;
144
}
145
mp = monitored();
146
#endif
147
if (FSTATFS(fd, fs))
148
return -1;
149
#if FS
150
#if !_vfs_statfs
151
if (mp || state.global)
152
{
153
memset(&vfs, 0, sizeof(vfs));
154
vfs.f_bsize = fs->f_bsize;
155
vfs.f_blocks = fs->f_blocks;
156
vfs.f_bfree = fs->f_bfree;
157
vfs.f_files = fs->f_files;
158
vfs.f_ffree = fs->f_ffree;
159
}
160
#endif
161
if (mp)
162
fscall(mp, MSG_fstatfs, 0, fd, VFS);
163
for (mp = state.global; mp; mp = mp->global)
164
if (fssys(mp, MSG_fstatfs))
165
fscall(mp, MSG_fstatfs, 0, fd, VFS);
166
#endif
167
return 0;
168
}
169
170
#endif
171
172
#else
173
174
NoN(fstatfs)
175
176
#endif
177
178