This source file includes following definitions.
- statfs_to_ostatfs
- compat_25_sys_statfs
- compat_25_sys_fstatfs
- compat_25_sys_getfsstat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 #include <sys/namei.h>
42 #include <sys/filedesc.h>
43 #include <sys/kernel.h>
44 #include <sys/file.h>
45 #include <sys/vnode.h>
46 #include <sys/mount.h>
47 #include <sys/proc.h>
48 #include <sys/uio.h>
49 #include <sys/dirent.h>
50
51 #include <sys/syscallargs.h>
52
53 void statfs_to_ostatfs(struct proc *, struct mount *, struct statfs *, struct ostatfs *);
54
55
56
57
58 void
59 statfs_to_ostatfs(p, mp, sp, osp)
60 struct proc *p;
61 struct mount *mp;
62 struct statfs *sp;
63 struct ostatfs *osp;
64 {
65 #ifdef COMPAT_43
66 osp->f_type = mp->mnt_vfc->vfc_typenum;
67 #else
68 osp->f_type = 0;
69 #endif
70 osp->f_flags = mp->mnt_flag & 0xffff;
71 osp->f_bsize = sp->f_bsize;
72 osp->f_iosize = sp->f_iosize;
73 osp->f_blocks = sp->f_blocks;
74 osp->f_bfree = sp->f_bfree;
75 osp->f_bavail = sp->f_bavail;
76 osp->f_files = sp->f_files;
77 osp->f_ffree = sp->f_ffree;
78
79 if (suser(p, 0))
80 osp->f_fsid.val[0] = osp->f_fsid.val[1] = 0;
81 else
82 bcopy(&sp->f_fsid, &osp->f_fsid, sizeof(osp->f_fsid));
83 osp->f_owner = sp->f_owner;
84 osp->f_syncwrites = sp->f_syncwrites;
85 osp->f_asyncwrites = sp->f_asyncwrites;
86 bcopy(sp->f_fstypename, osp->f_fstypename, MFSNAMELEN);
87 bcopy(sp->f_mntonname, osp->f_mntonname, MNAMELEN);
88 bcopy(sp->f_mntfromname, osp->f_mntfromname, MNAMELEN);
89 }
90
91
92
93
94
95 int
96 compat_25_sys_statfs(p, v, retval)
97 struct proc *p;
98 void *v;
99 register_t *retval;
100 {
101 register struct compat_25_sys_statfs_args
102
103
104 *uap = v;
105 register struct mount *mp;
106 register struct statfs *sp;
107 struct ostatfs osb;
108 int error;
109 struct nameidata nd;
110
111 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
112 if ((error = namei(&nd)) != 0)
113 return (error);
114 mp = nd.ni_vp->v_mount;
115 sp = &mp->mnt_stat;
116 vrele(nd.ni_vp);
117 if ((error = VFS_STATFS(mp, sp, p)) != 0)
118 return (error);
119
120 statfs_to_ostatfs(p, mp, sp, &osb);
121 return (copyout((caddr_t)&osb, (caddr_t)SCARG(uap, buf), sizeof(osb)));
122 }
123
124
125
126
127
128 int
129 compat_25_sys_fstatfs(p, v, retval)
130 struct proc *p;
131 void *v;
132 register_t *retval;
133 {
134 struct compat_25_sys_fstatfs_args
135
136
137 *uap = v;
138 struct file *fp;
139 struct mount *mp;
140 struct statfs *sp;
141 struct ostatfs osb;
142 int error;
143
144 if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
145 return (error);
146 mp = ((struct vnode *)fp->f_data)->v_mount;
147 sp = &mp->mnt_stat;
148 error = VFS_STATFS(mp, sp, p);
149 FRELE(fp);
150 if (error)
151 return (error);
152
153 statfs_to_ostatfs(p, mp, sp, &osb);
154 return (copyout((caddr_t)&osb, (caddr_t)SCARG(uap, buf), sizeof(osb)));
155 }
156
157
158
159
160 int
161 compat_25_sys_getfsstat(p, v, retval)
162 struct proc *p;
163 void *v;
164 register_t *retval;
165 {
166 register struct compat_25_sys_getfsstat_args
167
168
169
170 *uap = v;
171 register struct mount *mp, *nmp;
172 register struct statfs *sp;
173 struct ostatfs osb;
174 caddr_t sfsp;
175 long count, maxcount;
176 int error, flags = SCARG(uap, flags);
177
178 maxcount = SCARG(uap, bufsize) / sizeof(struct ostatfs);
179 sfsp = (caddr_t)SCARG(uap, buf);
180 count = 0;
181
182 for (mp = CIRCLEQ_FIRST(&mountlist); mp != CIRCLEQ_END(&mountlist);
183 mp = nmp) {
184 if (vfs_busy(mp, VB_READ|VB_NOWAIT)) {
185 nmp = CIRCLEQ_NEXT(mp, mnt_list);
186 continue;
187 }
188 if (sfsp && count < maxcount) {
189 sp = &mp->mnt_stat;
190
191
192 if (flags != MNT_NOWAIT &&
193 flags != MNT_LAZY &&
194 (flags == MNT_WAIT ||
195 flags == 0) &&
196 (error = VFS_STATFS(mp, sp, p))) {
197 nmp = CIRCLEQ_NEXT(mp, mnt_list);
198 vfs_unbusy(mp);
199 continue;
200 }
201
202 statfs_to_ostatfs(p, mp, sp, &osb);
203 error = copyout((caddr_t)&osb, sfsp, sizeof(osb));
204 if (error) {
205 vfs_unbusy(mp);
206 return (error);
207 }
208 sfsp += sizeof(osb);
209 }
210 count++;
211 nmp = CIRCLEQ_NEXT(mp, mnt_list);
212 vfs_unbusy(mp);
213 }
214
215 if (sfsp && count > maxcount)
216 *retval = maxcount;
217 else
218 *retval = count;
219
220 return (0);
221 }