sunos_misc.c revision 1.9.2.9 1 1.1 deraadt /*
2 1.1 deraadt * Copyright (c) 1992, 1993
3 1.1 deraadt * The Regents of the University of California. All rights reserved.
4 1.1 deraadt *
5 1.1 deraadt * This software was developed by the Computer Systems Engineering group
6 1.1 deraadt * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
7 1.1 deraadt * contributed to Berkeley.
8 1.1 deraadt *
9 1.1 deraadt * All advertising materials mentioning features or use of this software
10 1.1 deraadt * must display the following acknowledgement:
11 1.1 deraadt * This product includes software developed by the University of
12 1.1 deraadt * California, Lawrence Berkeley Laboratory.
13 1.1 deraadt *
14 1.1 deraadt * Redistribution and use in source and binary forms, with or without
15 1.1 deraadt * modification, are permitted provided that the following conditions
16 1.1 deraadt * are met:
17 1.1 deraadt * 1. Redistributions of source code must retain the above copyright
18 1.1 deraadt * notice, this list of conditions and the following disclaimer.
19 1.1 deraadt * 2. Redistributions in binary form must reproduce the above copyright
20 1.1 deraadt * notice, this list of conditions and the following disclaimer in the
21 1.1 deraadt * documentation and/or other materials provided with the distribution.
22 1.1 deraadt * 3. All advertising materials mentioning features or use of this software
23 1.1 deraadt * must display the following acknowledgement:
24 1.1 deraadt * This product includes software developed by the University of
25 1.1 deraadt * California, Berkeley and its contributors.
26 1.1 deraadt * 4. Neither the name of the University nor the names of its contributors
27 1.1 deraadt * may be used to endorse or promote products derived from this software
28 1.1 deraadt * without specific prior written permission.
29 1.1 deraadt *
30 1.1 deraadt * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
31 1.1 deraadt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 1.1 deraadt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 1.1 deraadt * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
34 1.1 deraadt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35 1.1 deraadt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
36 1.1 deraadt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
37 1.1 deraadt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38 1.1 deraadt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
39 1.1 deraadt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 1.1 deraadt * SUCH DAMAGE.
41 1.1 deraadt *
42 1.1 deraadt * @(#)sun_misc.c 8.1 (Berkeley) 6/18/93
43 1.1 deraadt *
44 1.1 deraadt * from: Header: sun_misc.c,v 1.16 93/04/07 02:46:27 torek Exp
45 1.9.2.9 pk * $Id: sunos_misc.c,v 1.9.2.9 1993/12/01 15:19:57 pk Exp $
46 1.1 deraadt */
47 1.1 deraadt
48 1.1 deraadt /*
49 1.1 deraadt * SunOS compatibility module.
50 1.1 deraadt *
51 1.1 deraadt * SunOS system calls that are implemented differently in BSD are
52 1.1 deraadt * handled here.
53 1.1 deraadt */
54 1.1 deraadt
55 1.1 deraadt #include <sys/param.h>
56 1.1 deraadt #include <sys/systm.h>
57 1.9.2.8 deraadt #include <sys/namei.h>
58 1.4 deraadt #include <ufs/dir.h>
59 1.1 deraadt #include <sys/proc.h>
60 1.1 deraadt #include <sys/file.h>
61 1.9.2.9 pk #include <sys/stat.h>
62 1.1 deraadt #include <sys/filedesc.h>
63 1.1 deraadt #include <sys/ioctl.h>
64 1.8 deraadt #include <sys/kernel.h>
65 1.9.2.1 deraadt #include <sys/exec.h>
66 1.1 deraadt #include <sys/malloc.h>
67 1.1 deraadt #include <sys/mbuf.h>
68 1.1 deraadt #include <sys/mman.h>
69 1.1 deraadt #include <sys/mount.h>
70 1.1 deraadt #include <sys/resource.h>
71 1.1 deraadt #include <sys/resourcevar.h>
72 1.1 deraadt #include <sys/signal.h>
73 1.1 deraadt #include <sys/signalvar.h>
74 1.1 deraadt #include <sys/socket.h>
75 1.1 deraadt #include <sys/vnode.h>
76 1.1 deraadt #include <sys/uio.h>
77 1.1 deraadt #include <sys/wait.h>
78 1.8 deraadt #include <sys/utsname.h>
79 1.1 deraadt
80 1.9.2.1 deraadt #include <netinet/in.h>
81 1.9.2.1 deraadt
82 1.7 deraadt #include <miscfs/specfs/specdev.h>
83 1.1 deraadt
84 1.1 deraadt #include <vm/vm.h>
85 1.1 deraadt
86 1.1 deraadt struct sun_wait4_args {
87 1.1 deraadt int pid;
88 1.1 deraadt int *status;
89 1.1 deraadt int options;
90 1.1 deraadt struct rusage *rusage;
91 1.1 deraadt };
92 1.1 deraadt sun_wait4(p, uap, retval)
93 1.1 deraadt struct proc *p;
94 1.1 deraadt struct sun_wait4_args *uap;
95 1.1 deraadt int *retval;
96 1.1 deraadt {
97 1.1 deraadt
98 1.1 deraadt if (uap->pid == 0)
99 1.1 deraadt uap->pid = WAIT_ANY;
100 1.1 deraadt return (wait4(p, uap, retval));
101 1.1 deraadt }
102 1.1 deraadt
103 1.1 deraadt struct sun_creat_args {
104 1.1 deraadt char *fname;
105 1.1 deraadt int fmode;
106 1.1 deraadt };
107 1.1 deraadt sun_creat(p, uap, retval)
108 1.1 deraadt struct proc *p;
109 1.1 deraadt struct sun_creat_args *uap;
110 1.1 deraadt int *retval;
111 1.1 deraadt {
112 1.1 deraadt struct args {
113 1.1 deraadt char *fname;
114 1.1 deraadt int mode;
115 1.1 deraadt int crtmode;
116 1.1 deraadt } openuap;
117 1.1 deraadt
118 1.1 deraadt openuap.fname = uap->fname;
119 1.1 deraadt openuap.crtmode = uap->fmode;
120 1.1 deraadt openuap.mode = O_WRONLY | O_CREAT | O_TRUNC;
121 1.1 deraadt return (open(p, &openuap, retval));
122 1.1 deraadt }
123 1.1 deraadt
124 1.1 deraadt struct sun_execv_args {
125 1.1 deraadt char *fname;
126 1.1 deraadt char **argp;
127 1.1 deraadt char **envp; /* pseudo */
128 1.1 deraadt };
129 1.1 deraadt sun_execv(p, uap, retval)
130 1.1 deraadt struct proc *p;
131 1.1 deraadt struct sun_execv_args *uap;
132 1.1 deraadt int *retval;
133 1.1 deraadt {
134 1.1 deraadt
135 1.1 deraadt uap->envp = NULL;
136 1.1 deraadt return (execve(p, uap, retval));
137 1.1 deraadt }
138 1.1 deraadt
139 1.1 deraadt struct sun_omsync_args {
140 1.1 deraadt caddr_t addr;
141 1.1 deraadt int len;
142 1.1 deraadt int flags;
143 1.1 deraadt };
144 1.1 deraadt sun_omsync(p, uap, retval)
145 1.1 deraadt struct proc *p;
146 1.1 deraadt struct sun_omsync_args *uap;
147 1.1 deraadt int *retval;
148 1.1 deraadt {
149 1.1 deraadt
150 1.1 deraadt if (uap->flags)
151 1.1 deraadt return (EINVAL);
152 1.1 deraadt return (msync(p, uap, retval));
153 1.1 deraadt }
154 1.1 deraadt
155 1.1 deraadt struct sun_unmount_args {
156 1.1 deraadt char *name;
157 1.1 deraadt int flags; /* pseudo */
158 1.1 deraadt };
159 1.1 deraadt sun_unmount(p, uap, retval)
160 1.1 deraadt struct proc *p;
161 1.1 deraadt struct sun_unmount_args *uap;
162 1.1 deraadt int *retval;
163 1.1 deraadt {
164 1.1 deraadt
165 1.1 deraadt uap->flags = 0;
166 1.1 deraadt return (unmount(p, uap, retval));
167 1.1 deraadt }
168 1.1 deraadt
169 1.1 deraadt static int
170 1.1 deraadt gettype(tptr)
171 1.1 deraadt int *tptr;
172 1.1 deraadt {
173 1.1 deraadt int type, error;
174 1.1 deraadt char in[20];
175 1.1 deraadt
176 1.1 deraadt if (error = copyinstr((caddr_t)*tptr, in, sizeof in, (u_int *)0))
177 1.1 deraadt return (error);
178 1.1 deraadt if (strcmp(in, "4.2") == 0 || strcmp(in, "ufs") == 0)
179 1.1 deraadt type = MOUNT_UFS;
180 1.1 deraadt else if (strcmp(in, "nfs") == 0)
181 1.1 deraadt type = MOUNT_NFS;
182 1.1 deraadt else
183 1.1 deraadt return (EINVAL);
184 1.1 deraadt *tptr = type;
185 1.1 deraadt return (0);
186 1.1 deraadt }
187 1.1 deraadt
188 1.1 deraadt #define SUNM_RDONLY 0x01 /* mount fs read-only */
189 1.1 deraadt #define SUNM_NOSUID 0x02 /* mount fs with setuid disallowed */
190 1.1 deraadt #define SUNM_NEWTYPE 0x04 /* type is string (char *), not int */
191 1.1 deraadt #define SUNM_GRPID 0x08 /* (bsd semantics; ignored) */
192 1.1 deraadt #define SUNM_REMOUNT 0x10 /* update existing mount */
193 1.1 deraadt #define SUNM_NOSUB 0x20 /* prevent submounts (rejected) */
194 1.1 deraadt #define SUNM_MULTI 0x40 /* (ignored) */
195 1.1 deraadt #define SUNM_SYS5 0x80 /* Sys 5-specific semantics (rejected) */
196 1.1 deraadt
197 1.9.2.1 deraadt struct sun_nfs_args {
198 1.9.2.1 deraadt struct sockaddr_in *addr; /* file server address */
199 1.9.2.1 deraadt caddr_t fh; /* file handle to be mounted */
200 1.9.2.1 deraadt int flags; /* flags */
201 1.9.2.1 deraadt int wsize; /* write size in bytes */
202 1.9.2.1 deraadt int rsize; /* read size in bytes */
203 1.9.2.1 deraadt int timeo; /* initial timeout in .1 secs */
204 1.9.2.1 deraadt int retrans; /* times to retry send */
205 1.9.2.1 deraadt char *hostname; /* server's hostname */
206 1.9.2.1 deraadt int acregmin; /* attr cache file min secs */
207 1.9.2.1 deraadt int acregmax; /* attr cache file max secs */
208 1.9.2.1 deraadt int acdirmin; /* attr cache dir min secs */
209 1.9.2.1 deraadt int acdirmax; /* attr cache dir max secs */
210 1.9.2.1 deraadt char *netname; /* server's netname */
211 1.9.2.1 deraadt struct pathcnf *pathconf; /* static pathconf kludge */
212 1.9.2.1 deraadt };
213 1.9.2.1 deraadt
214 1.1 deraadt struct sun_mount_args {
215 1.1 deraadt int type;
216 1.1 deraadt char *dir;
217 1.1 deraadt int flags;
218 1.1 deraadt caddr_t data;
219 1.1 deraadt };
220 1.1 deraadt sun_mount(p, uap, retval)
221 1.1 deraadt struct proc *p;
222 1.1 deraadt struct sun_mount_args *uap;
223 1.1 deraadt int *retval;
224 1.1 deraadt {
225 1.1 deraadt int oflags = uap->flags, nflags, error;
226 1.9.2.1 deraadt extern char sigcode[], esigcode[];
227 1.9.2.1 deraadt #define szsigcode (esigcode - sigcode)
228 1.1 deraadt
229 1.1 deraadt if (oflags & (SUNM_NOSUB | SUNM_SYS5))
230 1.1 deraadt return (EINVAL);
231 1.1 deraadt if (oflags & SUNM_NEWTYPE && (error = gettype(&uap->type)))
232 1.1 deraadt return (error);
233 1.1 deraadt nflags = 0;
234 1.1 deraadt if (oflags & SUNM_RDONLY)
235 1.1 deraadt nflags |= MNT_RDONLY;
236 1.1 deraadt if (oflags & SUNM_NOSUID)
237 1.1 deraadt nflags |= MNT_NOSUID;
238 1.1 deraadt if (oflags & SUNM_REMOUNT)
239 1.1 deraadt nflags |= MNT_UPDATE;
240 1.1 deraadt uap->flags = nflags;
241 1.9.2.1 deraadt
242 1.9.2.1 deraadt if (uap->type == MOUNT_NFS) {
243 1.9.2.1 deraadt struct sun_nfs_args sna;
244 1.9.2.1 deraadt struct sockaddr_in sain;
245 1.9.2.1 deraadt struct nfs_args na;
246 1.9.2.1 deraadt struct sockaddr sa;
247 1.9.2.1 deraadt
248 1.9.2.1 deraadt if (error = copyin(uap->data, &sna, sizeof sna))
249 1.9.2.1 deraadt return (error);
250 1.9.2.1 deraadt if (error = copyin(sna.addr, &sain, sizeof sain))
251 1.9.2.1 deraadt return (error);
252 1.9.2.1 deraadt bcopy(&sain, &sa, sizeof sa);
253 1.9.2.1 deraadt sa.sa_len = sizeof(sain);
254 1.9.2.1 deraadt uap->data = (caddr_t)ALIGN(PS_STRINGS - szsigcode - STACKGAPLEN);
255 1.9.2.1 deraadt na.addr = (struct sockaddr *)((int)uap->data + sizeof na);
256 1.9.2.1 deraadt na.sotype = SOCK_DGRAM;
257 1.9.2.1 deraadt na.proto = IPPROTO_UDP;
258 1.9.2.1 deraadt na.fh = (nfsv2fh_t *)sna.fh;
259 1.9.2.1 deraadt na.flags = sna.flags;
260 1.9.2.1 deraadt na.wsize = sna.wsize;
261 1.9.2.1 deraadt na.rsize = sna.rsize;
262 1.9.2.1 deraadt na.timeo = sna.timeo;
263 1.9.2.1 deraadt na.retrans = sna.retrans;
264 1.9.2.1 deraadt na.hostname = sna.hostname;
265 1.9.2.1 deraadt
266 1.9.2.1 deraadt if (error = copyout(&sa, na.addr, sizeof sa))
267 1.9.2.1 deraadt return (error);
268 1.9.2.1 deraadt if (error = copyout(&na, uap->data, sizeof na))
269 1.9.2.1 deraadt return (error);
270 1.9.2.1 deraadt }
271 1.1 deraadt return (mount(p, uap, retval));
272 1.1 deraadt }
273 1.1 deraadt
274 1.1 deraadt struct sun_sigpending_args {
275 1.1 deraadt int *mask;
276 1.1 deraadt };
277 1.1 deraadt sun_sigpending(p, uap, retval)
278 1.1 deraadt struct proc *p;
279 1.1 deraadt struct sun_sigpending_args *uap;
280 1.1 deraadt int *retval;
281 1.1 deraadt {
282 1.1 deraadt int mask = p->p_sig & p->p_sigmask;
283 1.1 deraadt
284 1.1 deraadt return (copyout((caddr_t)&mask, (caddr_t)uap->mask, sizeof(int)));
285 1.1 deraadt }
286 1.1 deraadt
287 1.8 deraadt /* XXX: Temporary until sys/dir.h, include/dirent.h and sys/dirent.h are fixed */
288 1.4 deraadt struct dirent {
289 1.4 deraadt u_long d_fileno; /* file number of entry */
290 1.4 deraadt u_short d_reclen; /* length of this record */
291 1.4 deraadt u_short d_namlen; /* length of string in d_name */
292 1.4 deraadt char d_name[255 + 1]; /* name must be no longer than this */
293 1.4 deraadt };
294 1.4 deraadt
295 1.1 deraadt /*
296 1.1 deraadt * Here is the sun layout. (Compare the BSD layout in <sys/dirent.h>.)
297 1.1 deraadt * We can assume big-endian, so the BSD d_type field is just the high
298 1.1 deraadt * byte of the SunOS d_namlen field, after adjusting for the extra "long".
299 1.1 deraadt */
300 1.1 deraadt struct sun_dirent {
301 1.1 deraadt long d_off;
302 1.1 deraadt u_long d_fileno;
303 1.1 deraadt u_short d_reclen;
304 1.1 deraadt u_short d_namlen;
305 1.1 deraadt char d_name[256];
306 1.1 deraadt };
307 1.1 deraadt
308 1.1 deraadt /*
309 1.1 deraadt * Read Sun-style directory entries. We suck them into kernel space so
310 1.1 deraadt * that they can be massaged before being copied out to user code. Like
311 1.1 deraadt * SunOS, we squish out `empty' entries.
312 1.1 deraadt *
313 1.1 deraadt * This is quite ugly, but what do you expect from compatibility code?
314 1.1 deraadt */
315 1.1 deraadt struct sun_getdents_args {
316 1.1 deraadt int fd;
317 1.1 deraadt char *buf;
318 1.1 deraadt int nbytes;
319 1.1 deraadt };
320 1.1 deraadt sun_getdents(p, uap, retval)
321 1.1 deraadt struct proc *p;
322 1.1 deraadt register struct sun_getdents_args *uap;
323 1.1 deraadt int *retval;
324 1.1 deraadt {
325 1.1 deraadt register struct vnode *vp;
326 1.1 deraadt register caddr_t inp, buf; /* BSD-format */
327 1.1 deraadt register int len, reclen; /* BSD-format */
328 1.1 deraadt register caddr_t outp; /* Sun-format */
329 1.1 deraadt register int resid; /* Sun-format */
330 1.1 deraadt struct file *fp;
331 1.1 deraadt struct uio auio;
332 1.1 deraadt struct iovec aiov;
333 1.1 deraadt off_t off; /* true file offset */
334 1.1 deraadt long soff; /* Sun file offset */
335 1.1 deraadt int buflen, error, eofflag;
336 1.1 deraadt #define BSD_DIRENT(cp) ((struct dirent *)(cp))
337 1.1 deraadt #define SUN_RECLEN(reclen) (reclen + sizeof(long))
338 1.1 deraadt
339 1.1 deraadt if ((error = getvnode(p->p_fd, uap->fd, &fp)) != 0)
340 1.1 deraadt return (error);
341 1.1 deraadt if ((fp->f_flag & FREAD) == 0)
342 1.1 deraadt return (EBADF);
343 1.1 deraadt vp = (struct vnode *)fp->f_data;
344 1.1 deraadt if (vp->v_type != VDIR) /* XXX vnode readdir op should do this */
345 1.1 deraadt return (EINVAL);
346 1.1 deraadt buflen = min(MAXBSIZE, uap->nbytes);
347 1.1 deraadt buf = malloc(buflen, M_TEMP, M_WAITOK);
348 1.1 deraadt VOP_LOCK(vp);
349 1.1 deraadt off = fp->f_offset;
350 1.1 deraadt again:
351 1.1 deraadt aiov.iov_base = buf;
352 1.1 deraadt aiov.iov_len = buflen;
353 1.1 deraadt auio.uio_iov = &aiov;
354 1.1 deraadt auio.uio_iovcnt = 1;
355 1.1 deraadt auio.uio_rw = UIO_READ;
356 1.1 deraadt auio.uio_segflg = UIO_SYSSPACE;
357 1.1 deraadt auio.uio_procp = p;
358 1.1 deraadt auio.uio_resid = buflen;
359 1.1 deraadt auio.uio_offset = off;
360 1.1 deraadt /*
361 1.1 deraadt * First we read into the malloc'ed buffer, then
362 1.1 deraadt * we massage it into user space, one record at a time.
363 1.1 deraadt */
364 1.4 deraadt if (error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, NULL, 0))
365 1.1 deraadt goto out;
366 1.1 deraadt inp = buf;
367 1.1 deraadt outp = uap->buf;
368 1.1 deraadt resid = uap->nbytes;
369 1.1 deraadt if ((len = buflen - auio.uio_resid) == 0)
370 1.1 deraadt goto eof;
371 1.1 deraadt for (; len > 0; len -= reclen) {
372 1.1 deraadt reclen = ((struct dirent *)inp)->d_reclen;
373 1.1 deraadt if (reclen & 3)
374 1.1 deraadt panic("sun_getdents");
375 1.1 deraadt off += reclen; /* each entry points to next */
376 1.1 deraadt if (BSD_DIRENT(inp)->d_fileno == 0) {
377 1.1 deraadt inp += reclen; /* it is a hole; squish it out */
378 1.1 deraadt continue;
379 1.1 deraadt }
380 1.1 deraadt if (reclen > len || resid < SUN_RECLEN(reclen)) {
381 1.1 deraadt /* entry too big for buffer, so just stop */
382 1.1 deraadt outp++;
383 1.1 deraadt break;
384 1.1 deraadt }
385 1.1 deraadt /*
386 1.1 deraadt * Massage in place to make a Sun-shaped dirent (otherwise
387 1.1 deraadt * we have to worry about touching user memory outside of
388 1.1 deraadt * the copyout() call).
389 1.1 deraadt */
390 1.1 deraadt BSD_DIRENT(inp)->d_reclen = SUN_RECLEN(reclen);
391 1.4 deraadt #if notdef
392 1.4 deraadt BSD_DIRENT(inp)->d_type = 0; /* 4.4 specific */
393 1.4 deraadt #endif
394 1.1 deraadt soff = off;
395 1.1 deraadt if ((error = copyout((caddr_t)&soff, outp, sizeof soff)) != 0 ||
396 1.1 deraadt (error = copyout(inp, outp + sizeof soff, reclen)) != 0)
397 1.1 deraadt goto out;
398 1.1 deraadt /* advance past this real entry */
399 1.1 deraadt inp += reclen;
400 1.1 deraadt /* advance output past Sun-shaped entry */
401 1.1 deraadt outp += SUN_RECLEN(reclen);
402 1.1 deraadt resid -= SUN_RECLEN(reclen);
403 1.1 deraadt }
404 1.1 deraadt /* if we squished out the whole block, try again */
405 1.1 deraadt if (outp == uap->buf)
406 1.1 deraadt goto again;
407 1.1 deraadt fp->f_offset = off; /* update the vnode offset */
408 1.1 deraadt eof:
409 1.1 deraadt *retval = uap->nbytes - resid;
410 1.1 deraadt out:
411 1.1 deraadt VOP_UNLOCK(vp);
412 1.1 deraadt free(buf, M_TEMP);
413 1.1 deraadt return (error);
414 1.1 deraadt }
415 1.1 deraadt
416 1.4 deraadt /*
417 1.4 deraadt * The Sun bit-style arguments are not in the same order as the
418 1.9.2.5 deraadt * NetBSD ones. We must remap the bits.
419 1.4 deraadt */
420 1.1 deraadt
421 1.5 deraadt #if defined(sparc)
422 1.1 deraadt #define DEVZERO makedev(3, 12) /* major,minor of /dev/zero */
423 1.9.2.5 deraadt #else /* all m68k architectures */
424 1.6 deraadt #define DEVZERO makedev(2, 12) /* major,minor of /dev/zero */
425 1.5 deraadt #endif
426 1.1 deraadt
427 1.4 deraadt #define SUN_PROT_READ 1
428 1.4 deraadt #define SUN_PROT_WRITE 2
429 1.4 deraadt #define SUN_PROT_EXEC 4
430 1.4 deraadt #define SUN_PROT_UALL (SUN_PROT_READ | SUN_PROT_WRITE | SUN_PROT_EXEC)
431 1.4 deraadt
432 1.4 deraadt #define SUN__MAP_NEW 0x80000000 /* if not, old mmap & cannot handle */
433 1.4 deraadt
434 1.4 deraadt #define SUN_MAP_SHARED 1
435 1.4 deraadt #define SUN_MAP_PRIVATE 2
436 1.4 deraadt #define SUN_MAP_TYPE 0xf
437 1.4 deraadt #define SUN_MAP_FIXED 0x10
438 1.1 deraadt
439 1.1 deraadt struct sun_mmap_args {
440 1.1 deraadt caddr_t addr;
441 1.1 deraadt size_t len;
442 1.1 deraadt int prot;
443 1.1 deraadt int flags;
444 1.1 deraadt int fd;
445 1.4 deraadt off_t off;
446 1.1 deraadt };
447 1.1 deraadt sun_mmap(p, uap, retval)
448 1.1 deraadt register struct proc *p;
449 1.1 deraadt register struct sun_mmap_args *uap;
450 1.1 deraadt int *retval;
451 1.1 deraadt {
452 1.4 deraadt register int flags, prot, newflags, newprot;
453 1.1 deraadt register struct filedesc *fdp;
454 1.1 deraadt register struct file *fp;
455 1.1 deraadt register struct vnode *vp;
456 1.1 deraadt
457 1.1 deraadt /*
458 1.4 deraadt * Verify and re-map the arguments.
459 1.1 deraadt */
460 1.4 deraadt prot = uap->prot;
461 1.4 deraadt newprot = 0;
462 1.4 deraadt if (uap->prot & ~SUN_PROT_UALL)
463 1.4 deraadt return (EINVAL);
464 1.4 deraadt if (uap->prot & SUN_PROT_READ)
465 1.4 deraadt newprot |= PROT_READ;
466 1.4 deraadt if (uap->prot & SUN_PROT_WRITE)
467 1.4 deraadt newprot |= PROT_WRITE;
468 1.4 deraadt if (uap->prot & SUN_PROT_EXEC)
469 1.4 deraadt newprot |= PROT_EXEC;
470 1.4 deraadt
471 1.1 deraadt flags = uap->flags;
472 1.4 deraadt newflags = 0;
473 1.4 deraadt if ((flags & SUN__MAP_NEW) == 0)
474 1.1 deraadt return (EINVAL);
475 1.4 deraadt
476 1.4 deraadt switch (flags & SUN_MAP_TYPE) {
477 1.4 deraadt case SUN_MAP_SHARED:
478 1.4 deraadt newflags |= MAP_SHARED;
479 1.4 deraadt break;
480 1.4 deraadt case SUN_MAP_PRIVATE:
481 1.4 deraadt newflags |= MAP_PRIVATE;
482 1.4 deraadt break;
483 1.4 deraadt default:
484 1.1 deraadt return (EINVAL);
485 1.4 deraadt }
486 1.1 deraadt
487 1.4 deraadt if (flags & SUN_MAP_FIXED)
488 1.4 deraadt newflags |= MAP_FIXED;
489 1.4 deraadt
490 1.9.2.9 pk if ((newflags & MAP_FIXED) == 0 &&
491 1.9.2.9 pk uap->addr != 0 &&
492 1.9.2.9 pk uap->addr < (caddr_t)round_page(p->p_vmspace->vm_daddr + MAXDSIZ))
493 1.9.2.9 pk uap->addr = (caddr_t)round_page(p->p_vmspace->vm_daddr + MAXDSIZ);
494 1.9.2.9 pk
495 1.1 deraadt /*
496 1.1 deraadt * Special case: if fd refers to /dev/zero, map as MAP_ANON. (XXX)
497 1.1 deraadt */
498 1.1 deraadt fdp = p->p_fd;
499 1.1 deraadt if ((unsigned)uap->fd < fdp->fd_nfiles && /*XXX*/
500 1.1 deraadt (fp = fdp->fd_ofiles[uap->fd]) != NULL && /*XXX*/
501 1.1 deraadt fp->f_type == DTYPE_VNODE && /*XXX*/
502 1.1 deraadt (vp = (struct vnode *)fp->f_data)->v_type == VCHR && /*XXX*/
503 1.1 deraadt vp->v_rdev == DEVZERO) { /*XXX*/
504 1.4 deraadt newflags |= MAP_ANON;
505 1.1 deraadt uap->fd = -1;
506 1.4 deraadt } else
507 1.4 deraadt newflags |= MAP_FILE;
508 1.4 deraadt
509 1.1 deraadt /* All done, fix up fields and go. */
510 1.4 deraadt uap->flags = newflags;
511 1.4 deraadt uap->prot = newprot;
512 1.2 deraadt return (smmap(p, uap, retval));
513 1.1 deraadt }
514 1.1 deraadt
515 1.1 deraadt #define MC_SYNC 1
516 1.1 deraadt #define MC_LOCK 2
517 1.1 deraadt #define MC_UNLOCK 3
518 1.1 deraadt #define MC_ADVISE 4
519 1.1 deraadt #define MC_LOCKAS 5
520 1.1 deraadt #define MC_UNLOCKAS 6
521 1.1 deraadt
522 1.1 deraadt struct sun_mctl_args {
523 1.1 deraadt caddr_t addr;
524 1.1 deraadt size_t len;
525 1.1 deraadt int func;
526 1.1 deraadt void *arg;
527 1.1 deraadt };
528 1.1 deraadt sun_mctl(p, uap, retval)
529 1.1 deraadt register struct proc *p;
530 1.1 deraadt register struct sun_mctl_args *uap;
531 1.1 deraadt int *retval;
532 1.1 deraadt {
533 1.1 deraadt
534 1.1 deraadt switch (uap->func) {
535 1.1 deraadt
536 1.1 deraadt case MC_ADVISE: /* ignore for now */
537 1.1 deraadt return (0);
538 1.1 deraadt
539 1.1 deraadt case MC_SYNC: /* translate to msync */
540 1.1 deraadt return (msync(p, uap, retval));
541 1.1 deraadt
542 1.1 deraadt default:
543 1.1 deraadt return (EINVAL);
544 1.1 deraadt }
545 1.1 deraadt }
546 1.1 deraadt
547 1.1 deraadt struct sun_setsockopt_args {
548 1.1 deraadt int s;
549 1.1 deraadt int level;
550 1.1 deraadt int name;
551 1.1 deraadt caddr_t val;
552 1.1 deraadt int valsize;
553 1.1 deraadt };
554 1.1 deraadt sun_setsockopt(p, uap, retval)
555 1.1 deraadt struct proc *p;
556 1.1 deraadt register struct sun_setsockopt_args *uap;
557 1.1 deraadt int *retval;
558 1.1 deraadt {
559 1.1 deraadt struct file *fp;
560 1.1 deraadt struct mbuf *m = NULL;
561 1.1 deraadt int error;
562 1.1 deraadt
563 1.1 deraadt if (error = getsock(p->p_fd, uap->s, &fp))
564 1.1 deraadt return (error);
565 1.1 deraadt #define SO_DONTLINGER (~SO_LINGER)
566 1.1 deraadt if (uap->name == SO_DONTLINGER) {
567 1.1 deraadt m = m_get(M_WAIT, MT_SOOPTS);
568 1.1 deraadt if (m == NULL)
569 1.1 deraadt return (ENOBUFS);
570 1.1 deraadt mtod(m, struct linger *)->l_onoff = 0;
571 1.1 deraadt m->m_len = sizeof(struct linger);
572 1.1 deraadt return (sosetopt((struct socket *)fp->f_data, uap->level,
573 1.1 deraadt SO_LINGER, m));
574 1.1 deraadt }
575 1.1 deraadt if (uap->valsize > MLEN)
576 1.1 deraadt return (EINVAL);
577 1.1 deraadt if (uap->val) {
578 1.1 deraadt m = m_get(M_WAIT, MT_SOOPTS);
579 1.1 deraadt if (m == NULL)
580 1.1 deraadt return (ENOBUFS);
581 1.1 deraadt if (error = copyin(uap->val, mtod(m, caddr_t),
582 1.1 deraadt (u_int)uap->valsize)) {
583 1.1 deraadt (void) m_free(m);
584 1.1 deraadt return (error);
585 1.1 deraadt }
586 1.1 deraadt m->m_len = uap->valsize;
587 1.1 deraadt }
588 1.1 deraadt return (sosetopt((struct socket *)fp->f_data, uap->level,
589 1.1 deraadt uap->name, m));
590 1.1 deraadt }
591 1.1 deraadt
592 1.1 deraadt struct sun_fchroot_args {
593 1.1 deraadt int fdes;
594 1.1 deraadt };
595 1.1 deraadt sun_fchroot(p, uap, retval)
596 1.1 deraadt register struct proc *p;
597 1.1 deraadt register struct sun_fchroot_args *uap;
598 1.1 deraadt int *retval;
599 1.1 deraadt {
600 1.1 deraadt register struct filedesc *fdp = p->p_fd;
601 1.1 deraadt register struct vnode *vp;
602 1.1 deraadt struct file *fp;
603 1.1 deraadt int error;
604 1.1 deraadt
605 1.1 deraadt if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
606 1.1 deraadt return (error);
607 1.1 deraadt if ((error = getvnode(fdp, uap->fdes, &fp)) != 0)
608 1.1 deraadt return (error);
609 1.1 deraadt vp = (struct vnode *)fp->f_data;
610 1.1 deraadt VOP_LOCK(vp);
611 1.1 deraadt if (vp->v_type != VDIR)
612 1.1 deraadt error = ENOTDIR;
613 1.1 deraadt else
614 1.1 deraadt error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p);
615 1.1 deraadt VOP_UNLOCK(vp);
616 1.1 deraadt if (error)
617 1.1 deraadt return (error);
618 1.1 deraadt VREF(vp);
619 1.1 deraadt if (fdp->fd_rdir != NULL)
620 1.1 deraadt vrele(fdp->fd_rdir);
621 1.1 deraadt fdp->fd_rdir = vp;
622 1.1 deraadt return (0);
623 1.3 deraadt }
624 1.3 deraadt
625 1.3 deraadt /*
626 1.3 deraadt * XXX: This needs cleaning up.
627 1.3 deraadt */
628 1.8 deraadt sun_auditsys(...)
629 1.3 deraadt {
630 1.3 deraadt return 0;
631 1.8 deraadt }
632 1.8 deraadt
633 1.8 deraadt struct sun_utsname {
634 1.8 deraadt char sysname[9];
635 1.8 deraadt char nodename[9];
636 1.8 deraadt char nodeext[65-9];
637 1.8 deraadt char release[9];
638 1.8 deraadt char version[9];
639 1.8 deraadt char machine[9];
640 1.8 deraadt };
641 1.8 deraadt
642 1.8 deraadt struct sun_uname_args {
643 1.8 deraadt struct sun_utsname *name;
644 1.8 deraadt };
645 1.8 deraadt sun_uname(p, uap, retval)
646 1.8 deraadt struct proc *p;
647 1.8 deraadt struct sun_uname_args *uap;
648 1.8 deraadt int *retval;
649 1.8 deraadt {
650 1.8 deraadt struct sun_utsname sut;
651 1.8 deraadt
652 1.8 deraadt /* first update utsname just as with NetBSD uname() */
653 1.8 deraadt bcopy(hostname, utsname.nodename, sizeof(utsname.nodename));
654 1.8 deraadt utsname.nodename[sizeof(utsname.nodename)-1] = '\0';
655 1.8 deraadt
656 1.8 deraadt /* then copy it over into SunOS struct utsname */
657 1.8 deraadt bzero(&sut, sizeof(sut));
658 1.8 deraadt bcopy(utsname.sysname, sut.sysname, sizeof(sut.sysname) - 1);
659 1.8 deraadt bcopy(utsname.nodename, sut.nodename, sizeof(sut.nodename) - 1);
660 1.8 deraadt bcopy(utsname.release, sut.release, sizeof(sut.release) - 1);
661 1.8 deraadt bcopy(utsname.version, sut.version, sizeof(sut.version) - 1);
662 1.8 deraadt bcopy(utsname.machine, sut.machine, sizeof(sut.machine) - 1);
663 1.8 deraadt
664 1.8 deraadt return copyout((caddr_t)&sut, (caddr_t)uap->name, sizeof(struct sun_utsname));
665 1.8 deraadt }
666 1.8 deraadt
667 1.8 deraadt struct sun_setpgid_args {
668 1.8 deraadt int pid; /* target process id */
669 1.8 deraadt int pgid; /* target pgrp id */
670 1.8 deraadt };
671 1.8 deraadt int
672 1.8 deraadt sun_setpgid(p, uap, retval)
673 1.8 deraadt struct proc *p;
674 1.8 deraadt struct sun_setpgid_args *uap;
675 1.8 deraadt int *retval;
676 1.8 deraadt {
677 1.8 deraadt /*
678 1.8 deraadt * difference to our setpgid call is to include backwards
679 1.8 deraadt * compatibility to pre-setsid() binaries. Do setsid()
680 1.8 deraadt * instead of setpgid() in those cases where the process
681 1.8 deraadt * tries to create a new session the old way.
682 1.8 deraadt */
683 1.8 deraadt if (!uap->pgid && (!uap->pid || uap->pid == p->p_pid))
684 1.8 deraadt return setsid(p, uap, retval);
685 1.8 deraadt else
686 1.8 deraadt return setpgid(p, uap, retval);
687 1.8 deraadt }
688 1.8 deraadt
689 1.8 deraadt struct sun_open_args {
690 1.8 deraadt char *fname;
691 1.8 deraadt int fmode;
692 1.8 deraadt int crtmode;
693 1.8 deraadt };
694 1.8 deraadt sun_open(p, uap, retval)
695 1.8 deraadt struct proc *p;
696 1.8 deraadt struct sun_open_args *uap;
697 1.8 deraadt int *retval;
698 1.8 deraadt {
699 1.8 deraadt int l, r;
700 1.8 deraadt int noctty = uap->fmode & 0x8000;
701 1.8 deraadt int ret;
702 1.8 deraadt
703 1.8 deraadt /* convert mode into NetBSD mode */
704 1.8 deraadt l = uap->fmode;
705 1.8 deraadt r = (l & (0x0001 | 0x0002 | 0x0008 | 0x0040 | 0x0200 | 0x0400 | 0x0800));
706 1.8 deraadt r |= ((l & (0x0004 | 0x1000 | 0x4000)) ? O_NONBLOCK : 0);
707 1.8 deraadt r |= ((l & 0x0080) ? O_SHLOCK : 0);
708 1.8 deraadt r |= ((l & 0x0100) ? O_EXLOCK : 0);
709 1.8 deraadt r |= ((l & 0x2000) ? O_FSYNC : 0);
710 1.8 deraadt
711 1.8 deraadt uap->fmode = r;
712 1.8 deraadt ret = open(p, uap, retval);
713 1.8 deraadt
714 1.8 deraadt if (!ret && !noctty && SESS_LEADER(p) && !(p->p_flag & SCTTY)) {
715 1.8 deraadt struct filedesc *fdp = p->p_fd;
716 1.8 deraadt struct file *fp = fdp->fd_ofiles[*retval];
717 1.8 deraadt
718 1.8 deraadt /* ignore any error, just give it a try */
719 1.8 deraadt if (fp->f_type == DTYPE_VNODE)
720 1.8 deraadt (fp->f_ops->fo_ioctl)(fp, TIOCSCTTY, (caddr_t) 0, p);
721 1.8 deraadt }
722 1.8 deraadt return ret;
723 1.1 deraadt }
724 1.9.2.2 deraadt
725 1.9.2.2 deraadt struct nfssvc_args {
726 1.9.2.2 deraadt int fd;
727 1.9.2.2 deraadt caddr_t mskval;
728 1.9.2.2 deraadt int msklen;
729 1.9.2.2 deraadt caddr_t mtchval;
730 1.9.2.2 deraadt int mtchlen;
731 1.9.2.2 deraadt };
732 1.9.2.2 deraadt struct sun_nfssvc_args {
733 1.9.2.2 deraadt int fd;
734 1.9.2.2 deraadt };
735 1.9.2.2 deraadt sun_nfssvc(p, uap, retval)
736 1.9.2.2 deraadt struct proc *p;
737 1.9.2.2 deraadt struct sun_nfssvc_args *uap;
738 1.9.2.2 deraadt int *retval;
739 1.9.2.2 deraadt {
740 1.9.2.2 deraadt struct nfssvc_args outuap;
741 1.9.2.2 deraadt struct sockaddr sa;
742 1.9.2.2 deraadt int error;
743 1.9.2.2 deraadt extern char sigcode[], esigcode[];
744 1.9.2.2 deraadt
745 1.9.2.2 deraadt bzero(&outuap, sizeof outuap);
746 1.9.2.2 deraadt outuap.fd = uap->fd;
747 1.9.2.2 deraadt outuap.mskval = (caddr_t)ALIGN(PS_STRINGS - szsigcode - STACKGAPLEN);
748 1.9.2.2 deraadt outuap.msklen = sizeof sa;
749 1.9.2.2 deraadt outuap.mtchval = outuap.mskval + sizeof sa;
750 1.9.2.2 deraadt outuap.mtchlen = sizeof sa;
751 1.9.2.2 deraadt
752 1.9.2.2 deraadt bzero(&sa, sizeof sa);
753 1.9.2.2 deraadt if (error = copyout(&sa, outuap.mskval, outuap.msklen))
754 1.9.2.2 deraadt return (error);
755 1.9.2.2 deraadt if (error = copyout(&sa, outuap.mtchval, outuap.mtchlen))
756 1.9.2.2 deraadt return (error);
757 1.9.2.2 deraadt
758 1.9.2.2 deraadt return nfssvc(p, &outuap, retval);
759 1.9.2.2 deraadt }
760 1.9.2.3 deraadt
761 1.9.2.3 deraadt struct sun_ustat {
762 1.9.2.3 deraadt daddr_t f_tfree; /* total free */
763 1.9.2.3 deraadt ino_t f_tinode; /* total inodes free */
764 1.9.2.3 deraadt char f_fname[6]; /* filsys name */
765 1.9.2.3 deraadt char f_fpack[6]; /* filsys pack name */
766 1.9.2.3 deraadt };
767 1.9.2.3 deraadt struct sun_ustat_args {
768 1.9.2.3 deraadt int dev;
769 1.9.2.3 deraadt struct sun_ustat *buf;
770 1.9.2.3 deraadt };
771 1.9.2.3 deraadt sun_ustat(p, uap, retval)
772 1.9.2.3 deraadt struct proc *p;
773 1.9.2.3 deraadt struct sun_ustat_args *uap;
774 1.9.2.3 deraadt int *retval;
775 1.9.2.3 deraadt {
776 1.9.2.3 deraadt struct sun_ustat us;
777 1.9.2.3 deraadt int error;
778 1.9.2.3 deraadt
779 1.9.2.3 deraadt bzero(&us, sizeof us);
780 1.9.2.8 deraadt
781 1.9.2.8 deraadt /*
782 1.9.2.8 deraadt * XXX: should set f_tfree and f_tinode at least
783 1.9.2.8 deraadt * How do we translate dev -> fstat? (and then to sun_ustat)
784 1.9.2.8 deraadt */
785 1.9.2.3 deraadt
786 1.9.2.3 deraadt if (error = copyout(&us, uap->buf, sizeof us))
787 1.9.2.3 deraadt return (error);
788 1.9.2.3 deraadt return 0;
789 1.9.2.4 deraadt }
790 1.9.2.4 deraadt
791 1.9.2.4 deraadt struct sun_quotactl_args {
792 1.9.2.4 deraadt int cmd;
793 1.9.2.4 deraadt char *special;
794 1.9.2.4 deraadt int uid;
795 1.9.2.4 deraadt caddr_t addr;
796 1.9.2.4 deraadt };
797 1.9.2.4 deraadt sun_quotactl(p, uap, retval)
798 1.9.2.4 deraadt struct proc *p;
799 1.9.2.4 deraadt struct sun_quotactl_args *uap;
800 1.9.2.4 deraadt int *retval;
801 1.9.2.4 deraadt {
802 1.9.2.4 deraadt return EINVAL;
803 1.9.2.5 deraadt }
804 1.9.2.5 deraadt
805 1.9.2.5 deraadt sun_vhangup(p, uap, retval)
806 1.9.2.5 deraadt struct proc *p;
807 1.9.2.5 deraadt void *uap;
808 1.9.2.5 deraadt int *retval;
809 1.9.2.5 deraadt {
810 1.9.2.5 deraadt return 0;
811 1.9.2.6 deraadt }
812 1.9.2.6 deraadt
813 1.9.2.6 deraadt struct sun_statfs {
814 1.9.2.6 deraadt long f_type; /* type of info, zero for now */
815 1.9.2.6 deraadt long f_bsize; /* fundamental file system block size */
816 1.9.2.6 deraadt long f_blocks; /* total blocks in file system */
817 1.9.2.6 deraadt long f_bfree; /* free blocks */
818 1.9.2.6 deraadt long f_bavail; /* free blocks available to non-super-user */
819 1.9.2.6 deraadt long f_files; /* total file nodes in file system */
820 1.9.2.6 deraadt long f_ffree; /* free file nodes in fs */
821 1.9.2.6 deraadt fsid_t f_fsid; /* file system id */
822 1.9.2.6 deraadt long f_spare[7]; /* spare for later */
823 1.9.2.6 deraadt };
824 1.9.2.8 deraadt static
825 1.9.2.8 deraadt sunstatfs(sp, buf)
826 1.9.2.8 deraadt struct statfs *sp;
827 1.9.2.8 deraadt caddr_t buf;
828 1.9.2.6 deraadt {
829 1.9.2.8 deraadt struct sun_statfs ssfs;
830 1.9.2.6 deraadt
831 1.9.2.6 deraadt bzero(&ssfs, sizeof ssfs);
832 1.9.2.6 deraadt ssfs.f_type = 0;
833 1.9.2.8 deraadt ssfs.f_bsize = sp->f_fsize;
834 1.9.2.8 deraadt ssfs.f_blocks = sp->f_blocks;
835 1.9.2.8 deraadt ssfs.f_bfree = sp->f_bfree;
836 1.9.2.8 deraadt ssfs.f_bavail = sp->f_bavail;
837 1.9.2.8 deraadt ssfs.f_files = sp->f_files;
838 1.9.2.8 deraadt ssfs.f_ffree = sp->f_ffree;
839 1.9.2.8 deraadt ssfs.f_fsid = sp->f_fsid;
840 1.9.2.8 deraadt return copyout((caddr_t)&ssfs, buf, sizeof ssfs);
841 1.9.2.8 deraadt }
842 1.9.2.6 deraadt
843 1.9.2.8 deraadt struct sun_statfs_args {
844 1.9.2.8 deraadt char *path;
845 1.9.2.8 deraadt struct sun_statfs *buf;
846 1.9.2.8 deraadt };
847 1.9.2.6 deraadt sun_statfs(p, uap, retval)
848 1.9.2.6 deraadt struct proc *p;
849 1.9.2.6 deraadt struct sun_statfs_args *uap;
850 1.9.2.6 deraadt int *retval;
851 1.9.2.6 deraadt {
852 1.9.2.8 deraadt register struct mount *mp;
853 1.9.2.8 deraadt register struct nameidata *ndp;
854 1.9.2.8 deraadt register struct statfs *sp;
855 1.9.2.8 deraadt int error;
856 1.9.2.8 deraadt struct nameidata nd;
857 1.9.2.6 deraadt
858 1.9.2.8 deraadt ndp = &nd;
859 1.9.2.8 deraadt ndp->ni_nameiop = LOOKUP | FOLLOW;
860 1.9.2.8 deraadt ndp->ni_segflg = UIO_USERSPACE;
861 1.9.2.8 deraadt ndp->ni_dirp = uap->path;
862 1.9.2.8 deraadt if (error = namei(ndp, p))
863 1.9.2.8 deraadt return (error);
864 1.9.2.8 deraadt mp = ndp->ni_vp->v_mount;
865 1.9.2.8 deraadt sp = &mp->mnt_stat;
866 1.9.2.8 deraadt vrele(ndp->ni_vp);
867 1.9.2.8 deraadt if (error = VFS_STATFS(mp, sp, p))
868 1.9.2.8 deraadt return (error);
869 1.9.2.8 deraadt sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
870 1.9.2.8 deraadt return sunstatfs(sp, (caddr_t)uap->buf);
871 1.9.2.6 deraadt }
872 1.9.2.6 deraadt
873 1.9.2.8 deraadt struct sun_fstatfs_args {
874 1.9.2.8 deraadt int fd;
875 1.9.2.8 deraadt struct sun_statfs *buf;
876 1.9.2.8 deraadt };
877 1.9.2.6 deraadt sun_fstatfs(p, uap, retval)
878 1.9.2.6 deraadt struct proc *p;
879 1.9.2.8 deraadt struct sun_fstatfs_args *uap;
880 1.9.2.6 deraadt int *retval;
881 1.9.2.6 deraadt {
882 1.9.2.8 deraadt struct file *fp;
883 1.9.2.8 deraadt struct mount *mp;
884 1.9.2.8 deraadt register struct statfs *sp;
885 1.9.2.8 deraadt int error;
886 1.9.2.6 deraadt
887 1.9.2.8 deraadt if (error = getvnode(p->p_fd, uap->fd, &fp))
888 1.9.2.8 deraadt return (error);
889 1.9.2.8 deraadt mp = ((struct vnode *)fp->f_data)->v_mount;
890 1.9.2.8 deraadt sp = &mp->mnt_stat;
891 1.9.2.8 deraadt if (error = VFS_STATFS(mp, sp, p))
892 1.9.2.8 deraadt return (error);
893 1.9.2.8 deraadt sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
894 1.9.2.8 deraadt return sunstatfs(sp, (caddr_t)uap->buf);
895 1.9.2.7 deraadt }
896 1.9.2.7 deraadt
897 1.9.2.7 deraadt struct sun_exportfs_args {
898 1.9.2.7 deraadt char *path;
899 1.9.2.8 deraadt char *ex; /* struct sun_export * */
900 1.9.2.7 deraadt };
901 1.9.2.7 deraadt sun_exportfs(p, uap, retval)
902 1.9.2.7 deraadt struct proc *p;
903 1.9.2.7 deraadt struct sun_exportfs_args *uap;
904 1.9.2.7 deraadt int *retval;
905 1.9.2.7 deraadt {
906 1.9.2.8 deraadt /*
907 1.9.2.8 deraadt * XXX: should perhaps translate into a mount(2)
908 1.9.2.8 deraadt * with MOUNT_EXPORT?
909 1.9.2.8 deraadt */
910 1.9.2.7 deraadt return 0;
911 1.9.2.9 pk }
912 1.9.2.9 pk
913 1.9.2.9 pk struct sun_mknod_args {
914 1.9.2.9 pk char *fname;
915 1.9.2.9 pk int fmode;
916 1.9.2.9 pk int dev;
917 1.9.2.9 pk };
918 1.9.2.9 pk
919 1.9.2.9 pk sun_mknod(p, uap, retval)
920 1.9.2.9 pk struct proc *p;
921 1.9.2.9 pk struct sun_mknod_args *uap;
922 1.9.2.9 pk int *retval;
923 1.9.2.9 pk {
924 1.9.2.9 pk if (S_ISFIFO(uap->fmode))
925 1.9.2.9 pk return mkfifo(p, uap, retval);
926 1.9.2.9 pk
927 1.9.2.9 pk return mknod(p, uap, retval);
928 1.9.2.3 deraadt }
929