svr4_fcntl.c revision 89306
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: head/sys/compat/svr4/svr4_fcntl.c 89306 2002-01-13 11:58:06Z alfred $
32 */
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/file.h>
36#include <sys/filedesc.h>
37/*#include <sys/ioctl.h>*/
38#include <sys/lock.h>
39#include <sys/mount.h>
40#include <sys/mutex.h>
41#include <sys/namei.h>
42#include <sys/proc.h>
43#include <sys/stat.h>
44#include <sys/unistd.h>
45#include <sys/vnode.h>
46
47#include <sys/sysproto.h>
48
49#include <compat/svr4/svr4.h>
50#include <compat/svr4/svr4_types.h>
51#include <compat/svr4/svr4_signal.h>
52#include <compat/svr4/svr4_proto.h>
53#include <compat/svr4/svr4_util.h>
54#include <compat/svr4/svr4_fcntl.h>
55
56static int svr4_to_bsd_flags __P((int));
57static u_long svr4_to_bsd_cmd __P((u_long));
58static int fd_revoke __P((struct thread *, int));
59static int fd_truncate __P((struct thread *, int, struct flock *));
60static int bsd_to_svr4_flags __P((int));
61static void bsd_to_svr4_flock __P((struct flock *, struct svr4_flock *));
62static void svr4_to_bsd_flock __P((struct svr4_flock *, struct flock *));
63static void bsd_to_svr4_flock64 __P((struct flock *, struct svr4_flock64 *));
64static void svr4_to_bsd_flock64 __P((struct svr4_flock64 *, struct flock *));
65
66static u_long
67svr4_to_bsd_cmd(cmd)
68	u_long	cmd;
69{
70	switch (cmd) {
71	case SVR4_F_DUPFD:
72		return F_DUPFD;
73	case SVR4_F_GETFD:
74		return F_GETFD;
75	case SVR4_F_SETFD:
76		return F_SETFD;
77	case SVR4_F_GETFL:
78		return F_GETFL;
79	case SVR4_F_SETFL:
80		return F_SETFL;
81	case SVR4_F_GETLK:
82		return F_GETLK;
83	case SVR4_F_SETLK:
84		return F_SETLK;
85	case SVR4_F_SETLKW:
86		return F_SETLKW;
87	default:
88		return -1;
89	}
90}
91
92static int
93svr4_to_bsd_flags(l)
94	int	l;
95{
96	int	r = 0;
97	r |= (l & SVR4_O_RDONLY) ? O_RDONLY : 0;
98	r |= (l & SVR4_O_WRONLY) ? O_WRONLY : 0;
99	r |= (l & SVR4_O_RDWR) ? O_RDWR : 0;
100	r |= (l & SVR4_O_NDELAY) ? O_NONBLOCK : 0;
101	r |= (l & SVR4_O_APPEND) ? O_APPEND : 0;
102	r |= (l & SVR4_O_SYNC) ? O_FSYNC : 0;
103	r |= (l & SVR4_O_NONBLOCK) ? O_NONBLOCK : 0;
104	r |= (l & SVR4_O_PRIV) ? O_EXLOCK : 0;
105	r |= (l & SVR4_O_CREAT) ? O_CREAT : 0;
106	r |= (l & SVR4_O_TRUNC) ? O_TRUNC : 0;
107	r |= (l & SVR4_O_EXCL) ? O_EXCL : 0;
108	r |= (l & SVR4_O_NOCTTY) ? O_NOCTTY : 0;
109	return r;
110}
111
112static int
113bsd_to_svr4_flags(l)
114	int	l;
115{
116	int	r = 0;
117	r |= (l & O_RDONLY) ? SVR4_O_RDONLY : 0;
118	r |= (l & O_WRONLY) ? SVR4_O_WRONLY : 0;
119	r |= (l & O_RDWR) ? SVR4_O_RDWR : 0;
120	r |= (l & O_NDELAY) ? SVR4_O_NONBLOCK : 0;
121	r |= (l & O_APPEND) ? SVR4_O_APPEND : 0;
122	r |= (l & O_FSYNC) ? SVR4_O_SYNC : 0;
123	r |= (l & O_NONBLOCK) ? SVR4_O_NONBLOCK : 0;
124	r |= (l & O_EXLOCK) ? SVR4_O_PRIV : 0;
125	r |= (l & O_CREAT) ? SVR4_O_CREAT : 0;
126	r |= (l & O_TRUNC) ? SVR4_O_TRUNC : 0;
127	r |= (l & O_EXCL) ? SVR4_O_EXCL : 0;
128	r |= (l & O_NOCTTY) ? SVR4_O_NOCTTY : 0;
129	return r;
130}
131
132
133static void
134bsd_to_svr4_flock(iflp, oflp)
135	struct flock		*iflp;
136	struct svr4_flock	*oflp;
137{
138	switch (iflp->l_type) {
139	case F_RDLCK:
140		oflp->l_type = SVR4_F_RDLCK;
141		break;
142	case F_WRLCK:
143		oflp->l_type = SVR4_F_WRLCK;
144		break;
145	case F_UNLCK:
146		oflp->l_type = SVR4_F_UNLCK;
147		break;
148	default:
149		oflp->l_type = -1;
150		break;
151	}
152
153	oflp->l_whence = (short) iflp->l_whence;
154	oflp->l_start = (svr4_off_t) iflp->l_start;
155	oflp->l_len = (svr4_off_t) iflp->l_len;
156	oflp->l_sysid = 0;
157	oflp->l_pid = (svr4_pid_t) iflp->l_pid;
158}
159
160
161static void
162svr4_to_bsd_flock(iflp, oflp)
163	struct svr4_flock	*iflp;
164	struct flock		*oflp;
165{
166	switch (iflp->l_type) {
167	case SVR4_F_RDLCK:
168		oflp->l_type = F_RDLCK;
169		break;
170	case SVR4_F_WRLCK:
171		oflp->l_type = F_WRLCK;
172		break;
173	case SVR4_F_UNLCK:
174		oflp->l_type = F_UNLCK;
175		break;
176	default:
177		oflp->l_type = -1;
178		break;
179	}
180
181	oflp->l_whence = iflp->l_whence;
182	oflp->l_start = (off_t) iflp->l_start;
183	oflp->l_len = (off_t) iflp->l_len;
184	oflp->l_pid = (pid_t) iflp->l_pid;
185
186}
187
188static void
189bsd_to_svr4_flock64(iflp, oflp)
190	struct flock		*iflp;
191	struct svr4_flock64	*oflp;
192{
193	switch (iflp->l_type) {
194	case F_RDLCK:
195		oflp->l_type = SVR4_F_RDLCK;
196		break;
197	case F_WRLCK:
198		oflp->l_type = SVR4_F_WRLCK;
199		break;
200	case F_UNLCK:
201		oflp->l_type = SVR4_F_UNLCK;
202		break;
203	default:
204		oflp->l_type = -1;
205		break;
206	}
207
208	oflp->l_whence = (short) iflp->l_whence;
209	oflp->l_start = (svr4_off64_t) iflp->l_start;
210	oflp->l_len = (svr4_off64_t) iflp->l_len;
211	oflp->l_sysid = 0;
212	oflp->l_pid = (svr4_pid_t) iflp->l_pid;
213}
214
215
216static void
217svr4_to_bsd_flock64(iflp, oflp)
218	struct svr4_flock64	*iflp;
219	struct flock		*oflp;
220{
221	switch (iflp->l_type) {
222	case SVR4_F_RDLCK:
223		oflp->l_type = F_RDLCK;
224		break;
225	case SVR4_F_WRLCK:
226		oflp->l_type = F_WRLCK;
227		break;
228	case SVR4_F_UNLCK:
229		oflp->l_type = F_UNLCK;
230		break;
231	default:
232		oflp->l_type = -1;
233		break;
234	}
235
236	oflp->l_whence = iflp->l_whence;
237	oflp->l_start = (off_t) iflp->l_start;
238	oflp->l_len = (off_t) iflp->l_len;
239	oflp->l_pid = (pid_t) iflp->l_pid;
240
241}
242
243
244static int
245fd_revoke(td, fd)
246	struct thread *td;
247	int fd;
248{
249	struct file *fp;
250	struct vnode *vp;
251	struct mount *mp;
252	struct vattr vattr;
253	int error, *retval;
254
255	retval = td->td_retval;
256	fp = ffind_hold(td, fd);
257	if (fp == NULL)
258		return EBADF;
259
260	if (fp->f_type != DTYPE_VNODE) {
261		fdrop(fp, td);
262		return EINVAL;
263	}
264
265	vp = (struct vnode *) fp->f_data;
266
267	if (vp->v_type != VCHR && vp->v_type != VBLK) {
268		error = EINVAL;
269		goto out;
270	}
271
272	if ((error = VOP_GETATTR(vp, &vattr, td->td_proc->p_ucred, td)) != 0)
273		goto out;
274
275	if (td->td_proc->p_ucred->cr_uid != vattr.va_uid &&
276	    (error = suser_td(td)) != 0)
277		goto out;
278
279	if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0)
280		goto out;
281	if (vcount(vp) > 1)
282		VOP_REVOKE(vp, REVOKEALL);
283	vn_finished_write(mp);
284out:
285	vrele(vp);
286	fdrop(fp, td);
287	return error;
288}
289
290
291static int
292fd_truncate(td, fd, flp)
293	struct thread *td;
294	int fd;
295	struct flock *flp;
296{
297	struct file *fp;
298	off_t start, length;
299	struct vnode *vp;
300	struct vattr vattr;
301	int error, *retval;
302	struct ftruncate_args ft;
303
304	retval = td->td_retval;
305
306	/*
307	 * We only support truncating the file.
308	 */
309	fp = ffind_hold(td, fd);
310	if (fp == NULL)
311		return EBADF;
312
313	vp = (struct vnode *)fp->f_data;
314	if (fp->f_type != DTYPE_VNODE || vp->v_type == VFIFO) {
315		fdrop(fp, td);
316		return ESPIPE;
317	}
318
319	if ((error = VOP_GETATTR(vp, &vattr, td->td_proc->p_ucred, td)) != 0)
320		fdrop(fp, td);
321		return error;
322	}
323
324	length = vattr.va_size;
325
326	switch (flp->l_whence) {
327	case SEEK_CUR:
328		start = fp->f_offset + flp->l_start;
329		break;
330
331	case SEEK_END:
332		start = flp->l_start + length;
333		break;
334
335	case SEEK_SET:
336		start = flp->l_start;
337		break;
338
339	default:
340		fdrop(fp, td);
341		return EINVAL;
342	}
343
344	if (start + flp->l_len < length) {
345		/* We don't support free'ing in the middle of the file */
346		return EINVAL;
347	}
348
349	SCARG(&ft, fd) = fd;
350	SCARG(&ft, length) = start;
351
352	error = ftruncate(td, &ft);
353
354	fdrop(fp, td);
355	return (error);
356}
357
358int
359svr4_sys_open(td, uap)
360	register struct thread *td;
361	struct svr4_sys_open_args *uap;
362{
363	struct proc *p = td->td_proc;
364	int			error, retval;
365	struct open_args	cup;
366
367	caddr_t sg = stackgap_init();
368	CHECKALTEXIST(td, &sg, SCARG(uap, path));
369
370	(&cup)->path = uap->path;
371	(&cup)->flags = svr4_to_bsd_flags(uap->flags);
372	(&cup)->mode = uap->mode;
373	error = open(td, &cup);
374
375	if (error) {
376	  /*	        uprintf("svr4_open(%s, 0x%0x, 0%o): %d\n", uap->path,
377			uap->flags, uap->mode, error);*/
378		return error;
379	}
380
381	retval = td->td_retval[0];
382
383	PROC_LOCK(p);
384	if (!(SCARG(&cup, flags) & O_NOCTTY) && SESS_LEADER(p) &&
385	    !(td->td_proc->p_flag & P_CONTROLT)) {
386#if defined(NOTYET)
387		struct file	*fp;
388
389		fp = ffind_hold(td, retval);
390		PROC_UNLOCK(p);
391		/*
392		 * we may have lost a race the above open() and
393		 * another thread issuing a close()
394		 */
395		if (fp == NULL)
396			return (EBADF);	/* XXX: correct errno? */
397		/* ignore any error, just give it a try */
398		if (fp->f_type == DTYPE_VNODE)
399			fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, td);
400		fdrop(fp, td);
401	} else {
402		PROC_UNLOCK(p);
403	}
404#else
405	}
406	PROC_UNLOCK(p);
407#endif
408	return error;
409}
410
411int
412svr4_sys_open64(td, uap)
413	register struct thread *td;
414	struct svr4_sys_open64_args *uap;
415{
416	return svr4_sys_open(td, (struct svr4_sys_open_args *)uap);
417}
418
419int
420svr4_sys_creat(td, uap)
421	register struct thread *td;
422	struct svr4_sys_creat_args *uap;
423{
424	struct open_args cup;
425
426	caddr_t sg = stackgap_init();
427	CHECKALTEXIST(td, &sg, SCARG(uap, path));
428
429	SCARG(&cup, path) = SCARG(uap, path);
430	SCARG(&cup, mode) = SCARG(uap, mode);
431	SCARG(&cup, flags) = O_WRONLY | O_CREAT | O_TRUNC;
432
433	return open(td, &cup);
434}
435
436int
437svr4_sys_creat64(td, uap)
438	register struct thread *td;
439	struct svr4_sys_creat64_args *uap;
440{
441	return svr4_sys_creat(td, (struct svr4_sys_creat_args *)uap);
442}
443
444int
445svr4_sys_llseek(td, uap)
446	register struct thread *td;
447	struct svr4_sys_llseek_args *uap;
448{
449	struct lseek_args ap;
450
451	SCARG(&ap, fd) = SCARG(uap, fd);
452
453#if BYTE_ORDER == BIG_ENDIAN
454	SCARG(&ap, offset) = (((u_int64_t) SCARG(uap, offset1)) << 32) |
455		SCARG(uap, offset2);
456#else
457	SCARG(&ap, offset) = (((u_int64_t) SCARG(uap, offset2)) << 32) |
458		SCARG(uap, offset1);
459#endif
460	SCARG(&ap, whence) = SCARG(uap, whence);
461
462	return lseek(td, &ap);
463}
464
465int
466svr4_sys_access(td, uap)
467	register struct thread *td;
468	struct svr4_sys_access_args *uap;
469{
470	struct access_args cup;
471	int *retval;
472
473	caddr_t sg = stackgap_init();
474	CHECKALTEXIST(td, &sg, SCARG(uap, path));
475
476	retval = td->td_retval;
477
478	SCARG(&cup, path) = SCARG(uap, path);
479	SCARG(&cup, flags) = SCARG(uap, flags);
480
481	return access(td, &cup);
482}
483
484#if defined(NOTYET)
485int
486svr4_sys_pread(td, uap)
487	register struct thread *td;
488	struct svr4_sys_pread_args *uap;
489{
490	struct pread_args pra;
491
492	/*
493	 * Just translate the args structure and call the NetBSD
494	 * pread(2) system call (offset type is 64-bit in NetBSD).
495	 */
496	SCARG(&pra, fd) = SCARG(uap, fd);
497	SCARG(&pra, buf) = SCARG(uap, buf);
498	SCARG(&pra, nbyte) = SCARG(uap, nbyte);
499	SCARG(&pra, offset) = SCARG(uap, off);
500
501	return pread(td, &pra);
502}
503#endif
504
505#if defined(NOTYET)
506int
507svr4_sys_pread64(td, v, retval)
508	register struct thread *td;
509	void *v;
510	register_t *retval;
511{
512
513	struct svr4_sys_pread64_args *uap = v;
514	struct sys_pread_args pra;
515
516	/*
517	 * Just translate the args structure and call the NetBSD
518	 * pread(2) system call (offset type is 64-bit in NetBSD).
519	 */
520	SCARG(&pra, fd) = SCARG(uap, fd);
521	SCARG(&pra, buf) = SCARG(uap, buf);
522	SCARG(&pra, nbyte) = SCARG(uap, nbyte);
523	SCARG(&pra, offset) = SCARG(uap, off);
524
525	return (sys_pread(td, &pra, retval));
526}
527#endif /* NOTYET */
528
529#if defined(NOTYET)
530int
531svr4_sys_pwrite(td, uap)
532	register struct thread *td;
533	struct svr4_sys_pwrite_args *uap;
534{
535	struct pwrite_args pwa;
536
537	/*
538	 * Just translate the args structure and call the NetBSD
539	 * pwrite(2) system call (offset type is 64-bit in NetBSD).
540	 */
541	SCARG(&pwa, fd) = SCARG(uap, fd);
542	SCARG(&pwa, buf) = SCARG(uap, buf);
543	SCARG(&pwa, nbyte) = SCARG(uap, nbyte);
544	SCARG(&pwa, offset) = SCARG(uap, off);
545
546	return pwrite(td, &pwa);
547}
548#endif
549
550#if defined(NOTYET)
551int
552svr4_sys_pwrite64(td, v, retval)
553	register struct thread *td;
554	void *v;
555	register_t *retval;
556{
557	struct svr4_sys_pwrite64_args *uap = v;
558	struct sys_pwrite_args pwa;
559
560	/*
561	 * Just translate the args structure and call the NetBSD
562	 * pwrite(2) system call (offset type is 64-bit in NetBSD).
563	 */
564	SCARG(&pwa, fd) = SCARG(uap, fd);
565	SCARG(&pwa, buf) = SCARG(uap, buf);
566	SCARG(&pwa, nbyte) = SCARG(uap, nbyte);
567	SCARG(&pwa, offset) = SCARG(uap, off);
568
569	return (sys_pwrite(td, &pwa, retval));
570}
571#endif /* NOTYET */
572
573int
574svr4_sys_fcntl(td, uap)
575	register struct thread *td;
576	struct svr4_sys_fcntl_args *uap;
577{
578	int				error;
579	struct fcntl_args		fa;
580	int                             *retval;
581
582	retval = td->td_retval;
583
584	SCARG(&fa, fd) = SCARG(uap, fd);
585	SCARG(&fa, cmd) = svr4_to_bsd_cmd(SCARG(uap, cmd));
586
587	switch (SCARG(&fa, cmd)) {
588	case F_DUPFD:
589	case F_GETFD:
590	case F_SETFD:
591		SCARG(&fa, arg) = (long) SCARG(uap, arg);
592		return fcntl(td, &fa);
593
594	case F_GETFL:
595		SCARG(&fa, arg) = (long) SCARG(uap, arg);
596		error = fcntl(td, &fa);
597		if (error)
598			return error;
599		*retval = bsd_to_svr4_flags(*retval);
600		return error;
601
602	case F_SETFL:
603		{
604			/*
605			 * we must save the O_ASYNC flag, as that is
606			 * handled by ioctl(_, I_SETSIG, _) emulation.
607			 */
608			long cmd;
609			int flags;
610
611			DPRINTF(("Setting flags %p\n", SCARG(uap, arg)));
612			cmd = SCARG(&fa, cmd); /* save it for a while */
613
614			SCARG(&fa, cmd) = F_GETFL;
615			if ((error = fcntl(td, &fa)) != 0)
616				return error;
617			flags = *retval;
618			flags &= O_ASYNC;
619			flags |= svr4_to_bsd_flags((u_long) SCARG(uap, arg));
620			SCARG(&fa, cmd) = cmd;
621			SCARG(&fa, arg) = (long) flags;
622			return fcntl(td, &fa);
623		}
624
625	case F_GETLK:
626	case F_SETLK:
627	case F_SETLKW:
628		{
629			struct svr4_flock	 ifl;
630			struct flock		*flp, fl;
631			caddr_t sg = stackgap_init();
632
633			flp = stackgap_alloc(&sg, sizeof(struct flock));
634			SCARG(&fa, arg) = (long) flp;
635
636			error = copyin(SCARG(uap, arg), &ifl, sizeof ifl);
637			if (error)
638				return error;
639
640			svr4_to_bsd_flock(&ifl, &fl);
641
642			error = copyout(&fl, flp, sizeof fl);
643			if (error)
644				return error;
645
646			error = fcntl(td, &fa);
647			if (error || SCARG(&fa, cmd) != F_GETLK)
648				return error;
649
650			error = copyin(flp, &fl, sizeof fl);
651			if (error)
652				return error;
653
654			bsd_to_svr4_flock(&fl, &ifl);
655
656			return copyout(&ifl, SCARG(uap, arg), sizeof ifl);
657		}
658	case -1:
659		switch (SCARG(uap, cmd)) {
660		case SVR4_F_DUP2FD:
661			{
662				struct dup2_args du;
663
664				SCARG(&du, from) = SCARG(uap, fd);
665				SCARG(&du, to) = (int)SCARG(uap, arg);
666				error = dup2(td, &du);
667				if (error)
668					return error;
669				*retval = SCARG(&du, to);
670				return 0;
671			}
672
673		case SVR4_F_FREESP:
674			{
675				struct svr4_flock	 ifl;
676				struct flock		 fl;
677
678				error = copyin(SCARG(uap, arg), &ifl,
679				    sizeof ifl);
680				if (error)
681					return error;
682				svr4_to_bsd_flock(&ifl, &fl);
683				return fd_truncate(td, SCARG(uap, fd), &fl);
684			}
685
686		case SVR4_F_GETLK64:
687		case SVR4_F_SETLK64:
688		case SVR4_F_SETLKW64:
689			{
690				struct svr4_flock64	 ifl;
691				struct flock		*flp, fl;
692				caddr_t sg = stackgap_init();
693
694				flp = stackgap_alloc(&sg, sizeof(struct flock));
695				SCARG(&fa, arg) = (long) flp;
696
697				error = copyin(SCARG(uap, arg), &ifl,
698				    sizeof ifl);
699				if (error)
700					return error;
701
702				svr4_to_bsd_flock64(&ifl, &fl);
703
704				error = copyout(&fl, flp, sizeof fl);
705				if (error)
706					return error;
707
708				error = fcntl(td, &fa);
709				if (error || SCARG(&fa, cmd) != F_GETLK)
710					return error;
711
712				error = copyin(flp, &fl, sizeof fl);
713				if (error)
714					return error;
715
716				bsd_to_svr4_flock64(&fl, &ifl);
717
718				return copyout(&ifl, SCARG(uap, arg),
719				    sizeof ifl);
720			}
721
722		case SVR4_F_FREESP64:
723			{
724				struct svr4_flock64	 ifl;
725				struct flock		 fl;
726
727				error = copyin(SCARG(uap, arg), &ifl,
728				    sizeof ifl);
729				if (error)
730					return error;
731				svr4_to_bsd_flock64(&ifl, &fl);
732				return fd_truncate(td, SCARG(uap, fd), &fl);
733			}
734
735		case SVR4_F_REVOKE:
736			return fd_revoke(td, SCARG(uap, fd));
737
738		default:
739			return ENOSYS;
740		}
741
742	default:
743		return ENOSYS;
744	}
745}
746