ultrix_fs.c revision 1.23 1 1.23 jdolecek /* $NetBSD: ultrix_fs.c,v 1.23 2002/11/02 17:05:19 jdolecek Exp $ */
2 1.1 jonathan
3 1.1 jonathan /*
4 1.12 jonathan * Copyright (c) 1995, 1997 Jonathan Stone
5 1.12 jonathan * All rights reserved.
6 1.1 jonathan *
7 1.1 jonathan * Redistribution and use in source and binary forms, with or without
8 1.1 jonathan * modification, are permitted provided that the following conditions
9 1.1 jonathan * are met:
10 1.1 jonathan * 1. Redistributions of source code must retain the above copyright
11 1.1 jonathan * notice, this list of conditions and the following disclaimer.
12 1.1 jonathan * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 jonathan * notice, this list of conditions and the following disclaimer in the
14 1.1 jonathan * documentation and/or other materials provided with the distribution.
15 1.7 jonathan * 3. All advertising materials mentioning features or use of this software
16 1.7 jonathan * must display the following acknowledgement:
17 1.8 jonathan * This product includes software developed by Jonathan Stone for
18 1.7 jonathan * the NetBSD Project.
19 1.7 jonathan * 4. The name of the author may not be used to endorse or promote products
20 1.1 jonathan * derived from this software without specific prior written permission.
21 1.1 jonathan *
22 1.1 jonathan * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
23 1.1 jonathan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 1.1 jonathan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 1.1 jonathan * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
26 1.1 jonathan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 1.1 jonathan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 1.1 jonathan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 1.1 jonathan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 1.1 jonathan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 1.1 jonathan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 1.1 jonathan * SUCH DAMAGE.
33 1.1 jonathan */
34 1.21 lukem
35 1.21 lukem #include <sys/cdefs.h>
36 1.23 jdolecek __KERNEL_RCSID(0, "$NetBSD: ultrix_fs.c,v 1.23 2002/11/02 17:05:19 jdolecek Exp $");
37 1.1 jonathan
38 1.1 jonathan #include <sys/param.h>
39 1.1 jonathan #include <sys/systm.h>
40 1.1 jonathan #include <sys/malloc.h>
41 1.2 jonathan #include <sys/exec.h>
42 1.2 jonathan #include <sys/namei.h>
43 1.1 jonathan #include <sys/mount.h>
44 1.9 jonathan #include <sys/proc.h>
45 1.2 jonathan #include <net/if.h>
46 1.2 jonathan #include <netinet/in.h>
47 1.1 jonathan
48 1.3 pk #include <nfs/rpcv2.h>
49 1.3 pk #include <nfs/nfsproto.h>
50 1.3 pk #include <nfs/nfs.h>
51 1.15 thorpej #include <nfs/nfsmount.h>
52 1.15 thorpej
53 1.15 thorpej #include <ufs/ufs/quota.h>
54 1.15 thorpej #include <ufs/ufs/ufsmount.h>
55 1.2 jonathan
56 1.2 jonathan #include <sys/syscallargs.h>
57 1.1 jonathan #include <compat/ultrix/ultrix_syscallargs.h>
58 1.9 jonathan #include <compat/common/compat_util.h>
59 1.2 jonathan
60 1.1 jonathan #define ULTRIX_MAXPATHLEN 1024
61 1.1 jonathan
62 1.1 jonathan /**
63 1.1 jonathan ** Ultrix filesystem operations: mount(), getmnt().
64 1.1 jonathan ** These are included purely so one can place an (ECOFF or ELF)
65 1.1 jonathan ** NetBSD/pmax kernel in an Ultrix root filesystem, boot it,
66 1.1 jonathan ** and over-write the Ultrix root parition with NetBSD binaries.
67 1.1 jonathan **/
68 1.1 jonathan
69 1.1 jonathan /*
70 1.1 jonathan * Ultrix file system data structure, as modified by
71 1.1 jonathan * Ultrix getmntent(). This structure is padded to 2560 bytes, for
72 1.1 jonathan * compatiblity with the size the Ultrix kernel and user apps expect.
73 1.1 jonathan */
74 1.1 jonathan struct ultrix_fs_data {
75 1.1 jonathan u_int32_t ufsd_flags; /* how mounted */
76 1.1 jonathan u_int32_t ufsd_mtsize; /* max transfer size in bytes */
77 1.1 jonathan u_int32_t ufsd_otsize; /* optimal transfer size in bytes */
78 1.1 jonathan u_int32_t ufsd_bsize; /* fs block size (bytes) for vm code */
79 1.1 jonathan u_int32_t ufsd_fstype; /* see ../h/fs_types.h */
80 1.1 jonathan u_int32_t ufsd_gtot; /* total number of gnodes */
81 1.1 jonathan u_int32_t ufsd_gfree; /* # of free gnodes */
82 1.1 jonathan u_int32_t ufsd_btot; /* total number of 1K blocks */
83 1.1 jonathan u_int32_t ufsd_bfree; /* # of free 1K blocks */
84 1.1 jonathan u_int32_t ufsd_bfreen; /* user consumable 1K blocks */
85 1.1 jonathan u_int32_t ufsd_pgthresh; /* min size in bytes before paging*/
86 1.1 jonathan int32_t ufsd_uid; /* uid that mounted me */
87 1.1 jonathan int16_t ufsd_dev; /* major/minor of fs */
88 1.1 jonathan int16_t ufsd_exroot; /* root mapping from exports */
89 1.1 jonathan char ufsd_devname[ULTRIX_MAXPATHLEN + 4]; /* name of dev */
90 1.1 jonathan char ufsd_path[ULTRIX_MAXPATHLEN + 4]; /* name of mnt point */
91 1.1 jonathan u_int32_t ufsd_nupdate; /* number of writes */
92 1.1 jonathan u_int32_t ufsd_pad[112]; /* pad to 2560 bytes. */
93 1.1 jonathan };
94 1.1 jonathan
95 1.1 jonathan /*
96 1.1 jonathan * Get statistics on mounted filesystems.
97 1.1 jonathan */
98 1.1 jonathan #if 0
99 1.1 jonathan struct ultrix_getmnt_args {
100 1.1 jonathan int32_t *start;
101 1.1 jonathan struct ultrix_fs_data *buf;
102 1.1 jonathan int32_t bufsize;
103 1.1 jonathan int32_t mode;
104 1.1 jonathan char *path;
105 1.1 jonathan };
106 1.1 jonathan
107 1.1 jonathan #endif
108 1.1 jonathan /*
109 1.1 jonathan * Ultrix getmnt() flags.
110 1.1 jonathan * The operation getmnt() should perform is incoded in the flag
111 1.1 jonathan * argument. There are two independent attributes.
112 1.1 jonathan *
113 1.1 jonathan * ULTRIX_NOSTAT_xxx will never hang, but it may not return
114 1.1 jonathan * up-to-date statistics. (For NFS clients, it returns whatever is
115 1.1 jonathan * in the cache.) ULTRIX_STAT_xxx returns up-to-date info but may
116 1.1 jonathan * hang (e.g., on dead NFS servers).
117 1.1 jonathan *
118 1.1 jonathan * ULTRIX_xxSTAT_ONE returns statistics on just one filesystem, determined
119 1.1 jonathan * by the parth argument. ULTRIX_xxSTAT_MANY ignores the path argument and
120 1.1 jonathan * returns info on as many filesystems fit in the structure.
121 1.1 jonathan * the start argument, which should be zero on the first call,
122 1.1 jonathan * can be used to iterate over all filesystems.
123 1.1 jonathan *
124 1.1 jonathan */
125 1.1 jonathan #define ULTRIX_NOSTAT_MANY 1
126 1.1 jonathan #define ULTRIX_STAT_MANY 2
127 1.1 jonathan #define ULTRIX_STAT_ONE 3
128 1.1 jonathan #define ULTRIX_NOSTAT_ONE 4
129 1.1 jonathan
130 1.1 jonathan /*
131 1.1 jonathan * Ultrix gnode-layer filesystem codes.
132 1.1 jonathan */
133 1.1 jonathan #define ULTRIX_FSTYPE_UNKNOWN 0x0
134 1.2 jonathan #define ULTRIX_FSTYPE_ULTRIX 0x1 /* Ultrix UFS: basically 4.2bsd FFS */
135 1.1 jonathan #define ULTRIX_FSTYPE_NFS 0x5 /* NFS v2 */
136 1.1 jonathan
137 1.1 jonathan /*
138 1.2 jonathan * Ultrix mount(2) options
139 1.2 jonathan */
140 1.2 jonathan #define ULTRIX_NM_RONLY 0x0001 /* mount read-only */
141 1.2 jonathan #define ULTRIX_NM_SOFT 0x0002 /* soft mount (hard is default) */
142 1.2 jonathan #define ULTRIX_NM_WSIZE 0x0004 /* set write size */
143 1.2 jonathan #define ULTRIX_NM_RSIZE 0x0008 /* set read size */
144 1.2 jonathan #define ULTRIX_NM_TIMEO 0x0010 /* set initial timeout */
145 1.2 jonathan #define ULTRIX_NM_RETRANS 0x0020 /* set number of request retrys */
146 1.2 jonathan #define ULTRIX_NM_HOSTNAME 0x0040 /* set hostname for error printf */
147 1.2 jonathan #define ULTRIX_NM_PGTHRESH 0x0080 /* set page threshold for exec */
148 1.2 jonathan #define ULTRIX_NM_INT 0x0100 /* allow hard mount keyboard interrupts */
149 1.2 jonathan #define ULTRIX_NM_NOAC 0x0200 /* don't cache attributes */
150 1.2 jonathan
151 1.11 jonathan
152 1.11 jonathan static void
153 1.11 jonathan make_ultrix_mntent __P(( struct statfs *sp, struct ultrix_fs_data *tem));
154 1.2 jonathan
155 1.2 jonathan /*
156 1.1 jonathan * Construct an Ultrix getmnt() ultrix_fs_data from the native NetBSD
157 1.1 jonathan * struct statfs.
158 1.1 jonathan */
159 1.1 jonathan static void
160 1.1 jonathan make_ultrix_mntent(sp, tem)
161 1.18 augustss struct statfs *sp;
162 1.18 augustss struct ultrix_fs_data *tem;
163 1.1 jonathan {
164 1.1 jonathan
165 1.16 perry memset(tem, 0, sizeof (*tem));
166 1.2 jonathan
167 1.2 jonathan tem->ufsd_flags = sp->f_flags; /* XXX translate */
168 1.1 jonathan tem->ufsd_mtsize = sp->f_bsize; /* XXX max transfer size */
169 1.1 jonathan tem->ufsd_otsize = sp->f_iosize;
170 1.1 jonathan tem->ufsd_bsize = sp->f_bsize;
171 1.1 jonathan /*
172 1.2 jonathan * Translate file system type. NetBSD/1.1 has f_type zero,
173 1.2 jonathan * and uses an fstype string instead.
174 1.2 jonathan * For now, map types not in Ultrix (kernfs, null, procfs...)
175 1.2 jonathan * to UFS, since Ultrix mout will try and call mount_unknown
176 1.2 jonathan * for ULTRIX_FSTYPE_UNKNOWN, but lacks a mount_unknown binary.
177 1.1 jonathan */
178 1.2 jonathan tem->ufsd_fstype = ULTRIX_FSTYPE_NFS;
179 1.2 jonathan if (strcmp(sp->f_fstypename, "ffs") == 0)
180 1.2 jonathan tem->ufsd_fstype = ULTRIX_FSTYPE_ULTRIX;
181 1.2 jonathan
182 1.2 jonathan tem->ufsd_gtot = sp->f_files; /* total "gnodes" */
183 1.4 jonathan tem->ufsd_gfree = sp->f_ffree; /* free "gnodes" */
184 1.2 jonathan tem->ufsd_btot = sp->f_blocks; /* total 1k blocks */
185 1.4 jonathan #ifdef needsmorethought /* XXX */
186 1.4 jonathan /* tem->ufsd_bfree = sp->f_bfree; */ /* free 1k blocks */
187 1.4 jonathan /* tem->ufsd_bfree = sp->f_bavail; */ /* free 1k blocks */
188 1.4 jonathan #endif
189 1.4 jonathan
190 1.2 jonathan tem->ufsd_bfreen = sp->f_bavail; /* blocks available to users */
191 1.1 jonathan tem->ufsd_pgthresh = 0; /* not relevant */
192 1.1 jonathan tem->ufsd_uid = 0; /* XXX kept where ?*/
193 1.1 jonathan tem->ufsd_dev = 0; /* ?? */
194 1.1 jonathan tem->ufsd_exroot = 0; /* ?? */
195 1.1 jonathan strncpy(tem->ufsd_path, sp->f_mntonname, ULTRIX_MAXPATHLEN);
196 1.1 jonathan strncpy(tem->ufsd_devname, sp->f_mntfromname, ULTRIX_MAXPATHLEN);
197 1.2 jonathan #if 0
198 1.2 jonathan /* In NetBSD-1.1, filesystem type is unused and always 0 */
199 1.6 christos printf("mntent: %s type %d\n", tem->ufsd_devname, tem->ufsd_fstype);
200 1.6 christos printf("mntent: %s tot %d free %d user%d\n",
201 1.2 jonathan tem->ufsd_devname, sp->f_blocks, sp->f_bfree, sp->f_bavail);
202 1.2 jonathan #endif
203 1.1 jonathan }
204 1.1 jonathan
205 1.1 jonathan int
206 1.1 jonathan ultrix_sys_getmnt(p, v, retval)
207 1.1 jonathan struct proc *p;
208 1.1 jonathan void *v;
209 1.23 jdolecek register_t *retval;
210 1.1 jonathan {
211 1.1 jonathan struct ultrix_sys_getmnt_args *uap = v;
212 1.1 jonathan struct mount *mp, *nmp;
213 1.1 jonathan struct statfs *sp;
214 1.1 jonathan struct ultrix_fs_data *sfsp;
215 1.1 jonathan char *path;
216 1.1 jonathan int mntflags;
217 1.1 jonathan int skip;
218 1.1 jonathan int start;
219 1.1 jonathan long count, maxcount;
220 1.1 jonathan int error = 0;
221 1.1 jonathan
222 1.17 simonb nmp = NULL; /* XXX keep gcc quiet */
223 1.1 jonathan path = NULL;
224 1.1 jonathan error = 0;
225 1.1 jonathan maxcount = SCARG(uap, bufsize) / sizeof(struct ultrix_fs_data);
226 1.1 jonathan sfsp = SCARG(uap, buf);
227 1.1 jonathan
228 1.1 jonathan if (SCARG(uap, mode) == ULTRIX_STAT_ONE ||
229 1.1 jonathan SCARG(uap, mode) == ULTRIX_STAT_MANY)
230 1.1 jonathan mntflags = MNT_WAIT;
231 1.1 jonathan else
232 1.1 jonathan mntflags = MNT_NOWAIT;
233 1.1 jonathan
234 1.1 jonathan if (SCARG(uap, mode) == ULTRIX_STAT_ONE || SCARG(uap, mode) == ULTRIX_NOSTAT_ONE) {
235 1.1 jonathan /*
236 1.1 jonathan * Only get info on mountpoints that matches the path
237 1.1 jonathan * provided.
238 1.1 jonathan */
239 1.1 jonathan MALLOC(path, char *, MAXPATHLEN, M_TEMP, M_WAITOK);
240 1.4 jonathan if ((error = copyinstr(SCARG(uap, path), path,
241 1.4 jonathan MAXPATHLEN, NULL)) != 0)
242 1.1 jonathan goto bad;
243 1.1 jonathan maxcount = 1;
244 1.1 jonathan } else {
245 1.1 jonathan /*
246 1.1 jonathan * Get info on any mountpoints, somewhat like readdir().
247 1.1 jonathan * Find out how many mount list entries to skip, and skip
248 1.1 jonathan * them.
249 1.1 jonathan */
250 1.4 jonathan if ((error = copyin((caddr_t)SCARG(uap, start), &start,
251 1.4 jonathan sizeof(*SCARG(uap, start)))) != 0)
252 1.1 jonathan goto bad;
253 1.15 thorpej simple_lock(&mountlist_slock);
254 1.1 jonathan for (skip = start, mp = mountlist.cqh_first;
255 1.1 jonathan mp != (void*)&mountlist && skip-- > 0; mp = nmp)
256 1.1 jonathan nmp = mp->mnt_list.cqe_next;
257 1.15 thorpej simple_unlock(&mountlist_slock);
258 1.1 jonathan }
259 1.1 jonathan
260 1.15 thorpej simple_lock(&mountlist_slock);
261 1.1 jonathan for (count = 0, mp = mountlist.cqh_first;
262 1.1 jonathan mp != (void*)&mountlist && count < maxcount; mp = nmp) {
263 1.15 thorpej if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock)) {
264 1.15 thorpej nmp = mp->mnt_list.cqe_next;
265 1.15 thorpej continue;
266 1.15 thorpej }
267 1.15 thorpej if (sfsp != NULL) {
268 1.1 jonathan struct ultrix_fs_data tem;
269 1.1 jonathan sp = &mp->mnt_stat;
270 1.1 jonathan
271 1.1 jonathan /*
272 1.1 jonathan * If requested, refresh the fsstat cache.
273 1.1 jonathan */
274 1.15 thorpej if (mntflags != MNT_WAIT &&
275 1.1 jonathan (error = VFS_STATFS(mp, sp, p)) != 0)
276 1.1 jonathan continue;
277 1.1 jonathan
278 1.1 jonathan /*
279 1.1 jonathan * XXX what does this do? -- cgd
280 1.1 jonathan */
281 1.1 jonathan sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
282 1.1 jonathan if (path == NULL ||
283 1.1 jonathan strcmp(path, sp->f_mntonname) == 0) {
284 1.1 jonathan make_ultrix_mntent(sp, &tem);
285 1.4 jonathan if ((error = copyout((caddr_t)&tem, sfsp,
286 1.4 jonathan sizeof(tem))) != 0)
287 1.1 jonathan goto bad;
288 1.1 jonathan sfsp++;
289 1.1 jonathan count++;
290 1.1 jonathan }
291 1.1 jonathan }
292 1.15 thorpej simple_lock(&mountlist_slock);
293 1.15 thorpej nmp = mp->mnt_list.cqe_next;
294 1.15 thorpej vfs_unbusy(mp);
295 1.1 jonathan }
296 1.15 thorpej simple_unlock(&mountlist_slock);
297 1.1 jonathan
298 1.1 jonathan if (sfsp != NULL && count > maxcount)
299 1.1 jonathan *retval = maxcount;
300 1.1 jonathan else
301 1.1 jonathan *retval = count;
302 1.1 jonathan
303 1.1 jonathan bad:
304 1.1 jonathan if (path)
305 1.1 jonathan FREE(path, M_TEMP);
306 1.1 jonathan return (error);
307 1.2 jonathan }
308 1.2 jonathan
309 1.2 jonathan
310 1.2 jonathan
311 1.2 jonathan /* Old-style inet sockaddr (no len field) as passed to Ultrix mount(2) */
312 1.2 jonathan struct osockaddr_in {
313 1.2 jonathan short sin_family;
314 1.2 jonathan u_short sin_port;
315 1.2 jonathan struct in_addr sin_addr;
316 1.2 jonathan char sin_zero[8];
317 1.2 jonathan };
318 1.2 jonathan
319 1.2 jonathan
320 1.2 jonathan /*
321 1.2 jonathan * fstype-dependent structure passed to Ultrix mount(2) when
322 1.2 jonathan * mounting NFS filesystems
323 1.2 jonathan */
324 1.2 jonathan struct ultrix_nfs_args {
325 1.2 jonathan struct osockaddr_in *addr; /* file server address */
326 1.3 pk void *fh; /* file handle to be mounted */
327 1.2 jonathan int flags; /* flags */
328 1.2 jonathan int wsize; /* write size in bytes */
329 1.2 jonathan int rsize; /* read size in bytes */
330 1.2 jonathan int timeo; /* initial timeout in .1 secs */
331 1.2 jonathan int retrans; /* times to retry send */
332 1.2 jonathan char *hostname; /* server's hostname */
333 1.2 jonathan char *optstr; /* string of nfs mount options*/
334 1.2 jonathan int gfs_flags; /* gnode flags (ugh) */
335 1.2 jonathan int pg_thresh; /* paging threshold ? */
336 1.2 jonathan };
337 1.2 jonathan
338 1.2 jonathan
339 1.2 jonathan /*
340 1.2 jonathan * fstype-dependent structure passed to Ultrix mount(2) when
341 1.2 jonathan * mounting local (4.2bsd FFS) filesystems
342 1.2 jonathan */
343 1.2 jonathan struct ultrix_ufs_args {
344 1.2 jonathan u_long ufs_flags; /* mount flags?*/
345 1.2 jonathan u_long ufs_pgthresh; /* minimum file size to page */
346 1.2 jonathan };
347 1.2 jonathan
348 1.2 jonathan int
349 1.2 jonathan ultrix_sys_mount(p, v, retval)
350 1.2 jonathan struct proc *p;
351 1.2 jonathan void *v;
352 1.23 jdolecek register_t *retval;
353 1.2 jonathan {
354 1.2 jonathan struct ultrix_sys_mount_args *uap = v;
355 1.2 jonathan
356 1.2 jonathan int error;
357 1.2 jonathan int otype = SCARG(uap, type);
358 1.2 jonathan char fsname[MFSNAMELEN];
359 1.2 jonathan char * fstype;
360 1.2 jonathan struct sys_mount_args nuap;
361 1.8 jonathan char *native_fstype;
362 1.2 jonathan
363 1.22 christos caddr_t usp = stackgap_init(p, 0);
364 1.2 jonathan
365 1.16 perry memset(&nuap, 0, sizeof(nuap));
366 1.2 jonathan SCARG(&nuap, flags) = 0;
367 1.2 jonathan
368 1.2 jonathan /*
369 1.2 jonathan * Translate Ultrix integer mount codes for UFS and NFS to
370 1.2 jonathan * NetBSD fstype strings. Other Ultrix filesystem types
371 1.2 jonathan * (msdos, DEC ods-2) are not supported.
372 1.8 jonathan * Copy resulting string out to userspace (on stack)
373 1.8 jonathan * so we can pass it to the native mount syscall.
374 1.2 jonathan */
375 1.2 jonathan if (otype == ULTRIX_FSTYPE_ULTRIX)
376 1.2 jonathan fstype = "ufs";
377 1.2 jonathan else if (otype == ULTRIX_FSTYPE_NFS)
378 1.2 jonathan fstype = "nfs";
379 1.2 jonathan else
380 1.2 jonathan return (EINVAL);
381 1.2 jonathan
382 1.2 jonathan /* Translate the Ultrix mount-readonly option parameter */
383 1.2 jonathan if (SCARG(uap, rdonly))
384 1.2 jonathan SCARG(&nuap, flags) |= MNT_RDONLY;
385 1.2 jonathan
386 1.2 jonathan /* Copy string-ified version of mount type back out to user space */
387 1.8 jonathan native_fstype = (char *)usp;
388 1.8 jonathan SCARG(&nuap, type) = native_fstype;
389 1.8 jonathan if ((error = copyout(fstype, native_fstype,
390 1.4 jonathan strlen(fstype)+1)) != 0) {
391 1.2 jonathan return (error);
392 1.2 jonathan }
393 1.2 jonathan usp += strlen(fstype)+1;
394 1.2 jonathan
395 1.2 jonathan #ifdef later
396 1.2 jonathan parse ultrix mount option string and set NetBSD flags
397 1.2 jonathan #endif
398 1.2 jonathan SCARG(&nuap, path) = SCARG(uap, dir);
399 1.2 jonathan
400 1.8 jonathan /*
401 1.8 jonathan * Translate fstype-dependent mount options from
402 1.8 jonathan * Ultrix format to native.
403 1.8 jonathan */
404 1.2 jonathan if (otype == ULTRIX_FSTYPE_ULTRIX) {
405 1.2 jonathan /* attempt to mount a native, rather than 4.2bsd, ffs */
406 1.2 jonathan struct ufs_args ua;
407 1.2 jonathan
408 1.2 jonathan ua.fspec = SCARG(uap, special);
409 1.16 perry memset(&ua.export, 0, sizeof(ua.export));
410 1.2 jonathan SCARG(&nuap, data) = usp;
411 1.2 jonathan
412 1.4 jonathan if ((error = copyout(&ua, SCARG(&nuap, data),
413 1.4 jonathan sizeof ua)) !=0) {
414 1.2 jonathan return(error);
415 1.2 jonathan }
416 1.2 jonathan /*
417 1.2 jonathan * Ultrix mount has no MNT_UPDATE flag.
418 1.2 jonathan * Attempt to see if this is the root we're mounting,
419 1.2 jonathan * and if so, set MNT_UPDATE so we can mount / read-write.
420 1.2 jonathan */
421 1.2 jonathan fsname[0] = 0;
422 1.4 jonathan if ((error = copyinstr((caddr_t)SCARG(&nuap, path), fsname,
423 1.20 matt sizeof fsname, NULL)) != 0)
424 1.2 jonathan return(error);
425 1.2 jonathan if (strcmp(fsname, "/") == 0) {
426 1.2 jonathan SCARG(&nuap, flags) |= MNT_UPDATE;
427 1.6 christos printf("COMPAT_ULTRIX: mount with MNT_UPDATE on %s\n",
428 1.5 christos fsname);
429 1.2 jonathan }
430 1.2 jonathan } else if (otype == ULTRIX_FSTYPE_NFS) {
431 1.2 jonathan struct ultrix_nfs_args una;
432 1.2 jonathan struct nfs_args na;
433 1.2 jonathan struct osockaddr_in osa;
434 1.2 jonathan struct sockaddr_in *sap = (struct sockaddr_in *)& osa;
435 1.2 jonathan
436 1.16 perry memset(&osa, 0, sizeof(osa));
437 1.16 perry memset(&una, 0, sizeof(una));
438 1.4 jonathan if ((error = copyin(SCARG(uap, data), &una, sizeof una)) !=0) {
439 1.2 jonathan return (error);
440 1.2 jonathan }
441 1.2 jonathan /*
442 1.2 jonathan * This is the only syscall boundary the
443 1.2 jonathan * address of the server passes, so do backwards
444 1.2 jonathan * compatibility on 4.3style sockaddrs here.
445 1.2 jonathan */
446 1.4 jonathan if ((error = copyin(una.addr, &osa, sizeof osa)) != 0) {
447 1.6 christos printf("ultrix_mount: nfs copyin osa\n");
448 1.2 jonathan return (error);
449 1.2 jonathan }
450 1.2 jonathan sap->sin_family = (u_char)osa.sin_family;
451 1.2 jonathan sap->sin_len = sizeof(*sap);
452 1.2 jonathan /* allocate space above caller's stack for nfs_args */
453 1.2 jonathan SCARG(&nuap, data) = usp;
454 1.2 jonathan usp += sizeof (na);
455 1.2 jonathan /* allocate space above caller's stack for server sockaddr */
456 1.3 pk na.version = NFS_ARGSVERSION;
457 1.2 jonathan na.addr = (struct sockaddr *)usp;
458 1.2 jonathan usp += sizeof(*sap);
459 1.2 jonathan na.addrlen = sap->sin_len;
460 1.2 jonathan na.sotype = SOCK_DGRAM;
461 1.2 jonathan na.proto = IPPROTO_UDP;
462 1.2 jonathan na.fh = una.fh;
463 1.3 pk na.fhsize = NFSX_V2FH;
464 1.2 jonathan na.flags = /*una.flags;*/ NFSMNT_NOCONN | NFSMNT_RESVPORT;
465 1.2 jonathan na.wsize = una.wsize;
466 1.2 jonathan na.rsize = una.rsize;
467 1.2 jonathan na.timeo = una.timeo;
468 1.2 jonathan na.retrans = una.retrans;
469 1.2 jonathan na.hostname = una.hostname;
470 1.4 jonathan if ((error = copyout(sap, na.addr, sizeof (*sap) )) != 0)
471 1.2 jonathan return (error);
472 1.4 jonathan if ((error = copyout(&na, SCARG(&nuap, data), sizeof na)) != 0)
473 1.2 jonathan return (error);
474 1.2 jonathan }
475 1.2 jonathan return (sys_mount(p, &nuap, retval));
476 1.1 jonathan }
477