This source file includes following definitions.
- make_ultrix_mntent
- ultrix_sys_getmnt
- ultrix_sys_mount
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 #include <sys/param.h>
33 #include <sys/systm.h>
34 #include <sys/malloc.h>
35 #include <sys/exec.h>
36 #include <sys/namei.h>
37 #include <sys/mount.h>
38 #include <net/if.h>
39 #include <netinet/in.h>
40
41 #include <nfs/rpcv2.h>
42 #include <nfs/nfsproto.h>
43 #include <nfs/nfs.h>
44
45 #include <sys/syscallargs.h>
46 #include <compat/ultrix/ultrix_syscallargs.h>
47
48 #include <uvm/uvm_extern.h>
49
50 #define ULTRIX_MAXPATHLEN 1024
51
52
53
54
55
56
57
58
59
60
61
62
63
64 struct ultrix_fs_data {
65 u_int32_t ufsd_flags;
66 u_int32_t ufsd_mtsize;
67 u_int32_t ufsd_otsize;
68 u_int32_t ufsd_bsize;
69 u_int32_t ufsd_fstype;
70 u_int32_t ufsd_gtot;
71 u_int32_t ufsd_gfree;
72 u_int32_t ufsd_btot;
73 u_int32_t ufsd_bfree;
74 u_int32_t ufsd_bfreen;
75 u_int32_t ufsd_pgthresh;
76 int32_t ufsd_uid;
77 int16_t ufsd_dev;
78 int16_t ufsd_exroot;
79 char ufsd_devname[ULTRIX_MAXPATHLEN + 4];
80 char ufsd_path[ULTRIX_MAXPATHLEN + 4];
81 u_int32_t ufsd_nupdate;
82 u_int32_t ufsd_pad[112];
83 };
84
85
86
87
88 #if 0
89 struct ultrix_getmnt_args {
90 int32_t *start;
91 struct ultrix_fs_data *buf;
92 int32_t bufsize;
93 int32_t mode;
94 char *path;
95 };
96
97 #endif
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115 #define ULTRIX_NOSTAT_MANY 1
116 #define ULTRIX_STAT_MANY 2
117 #define ULTRIX_STAT_ONE 3
118 #define ULTRIX_NOSTAT_ONE 4
119
120
121
122
123 #define ULTRIX_FSTYPE_UNKNOWN 0x0
124 #define ULTRIX_FSTYPE_ULTRIX 0x1
125 #define ULTRIX_FSTYPE_NFS 0x5
126
127
128
129
130 #define ULTRIX_NM_RONLY 0x0001
131 #define ULTRIX_NM_SOFT 0x0002
132 #define ULTRIX_NM_WSIZE 0x0004
133 #define ULTRIX_NM_RSIZE 0x0008
134 #define ULTRIX_NM_TIMEO 0x0010
135 #define ULTRIX_NM_RETRANS 0x0020
136 #define ULTRIX_NM_HOSTNAME 0x0040
137 #define ULTRIX_NM_PGTHRESH 0x0080
138 #define ULTRIX_NM_INT 0x0100
139 #define ULTRIX_NM_NOAC 0x0200
140
141
142
143
144
145
146 static void
147 make_ultrix_mntent(sp, tem)
148 register struct statfs *sp;
149 register struct ultrix_fs_data *tem;
150 {
151
152 bzero(tem, sizeof (*tem));
153
154 tem->ufsd_flags = sp->f_flags;
155 tem->ufsd_mtsize = sp->f_bsize;
156 tem->ufsd_otsize = sp->f_iosize;
157 tem->ufsd_bsize = sp->f_bsize;
158
159
160
161
162
163
164
165 tem->ufsd_fstype = ULTRIX_FSTYPE_NFS;
166 if (strcmp(sp->f_fstypename, "ffs") == 0)
167 tem->ufsd_fstype = ULTRIX_FSTYPE_ULTRIX;
168
169 tem->ufsd_gtot = sp->f_files;
170 tem->ufsd_gfree = sp->f_ffree;
171 tem->ufsd_btot = sp->f_blocks;
172 #ifdef needsmorethought
173
174
175 #endif
176
177 tem->ufsd_bfreen = sp->f_bavail;
178 tem->ufsd_pgthresh = 0;
179 tem->ufsd_uid = 0;
180 tem->ufsd_dev = 0;
181 tem->ufsd_exroot = 0;
182 strlcpy(tem->ufsd_path, sp->f_mntonname, sizeof(tem->ufsd_path));
183 strlcpy(tem->ufsd_devname, sp->f_mntfromname,
184 sizeof(tem->ufsd_devname));
185 #if 0
186
187 printf("mntent: %s type %d\n", tem->ufsd_devname, tem->ufsd_fstype);
188 printf("mntent: %s tot %d free %d user%d\n",
189 tem->ufsd_devname, sp->f_blocks, sp->f_bfree, sp->f_bavail);
190 #endif
191 }
192
193 int
194 ultrix_sys_getmnt(p, v, retval)
195 struct proc *p;
196 void *v;
197 int *retval;
198 {
199 struct ultrix_sys_getmnt_args *uap = v;
200 struct mount *mp, *nmp;
201 struct statfs *sp;
202 struct ultrix_fs_data *sfsp;
203 char *path;
204 int mntflags;
205 int skip;
206 int start;
207 long count, maxcount;
208 int error = 0;
209
210 path = NULL;
211 error = 0;
212 maxcount = SCARG(uap, bufsize) / sizeof(struct ultrix_fs_data);
213 sfsp = SCARG(uap, buf);
214
215 if (SCARG(uap, mode) == ULTRIX_STAT_ONE ||
216 SCARG(uap, mode) == ULTRIX_STAT_MANY)
217 mntflags = MNT_WAIT;
218 else
219 mntflags = MNT_NOWAIT;
220
221 if (SCARG(uap, mode) == ULTRIX_STAT_ONE || SCARG(uap, mode) == ULTRIX_NOSTAT_ONE) {
222
223
224
225
226 MALLOC(path, char *, MAXPATHLEN, M_TEMP, M_WAITOK);
227 if ((error = copyinstr(SCARG(uap, path), path,
228 MAXPATHLEN, NULL)) != 0)
229 goto bad;
230 maxcount = 1;
231 } else {
232
233
234
235
236
237 if ((error = copyin((caddr_t)SCARG(uap, start), &start,
238 sizeof(*SCARG(uap, start)))) != 0)
239 goto bad;
240 for (skip = start, mp = CIRCLEQ_FIRST(&mountlist);
241 mp != CIRCLEQ_END(&mountlist) && skip-- > 0; mp = nmp)
242 nmp = CIRCLEQ_NEXT(mp, mnt_list);
243 }
244
245 for (count = 0, mp = CIRCLEQ_FIRST(&mountlist);
246 mp != CIRCLEQ_END(&mountlist) && count < maxcount; mp = nmp) {
247 nmp = CIRCLEQ_NEXT(mp, mnt_list);
248 if (sfsp != NULL) {
249 struct ultrix_fs_data tem;
250 sp = &mp->mnt_stat;
251
252
253
254
255 if ((mntflags & MNT_WAIT) != 0 &&
256 (error = VFS_STATFS(mp, sp, p)) != 0)
257 continue;
258
259
260
261
262 sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
263 if (path == NULL ||
264 strcmp(path, sp->f_mntonname) == 0) {
265 make_ultrix_mntent(sp, &tem);
266 if ((error = copyout((caddr_t)&tem, sfsp,
267 sizeof(tem))) != 0)
268 goto bad;
269 sfsp++;
270 count++;
271 }
272 }
273 }
274
275 if (sfsp != NULL && count > maxcount)
276 *retval = maxcount;
277 else
278 *retval = count;
279
280 bad:
281 if (path)
282 FREE(path, M_TEMP);
283 return (error);
284 }
285
286
287
288
289 struct osockaddr_in {
290 short sin_family;
291 u_short sin_port;
292 struct in_addr sin_addr;
293 char sin_zero[8];
294 };
295
296
297
298
299
300
301 struct ultrix_nfs_args {
302 struct osockaddr_in *addr;
303 void *fh;
304 int flags;
305 int wsize;
306 int rsize;
307 int timeo;
308 int retrans;
309 char *hostname;
310 char *optstr;
311 int gfs_flags;
312 int pg_thresh;
313 };
314
315
316
317
318
319
320 struct ultrix_ufs_args {
321 u_long ufs_flags;
322 u_long ufs_pgthresh;
323 };
324
325 int
326 ultrix_sys_mount(p, v, retval)
327 struct proc *p;
328 void *v;
329 int *retval;
330 {
331 struct ultrix_sys_mount_args *uap = v;
332
333 int error;
334 int otype = SCARG(uap, type);
335 char fsname[MFSNAMELEN];
336 char * fstype;
337 struct sys_mount_args nuap;
338 caddr_t sg = stackgap_init(p->p_emul);
339 caddr_t usp = stackgap_alloc(&sg, 1024 );
340
341 bzero(&nuap, sizeof(nuap));
342 SCARG(&nuap, flags) = 0;
343
344
345
346
347
348
349 if (otype == ULTRIX_FSTYPE_ULTRIX)
350 fstype = "ufs";
351 else if (otype == ULTRIX_FSTYPE_NFS)
352 fstype = "nfs";
353 else
354 return (EINVAL);
355
356
357 if (SCARG(uap, rdonly))
358 SCARG(&nuap, flags) |= MNT_RDONLY;
359
360
361 SCARG(&nuap, type) = (char *)usp;
362 if ((error = copyout(fstype, (void *)SCARG(&nuap, type),
363 strlen(fstype)+1)) != 0) {
364 return (error);
365 }
366 usp += strlen(fstype)+1;
367
368 #ifdef later
369 parse ultrix mount option string and set NetBSD flags
370 #endif
371 SCARG(&nuap, path) = SCARG(uap, dir);
372
373 if (otype == ULTRIX_FSTYPE_ULTRIX) {
374
375 struct ufs_args ua;
376
377 ua.fspec = SCARG(uap, special);
378 bzero(&ua.export_info, sizeof(ua.export_info));
379 SCARG(&nuap, data) = usp;
380
381 if ((error = copyout(&ua, SCARG(&nuap, data),
382 sizeof ua)) !=0) {
383 return(error);
384 }
385
386
387
388
389
390 fsname[0] = 0;
391 if ((error = copyinstr((caddr_t)SCARG(&nuap, path), fsname,
392 sizeof fsname, (u_int *)0)) != 0)
393 return(error);
394 if (strcmp(fsname, "/") == 0) {
395 SCARG(&nuap, flags) |= MNT_UPDATE;
396 printf("COMPAT_ULTRIX: mount with MNT_UPDATE on %s\n",
397 fsname);
398 }
399 } else if (otype == ULTRIX_FSTYPE_NFS) {
400 struct ultrix_nfs_args una;
401 struct nfs_args na;
402 struct osockaddr_in osa;
403 struct sockaddr_in *sap = (struct sockaddr_in *)& osa;
404
405 bzero(&osa, sizeof(osa));
406 bzero(&una, sizeof(una));
407 if ((error = copyin(SCARG(uap, data), &una, sizeof una)) !=0) {
408 return (error);
409 }
410
411
412
413
414
415 if ((error = copyin(una.addr, &osa, sizeof osa)) != 0) {
416 printf("ultrix_mount: nfs copyin osa\n");
417 return (error);
418 }
419 sap->sin_family = (u_char)osa.sin_family;
420 sap->sin_len = sizeof(*sap);
421
422 SCARG(&nuap, data) = usp;
423 usp += sizeof (na);
424
425 na.version = NFS_ARGSVERSION;
426 na.addr = (struct sockaddr *)usp;
427 usp += sizeof(*sap);
428 na.addrlen = sap->sin_len;
429 na.sotype = SOCK_DGRAM;
430 na.proto = IPPROTO_UDP;
431 na.fh = una.fh;
432 na.fhsize = NFSX_V2FH;
433 na.flags = NFSMNT_NOCONN;
434 na.wsize = una.wsize;
435 na.rsize = una.rsize;
436 na.timeo = una.timeo;
437 na.retrans = una.retrans;
438 na.hostname = una.hostname;
439 if ((error = copyout(sap, na.addr, sizeof (*sap) )) != 0)
440 return (error);
441 if ((error = copyout(&na, SCARG(&nuap, data), sizeof na)) != 0)
442 return (error);
443 }
444 return (sys_mount(p, &nuap, retval));
445 }