This source file includes following definitions.
- osf1_sys_fstatfs
- osf1_sys_getfsstat
- osf1_sys_mount
- osf1_sys_statfs
- osf1_sys_unmount
- osf1_mount_mfs
- osf1_mount_nfs
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61 #include <sys/param.h>
62 #include <sys/systm.h>
63 #include <sys/namei.h>
64 #include <sys/proc.h>
65 #include <sys/file.h>
66 #include <sys/filedesc.h>
67 #include <sys/kernel.h>
68 #include <sys/mount.h>
69 #include <sys/vnode.h>
70 #include <sys/syscallargs.h>
71
72 #include <compat/osf1/osf1.h>
73 #include <compat/osf1/osf1_syscallargs.h>
74 #include <compat/osf1/osf1_util.h>
75 #include <compat/osf1/osf1_cvt.h>
76
77 #include <net/if.h>
78 #include <netinet/in.h>
79
80 #include <nfs/rpcv2.h>
81 #include <nfs/nfsproto.h>
82 #include <nfs/nfs.h>
83 #include <nfs/nfsmount.h>
84
85 #include <ufs/ufs/quota.h>
86 #include <ufs/ufs/ufsmount.h>
87
88 #include <machine/vmparam.h>
89
90 #define OSF1_MNT_WAIT 0x1
91 #define OSF1_MNT_NOWAIT 0x2
92
93 #define OSF1_MNT_FORCE 0x1
94 #define OSF1_MNT_NOFORCE 0x2
95
96
97 #define OSF1_GETFSSTAT_FLAGS (OSF1_MNT_WAIT|OSF1_MNT_NOWAIT)
98 #define OSF1_MOUNT_FLAGS 0xffffffff
99 #define OSF1_UNMOUNT_FLAGS (OSF1_MNT_FORCE|OSF1_MNT_NOFORCE)
100
101
102 static int osf1_mount_mfs(struct proc *,
103 struct osf1_sys_mount_args *, struct sys_mount_args *);
104 static int osf1_mount_nfs(struct proc *,
105 struct osf1_sys_mount_args *, struct sys_mount_args *);
106
107 int
108 osf1_sys_fstatfs(p, v, retval)
109 struct proc *p;
110 void *v;
111 register_t *retval;
112 {
113 struct osf1_sys_fstatfs_args *uap = v;
114 struct file *fp;
115 struct mount *mp;
116 struct statfs *sp;
117 struct osf1_statfs osfs;
118 int error;
119
120 if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)))
121 return (error);
122 mp = ((struct vnode *)fp->f_data)->v_mount;
123 sp = &mp->mnt_stat;
124 error = VFS_STATFS(mp, sp, p);
125 FRELE(fp);
126 if (error)
127 goto out;
128 sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
129 osf1_cvt_statfs_from_native(sp, &osfs);
130 error = copyout(&osfs, SCARG(uap, buf), min(sizeof osfs,
131 SCARG(uap, len)));
132 out:
133 return (error);
134 }
135
136 int
137 osf1_sys_getfsstat(p, v, retval)
138 struct proc *p;
139 void *v;
140 register_t *retval;
141 {
142 struct osf1_sys_getfsstat_args *uap = v;
143 struct mount *mp, *nmp;
144 struct statfs *sp;
145 struct osf1_statfs osfs;
146 caddr_t osf_sfsp;
147 long count, maxcount, error;
148
149 if (SCARG(uap, flags) & ~OSF1_GETFSSTAT_FLAGS)
150 return (EINVAL);
151
152 maxcount = SCARG(uap, bufsize) / sizeof(struct osf1_statfs);
153 osf_sfsp = (caddr_t)SCARG(uap, buf);
154 count = 0;
155 for (mp = CIRCLEQ_FIRST(&mountlist); mp != CIRCLEQ_END(&mountlist);
156 mp = nmp) {
157 nmp = CIRCLEQ_NEXT(mp, mnt_list);
158 if (osf_sfsp && count < maxcount) {
159 sp = &mp->mnt_stat;
160
161
162
163
164
165 if (((SCARG(uap, flags) & OSF1_MNT_NOWAIT) == 0 ||
166 (SCARG(uap, flags) & OSF1_MNT_WAIT)) &&
167 (error = VFS_STATFS(mp, sp, p)))
168 continue;
169 sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
170 osf1_cvt_statfs_from_native(sp, &osfs);
171 if ((error = copyout(&osfs, osf_sfsp,
172 sizeof (struct osf1_statfs))))
173 return (error);
174 osf_sfsp += sizeof (struct osf1_statfs);
175 }
176 count++;
177 }
178 if (osf_sfsp && count > maxcount)
179 *retval = maxcount;
180 else
181 *retval = count;
182 return (0);
183 }
184
185 int
186 osf1_sys_mount(p, v, retval)
187 struct proc *p;
188 void *v;
189 register_t *retval;
190 {
191 struct osf1_sys_mount_args *uap = v;
192 struct sys_mount_args a;
193 int error;
194
195 SCARG(&a, path) = SCARG(uap, path);
196
197 if (SCARG(uap, flags) & ~OSF1_MOUNT_FLAGS)
198 return (EINVAL);
199 SCARG(&a, flags) = SCARG(uap, flags);
200
201 switch (SCARG(uap, type)) {
202 case OSF1_MOUNT_NFS:
203 if ((error = osf1_mount_nfs(p, uap, &a)))
204 return error;
205 break;
206
207 case OSF1_MOUNT_MFS:
208 if ((error = osf1_mount_mfs(p, uap, &a)))
209 return error;
210 break;
211
212 default:
213 return (EINVAL);
214 }
215
216 return sys_mount(p, &a, retval);
217 }
218
219 int
220 osf1_sys_statfs(p, v, retval)
221 struct proc *p;
222 void *v;
223 register_t *retval;
224 {
225 struct osf1_sys_statfs_args *uap = v;
226 struct mount *mp;
227 struct statfs *sp;
228 struct osf1_statfs osfs;
229 int error;
230 struct nameidata nd;
231
232 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
233 if ((error = namei(&nd)))
234 return (error);
235 mp = nd.ni_vp->v_mount;
236 sp = &mp->mnt_stat;
237 vrele(nd.ni_vp);
238 if ((error = VFS_STATFS(mp, sp, p)))
239 return (error);
240 sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
241 osf1_cvt_statfs_from_native(sp, &osfs);
242 return copyout(&osfs, SCARG(uap, buf), min(sizeof osfs,
243 SCARG(uap, len)));
244 }
245
246 int
247 osf1_sys_unmount(p, v, retval)
248 struct proc *p;
249 void *v;
250 register_t *retval;
251 {
252 struct osf1_sys_unmount_args *uap = v;
253 struct sys_unmount_args a;
254
255 SCARG(&a, path) = SCARG(uap, path);
256
257 if (SCARG(uap, flags) & ~OSF1_UNMOUNT_FLAGS)
258 return (EINVAL);
259 SCARG(&a, flags) = 0;
260 if ((SCARG(uap, flags) & OSF1_MNT_FORCE) &&
261 (SCARG(uap, flags) & OSF1_MNT_NOFORCE) == 0)
262 SCARG(&a, flags) |= MNT_FORCE;
263
264 return sys_unmount(p, &a, retval);
265 }
266
267 static int
268 osf1_mount_mfs(p, osf_argp, bsd_argp)
269 struct proc *p;
270 struct osf1_sys_mount_args *osf_argp;
271 struct sys_mount_args *bsd_argp;
272 {
273 struct osf1_mfs_args osf_ma;
274 struct mfs_args bsd_ma;
275 caddr_t sg = stackgap_init(p->p_emul);
276 int error, len;
277 static const char mfs_name[] = MOUNT_MFS;
278
279 if ((error = copyin(SCARG(osf_argp, data), &osf_ma, sizeof osf_ma)))
280 return error;
281
282 memset(&bsd_ma, 0, sizeof bsd_ma);
283 bsd_ma.fspec = osf_ma.name;
284
285 bsd_ma.base = osf_ma.base;
286 bsd_ma.size = osf_ma.size;
287
288 SCARG(bsd_argp, data) = stackgap_alloc(&sg, sizeof bsd_ma);
289 if ((error = copyout(&bsd_ma, SCARG(bsd_argp, data), sizeof bsd_ma)))
290 return error;
291
292 len = strlen(mfs_name) + 1;
293 SCARG(bsd_argp, type) = stackgap_alloc(&sg, len);
294 if ((error = copyout(mfs_name, (void *)SCARG(bsd_argp, type), len)))
295 return error;
296
297 return 0;
298 }
299
300 static int
301 osf1_mount_nfs(p, osf_argp, bsd_argp)
302 struct proc *p;
303 struct osf1_sys_mount_args *osf_argp;
304 struct sys_mount_args *bsd_argp;
305 {
306 struct osf1_nfs_args osf_na;
307 struct nfs_args bsd_na;
308 caddr_t sg = stackgap_init(p->p_emul);
309 int error, len;
310 static const char nfs_name[] = MOUNT_NFS;
311 unsigned long leftovers;
312
313 if ((error = copyin(SCARG(osf_argp, data), &osf_na, sizeof osf_na)))
314 return error;
315
316 memset(&bsd_na, 0, sizeof bsd_na);
317 bsd_na.addr = (struct sockaddr *)osf_na.addr;
318 bsd_na.addrlen = sizeof (struct sockaddr_in);
319 bsd_na.fh = osf_na.fh;
320
321
322 bsd_na.flags = emul_flags_translate(osf1_nfs_mount_flags_xtab,
323 osf_na.flags, &leftovers);
324 if (leftovers & OSF1_NFSMNT_HOSTNAME) {
325 leftovers &= ~OSF1_NFSMNT_HOSTNAME;
326 bsd_na.hostname = osf_na.hostname;
327 } else {
328
329 }
330 if (leftovers & OSF1_NFSMNT_TCP) {
331 leftovers &= ~OSF1_NFSMNT_TCP;
332 bsd_na.sotype = SOCK_DGRAM;
333 bsd_na.proto = 0;
334 } else {
335 bsd_na.sotype = SOCK_STREAM;
336 bsd_na.proto = 0;
337 }
338 if (leftovers != 0)
339 return (EINVAL);
340
341
342 if (bsd_na.flags & NFSMNT_WSIZE)
343 bsd_na.wsize = osf_na.wsize;
344 if (bsd_na.flags & NFSMNT_RSIZE)
345 bsd_na.rsize = osf_na.rsize;
346 if (bsd_na.flags & NFSMNT_TIMEO)
347 bsd_na.timeo = osf_na.timeo;
348 if (bsd_na.flags & NFSMNT_RETRANS)
349 bsd_na.retrans = osf_na.retrans;
350
351 SCARG(bsd_argp, data) = stackgap_alloc(&sg, sizeof bsd_na);
352 if ((error = copyout(&bsd_na, SCARG(bsd_argp, data), sizeof bsd_na)))
353 return error;
354
355 len = strlen(nfs_name) + 1;
356 SCARG(bsd_argp, type) = stackgap_alloc(&sg, len);
357 if ((error = copyout(MOUNT_NFS, (void *)SCARG(bsd_argp, type), len)))
358 return error;
359
360 return 0;
361 }