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