proc->thread stage 2: MAJOR revamping of system calls, ucred, jail API,
[dragonfly.git] / sys / emulation / svr4 / svr4_fcntl.c
1 /*
2  * Copyright (c) 1998 Mark Newton
3  * Copyright (c) 1994, 1997 Christos Zoulas.  
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. All advertising materials mentioning features or use of this software
15  *    must display the following acknowledgement:
16  *      This product includes software developed by Christos Zoulas.
17  * 4. The name of the author may not be used to endorse or promote products
18  *    derived from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  * 
31  * $FreeBSD: src/sys/svr4/svr4_fcntl.c,v 1.7 1999/12/12 10:27:04 newton Exp $
32  * $DragonFly: src/sys/emulation/svr4/Attic/svr4_fcntl.c,v 1.3 2003/06/23 17:55:49 dillon Exp $
33  */
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/namei.h>
37 #include <sys/proc.h>
38 #include <sys/file.h>
39 #include <sys/stat.h>
40 #include <sys/filedesc.h>
41 /*#include <sys/ioctl.h>*/
42 #include <sys/kernel.h>
43 #include <sys/mount.h>
44 #include <sys/malloc.h>
45 #include <sys/vnode.h>
46 #include <sys/unistd.h>
47
48 #include <sys/sysproto.h>
49
50 #include <svr4/svr4.h>
51 #include <svr4/svr4_types.h>
52 #include <svr4/svr4_signal.h>
53 #include <svr4/svr4_proto.h>
54 #include <svr4/svr4_util.h>
55 #include <svr4/svr4_fcntl.h>
56
57 static int svr4_to_bsd_flags __P((int));
58 static u_long svr4_to_bsd_cmd __P((u_long));
59 static int fd_revoke __P((struct proc *, int));
60 static int fd_truncate __P((struct proc *, int, struct flock *));
61 static int bsd_to_svr4_flags __P((int));
62 static void bsd_to_svr4_flock __P((struct flock *, struct svr4_flock *));
63 static void svr4_to_bsd_flock __P((struct svr4_flock *, struct flock *));
64 static void bsd_to_svr4_flock64 __P((struct flock *, struct svr4_flock64 *));
65 static void svr4_to_bsd_flock64 __P((struct svr4_flock64 *, struct flock *));
66
67 static u_long
68 svr4_to_bsd_cmd(cmd)
69         u_long  cmd;
70 {
71         switch (cmd) {
72         case SVR4_F_DUPFD:
73                 return F_DUPFD;
74         case SVR4_F_GETFD:
75                 return F_GETFD;
76         case SVR4_F_SETFD:
77                 return F_SETFD;
78         case SVR4_F_GETFL:
79                 return F_GETFL;
80         case SVR4_F_SETFL:
81                 return F_SETFL;
82         case SVR4_F_GETLK:
83                 return F_GETLK;
84         case SVR4_F_SETLK:
85                 return F_SETLK;
86         case SVR4_F_SETLKW:
87                 return F_SETLKW;
88         default:
89                 return -1;
90         }
91 }
92
93 static int
94 svr4_to_bsd_flags(l)
95         int     l;
96 {
97         int     r = 0;
98         r |= (l & SVR4_O_RDONLY) ? O_RDONLY : 0;
99         r |= (l & SVR4_O_WRONLY) ? O_WRONLY : 0;
100         r |= (l & SVR4_O_RDWR) ? O_RDWR : 0;
101         r |= (l & SVR4_O_NDELAY) ? O_NONBLOCK : 0;
102         r |= (l & SVR4_O_APPEND) ? O_APPEND : 0;
103         r |= (l & SVR4_O_SYNC) ? O_FSYNC : 0;
104         r |= (l & SVR4_O_NONBLOCK) ? O_NONBLOCK : 0;
105         r |= (l & SVR4_O_PRIV) ? O_EXLOCK : 0;
106         r |= (l & SVR4_O_CREAT) ? O_CREAT : 0;
107         r |= (l & SVR4_O_TRUNC) ? O_TRUNC : 0;
108         r |= (l & SVR4_O_EXCL) ? O_EXCL : 0;
109         r |= (l & SVR4_O_NOCTTY) ? O_NOCTTY : 0;
110         return r;
111 }
112
113 static int
114 bsd_to_svr4_flags(l)
115         int     l;
116 {
117         int     r = 0;
118         r |= (l & O_RDONLY) ? SVR4_O_RDONLY : 0;
119         r |= (l & O_WRONLY) ? SVR4_O_WRONLY : 0;
120         r |= (l & O_RDWR) ? SVR4_O_RDWR : 0;
121         r |= (l & O_NDELAY) ? SVR4_O_NONBLOCK : 0;
122         r |= (l & O_APPEND) ? SVR4_O_APPEND : 0;
123         r |= (l & O_FSYNC) ? SVR4_O_SYNC : 0;
124         r |= (l & O_NONBLOCK) ? SVR4_O_NONBLOCK : 0;
125         r |= (l & O_EXLOCK) ? SVR4_O_PRIV : 0;
126         r |= (l & O_CREAT) ? SVR4_O_CREAT : 0;
127         r |= (l & O_TRUNC) ? SVR4_O_TRUNC : 0;
128         r |= (l & O_EXCL) ? SVR4_O_EXCL : 0;
129         r |= (l & O_NOCTTY) ? SVR4_O_NOCTTY : 0;
130         return r;
131 }
132
133
134 static void
135 bsd_to_svr4_flock(iflp, oflp)
136         struct flock            *iflp;
137         struct svr4_flock       *oflp;
138 {
139         switch (iflp->l_type) {
140         case F_RDLCK:
141                 oflp->l_type = SVR4_F_RDLCK;
142                 break;
143         case F_WRLCK:
144                 oflp->l_type = SVR4_F_WRLCK;
145                 break;
146         case F_UNLCK:
147                 oflp->l_type = SVR4_F_UNLCK;
148                 break;
149         default:
150                 oflp->l_type = -1;
151                 break;
152         }
153
154         oflp->l_whence = (short) iflp->l_whence;
155         oflp->l_start = (svr4_off_t) iflp->l_start;
156         oflp->l_len = (svr4_off_t) iflp->l_len;
157         oflp->l_sysid = 0;
158         oflp->l_pid = (svr4_pid_t) iflp->l_pid;
159 }
160
161
162 static void
163 svr4_to_bsd_flock(iflp, oflp)
164         struct svr4_flock       *iflp;
165         struct flock            *oflp;
166 {
167         switch (iflp->l_type) {
168         case SVR4_F_RDLCK:
169                 oflp->l_type = F_RDLCK;
170                 break;
171         case SVR4_F_WRLCK:
172                 oflp->l_type = F_WRLCK;
173                 break;
174         case SVR4_F_UNLCK:
175                 oflp->l_type = F_UNLCK;
176                 break;
177         default:
178                 oflp->l_type = -1;
179                 break;
180         }
181
182         oflp->l_whence = iflp->l_whence;
183         oflp->l_start = (off_t) iflp->l_start;
184         oflp->l_len = (off_t) iflp->l_len;
185         oflp->l_pid = (pid_t) iflp->l_pid;
186
187 }
188
189 static void
190 bsd_to_svr4_flock64(iflp, oflp)
191         struct flock            *iflp;
192         struct svr4_flock64     *oflp;
193 {
194         switch (iflp->l_type) {
195         case F_RDLCK:
196                 oflp->l_type = SVR4_F_RDLCK;
197                 break;
198         case F_WRLCK:
199                 oflp->l_type = SVR4_F_WRLCK;
200                 break;
201         case F_UNLCK:
202                 oflp->l_type = SVR4_F_UNLCK;
203                 break;
204         default:
205                 oflp->l_type = -1;
206                 break;
207         }
208
209         oflp->l_whence = (short) iflp->l_whence;
210         oflp->l_start = (svr4_off64_t) iflp->l_start;
211         oflp->l_len = (svr4_off64_t) iflp->l_len;
212         oflp->l_sysid = 0;
213         oflp->l_pid = (svr4_pid_t) iflp->l_pid;
214 }
215
216
217 static void
218 svr4_to_bsd_flock64(iflp, oflp)
219         struct svr4_flock64     *iflp;
220         struct flock            *oflp;
221 {
222         switch (iflp->l_type) {
223         case SVR4_F_RDLCK:
224                 oflp->l_type = F_RDLCK;
225                 break;
226         case SVR4_F_WRLCK:
227                 oflp->l_type = F_WRLCK;
228                 break;
229         case SVR4_F_UNLCK:
230                 oflp->l_type = F_UNLCK;
231                 break;
232         default:
233                 oflp->l_type = -1;
234                 break;
235         }
236
237         oflp->l_whence = iflp->l_whence;
238         oflp->l_start = (off_t) iflp->l_start;
239         oflp->l_len = (off_t) iflp->l_len;
240         oflp->l_pid = (pid_t) iflp->l_pid;
241
242 }
243
244
245 static int
246 fd_revoke(struct proc *p, int fd)
247 {
248         struct filedesc *fdp = p->p_fd;
249         struct file *fp;
250         struct vnode *vp;
251         struct vattr vattr;
252         int error, *retval;
253
254         retval = p->p_retval;
255         if ((u_int)fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL)
256                 return EBADF;
257
258         if (fp->f_type != DTYPE_VNODE) 
259                 return EINVAL;
260
261         vp = (struct vnode *) fp->f_data;
262
263         if (vp->v_type != VCHR && vp->v_type != VBLK) {
264                 error = EINVAL;
265                 goto out;
266         }
267
268         if ((error = VOP_GETATTR(vp, &vattr, p->p_ucred, p)) != 0)
269                 goto out;
270
271         if (p->p_ucred->cr_uid != vattr.va_uid &&
272             (error = suser_xxx(p->p_ucred, 0)) != 0)
273                 goto out;
274
275         if (vcount(vp) > 1)
276                 VOP_REVOKE(vp, REVOKEALL);
277 out:
278         vrele(vp);
279         return error;
280 }
281
282
283 static int
284 fd_truncate(struct proc *p, int fd, struct flock *flp)
285 {
286         struct filedesc *fdp = p->p_fd;
287         struct file *fp;
288         off_t start, length;
289         struct vnode *vp;
290         struct vattr vattr;
291         int error, *retval;
292         struct ftruncate_args ft;
293
294         retval = p->p_retval;
295
296         /*
297          * We only support truncating the file.
298          */
299         if ((u_int)fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL)
300                 return EBADF;
301
302         vp = (struct vnode *)fp->f_data;
303         if (fp->f_type != DTYPE_VNODE || vp->v_type == VFIFO)
304                 return ESPIPE;
305
306         if ((error = VOP_GETATTR(vp, &vattr, p->p_ucred, p)) != 0)
307                 return error;
308
309         length = vattr.va_size;
310
311         switch (flp->l_whence) {
312         case SEEK_CUR:
313                 start = fp->f_offset + flp->l_start;
314                 break;
315
316         case SEEK_END:
317                 start = flp->l_start + length;
318                 break;
319
320         case SEEK_SET:
321                 start = flp->l_start;
322                 break;
323
324         default:
325                 return EINVAL;
326         }
327
328         if (start + flp->l_len < length) {
329                 /* We don't support free'ing in the middle of the file */
330                 return EINVAL;
331         }
332
333         SCARG(&ft, fd) = fd;
334         SCARG(&ft, length) = start;
335
336         return ftruncate(&ft);
337 }
338
339 int
340 svr4_sys_open(struct svr4_sys_open_args *uap)
341 {
342         struct proc *p = curproc;
343         int                     error, retval;
344         struct open_args        cup;
345
346         caddr_t sg = stackgap_init();
347         CHECKALTEXIST(&sg, SCARG(uap, path));
348
349         (&cup)->path = uap->path;
350         (&cup)->flags = svr4_to_bsd_flags(uap->flags);
351         (&cup)->mode = uap->mode;
352         error = open(&cup);
353
354         if (error) {
355           /*            uprintf("svr4_open(%s, 0x%0x, 0%o): %d\n", uap->path,
356                         uap->flags, uap->mode, error);*/
357                 return error;
358         }
359
360         retval = p->p_retval[0];
361
362         if (!(SCARG(&cup, flags) & O_NOCTTY) && SESS_LEADER(p) &&
363             !(p->p_flag & P_CONTROLT)) {
364 #if defined(NOTYET)
365                 struct filedesc *fdp = p->p_fd;
366                 struct file     *fp = fdp->fd_ofiles[retval];
367
368                 /* ignore any error, just give it a try */
369                 if (fp->f_type == DTYPE_VNODE)
370                         fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, p);
371 #endif
372         }
373         return error;
374 }
375
376 int
377 svr4_sys_open64(struct svr4_sys_open64_args *uap)
378 {
379         return svr4_sys_open((struct svr4_sys_open_args *)uap);
380 }
381
382 int
383 svr4_sys_creat(struct svr4_sys_creat_args *uap)
384 {
385         struct open_args cup;
386
387         caddr_t sg = stackgap_init();
388         CHECKALTEXIST(&sg, SCARG(uap, path));
389
390         SCARG(&cup, path) = SCARG(uap, path);
391         SCARG(&cup, mode) = SCARG(uap, mode);
392         SCARG(&cup, flags) = O_WRONLY | O_CREAT | O_TRUNC;
393
394         return open(&cup);
395 }
396
397 int
398 svr4_sys_creat64(struct svr4_sys_creat64_args *uap)
399 {
400         return svr4_sys_creat((struct svr4_sys_creat_args *)uap);
401 }
402
403 int
404 svr4_sys_llseek(struct svr4_sys_llseek_args *v)
405 {
406         struct svr4_sys_llseek_args *uap = v;
407         struct lseek_args ap;
408
409         SCARG(&ap, fd) = SCARG(uap, fd);
410
411 #if BYTE_ORDER == BIG_ENDIAN
412         SCARG(&ap, offset) = (((long long) SCARG(uap, offset1)) << 32) | 
413                 SCARG(uap, offset2);
414 #else
415         SCARG(&ap, offset) = (((long long) SCARG(uap, offset2)) << 32) | 
416                 SCARG(uap, offset1);
417 #endif
418         SCARG(&ap, whence) = SCARG(uap, whence);
419
420         return lseek(&ap);
421 }
422
423 int
424 svr4_sys_access(struct svr4_sys_access_args *uap)
425 {
426         struct proc *p = curproc;
427         struct access_args cup;
428         int *retval;
429
430         caddr_t sg = stackgap_init();
431         CHECKALTEXIST(&sg, SCARG(uap, path));
432
433         retval = p->p_retval;
434
435         SCARG(&cup, path) = SCARG(uap, path);
436         SCARG(&cup, flags) = SCARG(uap, flags);
437
438         return access(&cup);
439 }
440
441 #if defined(NOTYET)
442 int
443 svr4_sys_pread(struct svr4_sys_pread_args *uap)
444 {
445         struct pread_args pra;
446
447         /*
448          * Just translate the args structure and call the NetBSD
449          * pread(2) system call (offset type is 64-bit in NetBSD).
450          */
451         SCARG(&pra, fd) = SCARG(uap, fd);
452         SCARG(&pra, buf) = SCARG(uap, buf);
453         SCARG(&pra, nbyte) = SCARG(uap, nbyte);
454         SCARG(&pra, offset) = SCARG(uap, off);
455
456         return pread(&pra);
457 }
458 #endif
459
460 #if defined(NOTYET)
461 int
462 svr4_sys_pread64(p, v, retval)
463         register struct proc *p;
464         void *v; 
465         register_t *retval;
466 {
467
468         struct svr4_sys_pread64_args *uap = v;
469         struct sys_pread_args pra;
470
471         /*
472          * Just translate the args structure and call the NetBSD
473          * pread(2) system call (offset type is 64-bit in NetBSD).
474          */
475         SCARG(&pra, fd) = SCARG(uap, fd);
476         SCARG(&pra, buf) = SCARG(uap, buf);
477         SCARG(&pra, nbyte) = SCARG(uap, nbyte);
478         SCARG(&pra, offset) = SCARG(uap, off);
479
480         return (sys_pread(&pra, retval));
481 }
482 #endif /* NOTYET */
483
484 #if defined(NOTYET)
485 int
486 svr4_sys_pwrite(struct svr4_sys_pwrite_args *uap)
487 {
488         struct pwrite_args pwa;
489
490         /*
491          * Just translate the args structure and call the NetBSD
492          * pwrite(2) system call (offset type is 64-bit in NetBSD).
493          */
494         SCARG(&pwa, fd) = SCARG(uap, fd);
495         SCARG(&pwa, buf) = SCARG(uap, buf);
496         SCARG(&pwa, nbyte) = SCARG(uap, nbyte);
497         SCARG(&pwa, offset) = SCARG(uap, off);
498
499         return pwrite(&pwa);
500 }
501 #endif
502
503 #if defined(NOTYET)
504 int
505 svr4_sys_pwrite64(p, v, retval)
506         register struct proc *p;
507         void *v; 
508         register_t *retval;
509 {
510         struct svr4_sys_pwrite64_args *uap = v;
511         struct sys_pwrite_args pwa;
512
513         /*
514          * Just translate the args structure and call the NetBSD
515          * pwrite(2) system call (offset type is 64-bit in NetBSD).
516          */
517         SCARG(&pwa, fd) = SCARG(uap, fd);
518         SCARG(&pwa, buf) = SCARG(uap, buf);
519         SCARG(&pwa, nbyte) = SCARG(uap, nbyte);
520         SCARG(&pwa, offset) = SCARG(uap, off);
521
522         return (sys_pwrite(p, &pwa, retval));
523 }
524 #endif /* NOTYET */
525
526 int
527 svr4_sys_fcntl(struct svr4_sys_fcntl_args *uap)
528 {
529         struct proc *p = curproc;
530         int                             error;
531         struct fcntl_args               fa;
532         int                             *retval;
533
534         retval = p->p_retval;
535
536         SCARG(&fa, fd) = SCARG(uap, fd);
537         SCARG(&fa, cmd) = svr4_to_bsd_cmd(SCARG(uap, cmd));
538
539         switch (SCARG(&fa, cmd)) {
540         case F_DUPFD:
541         case F_GETFD:
542         case F_SETFD:
543                 SCARG(&fa, arg) = (long) SCARG(uap, arg);
544                 return fcntl(&fa);
545
546         case F_GETFL:
547                 SCARG(&fa, arg) = (long) SCARG(uap, arg);
548                 error = fcntl(&fa);
549                 if (error)
550                         return error;
551                 *retval = bsd_to_svr4_flags(*retval);
552                 return error;
553
554         case F_SETFL:
555                 {
556                         /*
557                          * we must save the O_ASYNC flag, as that is
558                          * handled by ioctl(_, I_SETSIG, _) emulation.
559                          */
560                         long cmd;
561                         int flags;
562
563                         DPRINTF(("Setting flags 0x%x\n", SCARG(uap, arg)));
564                         cmd = SCARG(&fa, cmd); /* save it for a while */
565
566                         SCARG(&fa, cmd) = F_GETFL;
567                         if ((error = fcntl(&fa)) != 0)
568                                 return error;
569                         flags = *retval;
570                         flags &= O_ASYNC;
571                         flags |= svr4_to_bsd_flags((u_long) SCARG(uap, arg));
572                         SCARG(&fa, cmd) = cmd;
573                         SCARG(&fa, arg) = (long) flags;
574                         return fcntl(&fa);
575                 }
576
577         case F_GETLK:
578         case F_SETLK:
579         case F_SETLKW:
580                 {
581                         struct svr4_flock        ifl;
582                         struct flock            *flp, fl;
583                         caddr_t sg = stackgap_init();
584
585                         flp = stackgap_alloc(&sg, sizeof(struct flock));
586                         SCARG(&fa, arg) = (long) flp;
587
588                         error = copyin(SCARG(uap, arg), &ifl, sizeof ifl);
589                         if (error)
590                                 return error;
591
592                         svr4_to_bsd_flock(&ifl, &fl);
593
594                         error = copyout(&fl, flp, sizeof fl);
595                         if (error)
596                                 return error;
597
598                         error = fcntl(&fa);
599                         if (error || SCARG(&fa, cmd) != F_GETLK)
600                                 return error;
601
602                         error = copyin(flp, &fl, sizeof fl);
603                         if (error)
604                                 return error;
605
606                         bsd_to_svr4_flock(&fl, &ifl);
607
608                         return copyout(&ifl, SCARG(uap, arg), sizeof ifl);
609                 }
610         case -1:
611                 switch (SCARG(uap, cmd)) {
612                 case SVR4_F_DUP2FD:
613                         {
614                                 struct dup2_args du;
615
616                                 SCARG(&du, from) = SCARG(uap, fd);
617                                 SCARG(&du, to) = (int)SCARG(uap, arg);
618                                 error = dup2(&du);
619                                 if (error)
620                                         return error;
621                                 *retval = SCARG(&du, to);
622                                 return 0;
623                         }
624
625                 case SVR4_F_FREESP:
626                         {
627                                 struct svr4_flock        ifl;
628                                 struct flock             fl;
629
630                                 error = copyin(SCARG(uap, arg), &ifl,
631                                     sizeof ifl);
632                                 if (error)
633                                         return error;
634                                 svr4_to_bsd_flock(&ifl, &fl);
635                                 return fd_truncate(p, SCARG(uap, fd), &fl);
636                         }
637
638                 case SVR4_F_GETLK64:
639                 case SVR4_F_SETLK64:
640                 case SVR4_F_SETLKW64:
641                         {
642                                 struct svr4_flock64      ifl;
643                                 struct flock            *flp, fl;
644                                 caddr_t sg = stackgap_init();
645
646                                 flp = stackgap_alloc(&sg, sizeof(struct flock));
647                                 SCARG(&fa, arg) = (long) flp;
648
649                                 error = copyin(SCARG(uap, arg), &ifl,
650                                     sizeof ifl);
651                                 if (error)
652                                         return error;
653
654                                 svr4_to_bsd_flock64(&ifl, &fl);
655
656                                 error = copyout(&fl, flp, sizeof fl);
657                                 if (error)
658                                         return error;
659
660                                 error = fcntl(&fa);
661                                 if (error || SCARG(&fa, cmd) != F_GETLK)
662                                         return error;
663
664                                 error = copyin(flp, &fl, sizeof fl);
665                                 if (error)
666                                         return error;
667
668                                 bsd_to_svr4_flock64(&fl, &ifl);
669
670                                 return copyout(&ifl, SCARG(uap, arg),
671                                     sizeof ifl);
672                         }
673
674                 case SVR4_F_FREESP64:
675                         {
676                                 struct svr4_flock64      ifl;
677                                 struct flock             fl;
678
679                                 error = copyin(SCARG(uap, arg), &ifl,
680                                     sizeof ifl);
681                                 if (error)
682                                         return error;
683                                 svr4_to_bsd_flock64(&ifl, &fl);
684                                 return fd_truncate(p, SCARG(uap, fd), &fl);
685                         }
686
687                 case SVR4_F_REVOKE:
688                         return fd_revoke(p, SCARG(uap, fd));
689
690                 default:
691                         return ENOSYS;
692                 }
693
694         default:
695                 return ENOSYS;
696         }
697 }