Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[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.2 2003/06/17 04:28:57 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(p, fd)
247         struct proc *p;
248         int fd;
249 {
250         struct filedesc *fdp = p->p_fd;
251         struct file *fp;
252         struct vnode *vp;
253         struct vattr vattr;
254         int error, *retval;
255
256         retval = p->p_retval;
257         if ((u_int)fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL)
258                 return EBADF;
259
260         if (fp->f_type != DTYPE_VNODE) 
261                 return EINVAL;
262
263         vp = (struct vnode *) fp->f_data;
264
265         if (vp->v_type != VCHR && vp->v_type != VBLK) {
266                 error = EINVAL;
267                 goto out;
268         }
269
270         if ((error = VOP_GETATTR(vp, &vattr, p->p_ucred, p)) != 0)
271                 goto out;
272
273         if (p->p_ucred->cr_uid != vattr.va_uid &&
274             (error = suser(p)) != 0)
275                 goto out;
276
277         if (vcount(vp) > 1)
278                 VOP_REVOKE(vp, REVOKEALL);
279 out:
280         vrele(vp);
281         return error;
282 }
283
284
285 static int
286 fd_truncate(p, fd, flp)
287         struct proc *p;
288         int fd;
289         struct flock *flp;
290 {
291         struct filedesc *fdp = p->p_fd;
292         struct file *fp;
293         off_t start, length;
294         struct vnode *vp;
295         struct vattr vattr;
296         int error, *retval;
297         struct ftruncate_args ft;
298
299         retval = p->p_retval;
300
301         /*
302          * We only support truncating the file.
303          */
304         if ((u_int)fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL)
305                 return EBADF;
306
307         vp = (struct vnode *)fp->f_data;
308         if (fp->f_type != DTYPE_VNODE || vp->v_type == VFIFO)
309                 return ESPIPE;
310
311         if ((error = VOP_GETATTR(vp, &vattr, p->p_ucred, p)) != 0)
312                 return error;
313
314         length = vattr.va_size;
315
316         switch (flp->l_whence) {
317         case SEEK_CUR:
318                 start = fp->f_offset + flp->l_start;
319                 break;
320
321         case SEEK_END:
322                 start = flp->l_start + length;
323                 break;
324
325         case SEEK_SET:
326                 start = flp->l_start;
327                 break;
328
329         default:
330                 return EINVAL;
331         }
332
333         if (start + flp->l_len < length) {
334                 /* We don't support free'ing in the middle of the file */
335                 return EINVAL;
336         }
337
338         SCARG(&ft, fd) = fd;
339         SCARG(&ft, length) = start;
340
341         return ftruncate(p, &ft);
342 }
343
344 int
345 svr4_sys_open(p, uap)
346         register struct proc *p;
347         struct svr4_sys_open_args *uap;
348 {
349         int                     error, retval;
350         struct open_args        cup;
351
352         caddr_t sg = stackgap_init();
353         CHECKALTEXIST(p, &sg, SCARG(uap, path));
354
355         (&cup)->path = uap->path;
356         (&cup)->flags = svr4_to_bsd_flags(uap->flags);
357         (&cup)->mode = uap->mode;
358         error = open(p, &cup);
359
360         if (error) {
361           /*            uprintf("svr4_open(%s, 0x%0x, 0%o): %d\n", uap->path,
362                         uap->flags, uap->mode, error);*/
363                 return error;
364         }
365
366         retval = p->p_retval[0];
367
368         if (!(SCARG(&cup, flags) & O_NOCTTY) && SESS_LEADER(p) &&
369             !(p->p_flag & P_CONTROLT)) {
370 #if defined(NOTYET)
371                 struct filedesc *fdp = p->p_fd;
372                 struct file     *fp = fdp->fd_ofiles[retval];
373
374                 /* ignore any error, just give it a try */
375                 if (fp->f_type == DTYPE_VNODE)
376                         fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, p);
377 #endif
378         }
379         return error;
380 }
381
382 int
383 svr4_sys_open64(p, uap)
384         register struct proc *p;
385         struct svr4_sys_open64_args *uap;
386 {
387         return svr4_sys_open(p, (struct svr4_sys_open_args *)uap);
388 }
389
390 int
391 svr4_sys_creat(p, uap)
392         register struct proc *p;
393         struct svr4_sys_creat_args *uap;
394 {
395         struct open_args cup;
396
397         caddr_t sg = stackgap_init();
398         CHECKALTEXIST(p, &sg, SCARG(uap, path));
399
400         SCARG(&cup, path) = SCARG(uap, path);
401         SCARG(&cup, mode) = SCARG(uap, mode);
402         SCARG(&cup, flags) = O_WRONLY | O_CREAT | O_TRUNC;
403
404         return open(p, &cup);
405 }
406
407 int
408 svr4_sys_creat64(p, uap)
409         register struct proc *p;
410         struct svr4_sys_creat64_args *uap;
411 {
412         return svr4_sys_creat(p, (struct svr4_sys_creat_args *)uap);
413 }
414
415 int
416 svr4_sys_llseek(p, v)
417         register struct proc *p;
418         struct svr4_sys_llseek_args *v;
419 {
420         struct svr4_sys_llseek_args *uap = v;
421         struct lseek_args ap;
422
423         SCARG(&ap, fd) = SCARG(uap, fd);
424
425 #if BYTE_ORDER == BIG_ENDIAN
426         SCARG(&ap, offset) = (((long long) SCARG(uap, offset1)) << 32) | 
427                 SCARG(uap, offset2);
428 #else
429         SCARG(&ap, offset) = (((long long) SCARG(uap, offset2)) << 32) | 
430                 SCARG(uap, offset1);
431 #endif
432         SCARG(&ap, whence) = SCARG(uap, whence);
433
434         return lseek(p, &ap);
435 }
436
437 int
438 svr4_sys_access(p, uap)
439         register struct proc *p;
440         struct svr4_sys_access_args *uap;
441 {
442         struct access_args cup;
443         int *retval;
444
445         caddr_t sg = stackgap_init();
446         CHECKALTEXIST(p, &sg, SCARG(uap, path));
447
448         retval = p->p_retval;
449
450         SCARG(&cup, path) = SCARG(uap, path);
451         SCARG(&cup, flags) = SCARG(uap, flags);
452
453         return access(p, &cup);
454 }
455
456 #if defined(NOTYET)
457 int
458 svr4_sys_pread(p, uap)
459         register struct proc *p;
460         struct svr4_sys_pread_args *uap;
461 {
462         struct pread_args pra;
463
464         /*
465          * Just translate the args structure and call the NetBSD
466          * pread(2) system call (offset type is 64-bit in NetBSD).
467          */
468         SCARG(&pra, fd) = SCARG(uap, fd);
469         SCARG(&pra, buf) = SCARG(uap, buf);
470         SCARG(&pra, nbyte) = SCARG(uap, nbyte);
471         SCARG(&pra, offset) = SCARG(uap, off);
472
473         return pread(p, &pra);
474 }
475 #endif
476
477 #if defined(NOTYET)
478 int
479 svr4_sys_pread64(p, v, retval)
480         register struct proc *p;
481         void *v; 
482         register_t *retval;
483 {
484
485         struct svr4_sys_pread64_args *uap = v;
486         struct sys_pread_args pra;
487
488         /*
489          * Just translate the args structure and call the NetBSD
490          * pread(2) system call (offset type is 64-bit in NetBSD).
491          */
492         SCARG(&pra, fd) = SCARG(uap, fd);
493         SCARG(&pra, buf) = SCARG(uap, buf);
494         SCARG(&pra, nbyte) = SCARG(uap, nbyte);
495         SCARG(&pra, offset) = SCARG(uap, off);
496
497         return (sys_pread(p, &pra, retval));
498 }
499 #endif /* NOTYET */
500
501 #if defined(NOTYET)
502 int
503 svr4_sys_pwrite(p, uap)
504         register struct proc *p;
505         struct svr4_sys_pwrite_args *uap;
506 {
507         struct pwrite_args pwa;
508
509         /*
510          * Just translate the args structure and call the NetBSD
511          * pwrite(2) system call (offset type is 64-bit in NetBSD).
512          */
513         SCARG(&pwa, fd) = SCARG(uap, fd);
514         SCARG(&pwa, buf) = SCARG(uap, buf);
515         SCARG(&pwa, nbyte) = SCARG(uap, nbyte);
516         SCARG(&pwa, offset) = SCARG(uap, off);
517
518         return pwrite(p, &pwa);
519 }
520 #endif
521
522 #if defined(NOTYET)
523 int
524 svr4_sys_pwrite64(p, v, retval)
525         register struct proc *p;
526         void *v; 
527         register_t *retval;
528 {
529         struct svr4_sys_pwrite64_args *uap = v;
530         struct sys_pwrite_args pwa;
531
532         /*
533          * Just translate the args structure and call the NetBSD
534          * pwrite(2) system call (offset type is 64-bit in NetBSD).
535          */
536         SCARG(&pwa, fd) = SCARG(uap, fd);
537         SCARG(&pwa, buf) = SCARG(uap, buf);
538         SCARG(&pwa, nbyte) = SCARG(uap, nbyte);
539         SCARG(&pwa, offset) = SCARG(uap, off);
540
541         return (sys_pwrite(p, &pwa, retval));
542 }
543 #endif /* NOTYET */
544
545 int
546 svr4_sys_fcntl(p, uap)
547         register struct proc *p;
548         struct svr4_sys_fcntl_args *uap;
549 {
550         int                             error;
551         struct fcntl_args               fa;
552         int                             *retval;
553
554         retval = p->p_retval;
555
556         SCARG(&fa, fd) = SCARG(uap, fd);
557         SCARG(&fa, cmd) = svr4_to_bsd_cmd(SCARG(uap, cmd));
558
559         switch (SCARG(&fa, cmd)) {
560         case F_DUPFD:
561         case F_GETFD:
562         case F_SETFD:
563                 SCARG(&fa, arg) = (long) SCARG(uap, arg);
564                 return fcntl(p, &fa);
565
566         case F_GETFL:
567                 SCARG(&fa, arg) = (long) SCARG(uap, arg);
568                 error = fcntl(p, &fa);
569                 if (error)
570                         return error;
571                 *retval = bsd_to_svr4_flags(*retval);
572                 return error;
573
574         case F_SETFL:
575                 {
576                         /*
577                          * we must save the O_ASYNC flag, as that is
578                          * handled by ioctl(_, I_SETSIG, _) emulation.
579                          */
580                         long cmd;
581                         int flags;
582
583                         DPRINTF(("Setting flags 0x%x\n", SCARG(uap, arg)));
584                         cmd = SCARG(&fa, cmd); /* save it for a while */
585
586                         SCARG(&fa, cmd) = F_GETFL;
587                         if ((error = fcntl(p, &fa)) != 0)
588                                 return error;
589                         flags = *retval;
590                         flags &= O_ASYNC;
591                         flags |= svr4_to_bsd_flags((u_long) SCARG(uap, arg));
592                         SCARG(&fa, cmd) = cmd;
593                         SCARG(&fa, arg) = (long) flags;
594                         return fcntl(p, &fa);
595                 }
596
597         case F_GETLK:
598         case F_SETLK:
599         case F_SETLKW:
600                 {
601                         struct svr4_flock        ifl;
602                         struct flock            *flp, fl;
603                         caddr_t sg = stackgap_init();
604
605                         flp = stackgap_alloc(&sg, sizeof(struct flock));
606                         SCARG(&fa, arg) = (long) flp;
607
608                         error = copyin(SCARG(uap, arg), &ifl, sizeof ifl);
609                         if (error)
610                                 return error;
611
612                         svr4_to_bsd_flock(&ifl, &fl);
613
614                         error = copyout(&fl, flp, sizeof fl);
615                         if (error)
616                                 return error;
617
618                         error = fcntl(p, &fa);
619                         if (error || SCARG(&fa, cmd) != F_GETLK)
620                                 return error;
621
622                         error = copyin(flp, &fl, sizeof fl);
623                         if (error)
624                                 return error;
625
626                         bsd_to_svr4_flock(&fl, &ifl);
627
628                         return copyout(&ifl, SCARG(uap, arg), sizeof ifl);
629                 }
630         case -1:
631                 switch (SCARG(uap, cmd)) {
632                 case SVR4_F_DUP2FD:
633                         {
634                                 struct dup2_args du;
635
636                                 SCARG(&du, from) = SCARG(uap, fd);
637                                 SCARG(&du, to) = (int)SCARG(uap, arg);
638                                 error = dup2(p, &du);
639                                 if (error)
640                                         return error;
641                                 *retval = SCARG(&du, to);
642                                 return 0;
643                         }
644
645                 case SVR4_F_FREESP:
646                         {
647                                 struct svr4_flock        ifl;
648                                 struct flock             fl;
649
650                                 error = copyin(SCARG(uap, arg), &ifl,
651                                     sizeof ifl);
652                                 if (error)
653                                         return error;
654                                 svr4_to_bsd_flock(&ifl, &fl);
655                                 return fd_truncate(p, SCARG(uap, fd), &fl);
656                         }
657
658                 case SVR4_F_GETLK64:
659                 case SVR4_F_SETLK64:
660                 case SVR4_F_SETLKW64:
661                         {
662                                 struct svr4_flock64      ifl;
663                                 struct flock            *flp, fl;
664                                 caddr_t sg = stackgap_init();
665
666                                 flp = stackgap_alloc(&sg, sizeof(struct flock));
667                                 SCARG(&fa, arg) = (long) flp;
668
669                                 error = copyin(SCARG(uap, arg), &ifl,
670                                     sizeof ifl);
671                                 if (error)
672                                         return error;
673
674                                 svr4_to_bsd_flock64(&ifl, &fl);
675
676                                 error = copyout(&fl, flp, sizeof fl);
677                                 if (error)
678                                         return error;
679
680                                 error = fcntl(p, &fa);
681                                 if (error || SCARG(&fa, cmd) != F_GETLK)
682                                         return error;
683
684                                 error = copyin(flp, &fl, sizeof fl);
685                                 if (error)
686                                         return error;
687
688                                 bsd_to_svr4_flock64(&fl, &ifl);
689
690                                 return copyout(&ifl, SCARG(uap, arg),
691                                     sizeof ifl);
692                         }
693
694                 case SVR4_F_FREESP64:
695                         {
696                                 struct svr4_flock64      ifl;
697                                 struct flock             fl;
698
699                                 error = copyin(SCARG(uap, arg), &ifl,
700                                     sizeof ifl);
701                                 if (error)
702                                         return error;
703                                 svr4_to_bsd_flock64(&ifl, &fl);
704                                 return fd_truncate(p, SCARG(uap, fd), &fl);
705                         }
706
707                 case SVR4_F_REVOKE:
708                         return fd_revoke(p, SCARG(uap, fd));
709
710                 default:
711                         return ENOSYS;
712                 }
713
714         default:
715                 return ENOSYS;
716         }
717 }