xref: /netbsd-src/sys/compat/linux/common/linux_file.c (revision 8ac07aec990b9d2e483062509d0a9fa5b4f57cf2)
1 /*	$NetBSD: linux_file.c,v 1.95 2008/04/24 15:35:27 ad Exp $	*/
2 
3 /*-
4  * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Frank van der Linden and Eric Haszlakiewicz.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *	This product includes software developed by the NetBSD
21  *	Foundation, Inc. and its contributors.
22  * 4. Neither the name of The NetBSD Foundation nor the names of its
23  *    contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 /*
40  * Functions in multiarch:
41  *	linux_sys_llseek	: linux_llseek.c
42  */
43 
44 #include <sys/cdefs.h>
45 __KERNEL_RCSID(0, "$NetBSD: linux_file.c,v 1.95 2008/04/24 15:35:27 ad Exp $");
46 
47 #include <sys/param.h>
48 #include <sys/systm.h>
49 #include <sys/namei.h>
50 #include <sys/proc.h>
51 #include <sys/file.h>
52 #include <sys/stat.h>
53 #include <sys/filedesc.h>
54 #include <sys/ioctl.h>
55 #include <sys/kernel.h>
56 #include <sys/mount.h>
57 #include <sys/malloc.h>
58 #include <sys/namei.h>
59 #include <sys/vnode.h>
60 #include <sys/tty.h>
61 #include <sys/socketvar.h>
62 #include <sys/conf.h>
63 #include <sys/pipe.h>
64 
65 #include <sys/syscallargs.h>
66 #include <sys/vfs_syscalls.h>
67 
68 #include <compat/linux/common/linux_types.h>
69 #include <compat/linux/common/linux_signal.h>
70 #include <compat/linux/common/linux_fcntl.h>
71 #include <compat/linux/common/linux_util.h>
72 #include <compat/linux/common/linux_machdep.h>
73 #include <compat/linux/common/linux_ipc.h>
74 #include <compat/linux/common/linux_sem.h>
75 
76 #include <compat/linux/linux_syscallargs.h>
77 
78 static int linux_to_bsd_ioflags(int);
79 static int bsd_to_linux_ioflags(int);
80 #ifndef __amd64__
81 static void bsd_to_linux_stat(struct stat *, struct linux_stat *);
82 #endif
83 
84 conv_linux_flock(linux, flock)
85 
86 /*
87  * Some file-related calls are handled here. The usual flag conversion
88  * an structure conversion is done, and alternate emul path searching.
89  */
90 
91 /*
92  * The next two functions convert between the Linux and NetBSD values
93  * of the flags used in open(2) and fcntl(2).
94  */
95 static int
96 linux_to_bsd_ioflags(int lflags)
97 {
98 	int res = 0;
99 
100 	res |= cvtto_bsd_mask(lflags, LINUX_O_WRONLY, O_WRONLY);
101 	res |= cvtto_bsd_mask(lflags, LINUX_O_RDONLY, O_RDONLY);
102 	res |= cvtto_bsd_mask(lflags, LINUX_O_RDWR, O_RDWR);
103 	res |= cvtto_bsd_mask(lflags, LINUX_O_CREAT, O_CREAT);
104 	res |= cvtto_bsd_mask(lflags, LINUX_O_EXCL, O_EXCL);
105 	res |= cvtto_bsd_mask(lflags, LINUX_O_NOCTTY, O_NOCTTY);
106 	res |= cvtto_bsd_mask(lflags, LINUX_O_TRUNC, O_TRUNC);
107 	res |= cvtto_bsd_mask(lflags, LINUX_O_NDELAY, O_NDELAY);
108 	res |= cvtto_bsd_mask(lflags, LINUX_O_SYNC, O_FSYNC);
109 	res |= cvtto_bsd_mask(lflags, LINUX_FASYNC, O_ASYNC);
110 	res |= cvtto_bsd_mask(lflags, LINUX_O_APPEND, O_APPEND);
111 
112 	return res;
113 }
114 
115 static int
116 bsd_to_linux_ioflags(int bflags)
117 {
118 	int res = 0;
119 
120 	res |= cvtto_linux_mask(bflags, O_WRONLY, LINUX_O_WRONLY);
121 	res |= cvtto_linux_mask(bflags, O_RDONLY, LINUX_O_RDONLY);
122 	res |= cvtto_linux_mask(bflags, O_RDWR, LINUX_O_RDWR);
123 	res |= cvtto_linux_mask(bflags, O_CREAT, LINUX_O_CREAT);
124 	res |= cvtto_linux_mask(bflags, O_EXCL, LINUX_O_EXCL);
125 	res |= cvtto_linux_mask(bflags, O_NOCTTY, LINUX_O_NOCTTY);
126 	res |= cvtto_linux_mask(bflags, O_TRUNC, LINUX_O_TRUNC);
127 	res |= cvtto_linux_mask(bflags, O_NDELAY, LINUX_O_NDELAY);
128 	res |= cvtto_linux_mask(bflags, O_FSYNC, LINUX_O_SYNC);
129 	res |= cvtto_linux_mask(bflags, O_ASYNC, LINUX_FASYNC);
130 	res |= cvtto_linux_mask(bflags, O_APPEND, LINUX_O_APPEND);
131 
132 	return res;
133 }
134 
135 /*
136  * creat(2) is an obsolete function, but it's present as a Linux
137  * system call, so let's deal with it.
138  *
139  * Note: On the Alpha this doesn't really exist in Linux, but it's defined
140  * in syscalls.master anyway so this doesn't have to be special cased.
141  *
142  * Just call open(2) with the TRUNC, CREAT and WRONLY flags.
143  */
144 int
145 linux_sys_creat(struct lwp *l, const struct linux_sys_creat_args *uap, register_t *retval)
146 {
147 	/* {
148 		syscallarg(const char *) path;
149 		syscallarg(int) mode;
150 	} */
151 	struct sys_open_args oa;
152 
153 	SCARG(&oa, path) = SCARG(uap, path);
154 	SCARG(&oa, flags) = O_CREAT | O_TRUNC | O_WRONLY;
155 	SCARG(&oa, mode) = SCARG(uap, mode);
156 
157 	return sys_open(l, &oa, retval);
158 }
159 
160 /*
161  * open(2). Take care of the different flag values, and let the
162  * NetBSD syscall do the real work. See if this operation
163  * gives the current process a controlling terminal.
164  * (XXX is this necessary?)
165  */
166 int
167 linux_sys_open(struct lwp *l, const struct linux_sys_open_args *uap, register_t *retval)
168 {
169 	/* {
170 		syscallarg(const char *) path;
171 		syscallarg(int) flags;
172 		syscallarg(int) mode;
173 	} */
174 	struct proc *p = l->l_proc;
175 	int error, fl;
176 	struct sys_open_args boa;
177 
178 	fl = linux_to_bsd_ioflags(SCARG(uap, flags));
179 
180 	SCARG(&boa, path) = SCARG(uap, path);
181 	SCARG(&boa, flags) = fl;
182 	SCARG(&boa, mode) = SCARG(uap, mode);
183 
184 	if ((error = sys_open(l, &boa, retval)))
185 		return error;
186 
187 	/*
188 	 * this bit from sunos_misc.c (and svr4_fcntl.c).
189 	 * If we are a session leader, and we don't have a controlling
190 	 * terminal yet, and the O_NOCTTY flag is not set, try to make
191 	 * this the controlling terminal.
192 	 */
193         if (!(fl & O_NOCTTY) && SESS_LEADER(p) && !(p->p_lflag & PL_CONTROLT)) {
194                 file_t *fp;
195 
196 		fp = fd_getfile(*retval);
197 
198                 /* ignore any error, just give it a try */
199                 if (fp != NULL) {
200 			if (fp->f_type == DTYPE_VNODE) {
201 				(fp->f_ops->fo_ioctl) (fp, TIOCSCTTY, NULL);
202 			}
203 			fd_putfile(*retval);
204 		}
205         }
206 	return 0;
207 }
208 
209 /*
210  * Most actions in the fcntl() call are straightforward; simply
211  * pass control to the NetBSD system call. A few commands need
212  * conversions after the actual system call has done its work,
213  * because the flag values and lock structure are different.
214  */
215 int
216 linux_sys_fcntl(struct lwp *l, const struct linux_sys_fcntl_args *uap, register_t *retval)
217 {
218 	/* {
219 		syscallarg(int) fd;
220 		syscallarg(int) cmd;
221 		syscallarg(void *) arg;
222 	} */
223 	struct proc *p = l->l_proc;
224 	int fd, cmd, error;
225 	u_long val;
226 	void *arg;
227 	struct sys_fcntl_args fca;
228 	file_t *fp;
229 	struct vnode *vp;
230 	struct vattr va;
231 	long pgid;
232 	struct pgrp *pgrp;
233 	struct tty *tp;
234 
235 	fd = SCARG(uap, fd);
236 	cmd = SCARG(uap, cmd);
237 	arg = SCARG(uap, arg);
238 
239 	switch (cmd) {
240 
241 	case LINUX_F_DUPFD:
242 		cmd = F_DUPFD;
243 		break;
244 
245 	case LINUX_F_GETFD:
246 		cmd = F_GETFD;
247 		break;
248 
249 	case LINUX_F_SETFD:
250 		cmd = F_SETFD;
251 		break;
252 
253 	case LINUX_F_GETFL:
254 		SCARG(&fca, fd) = fd;
255 		SCARG(&fca, cmd) = F_GETFL;
256 		SCARG(&fca, arg) = arg;
257 		if ((error = sys_fcntl(l, &fca, retval)))
258 			return error;
259 		retval[0] = bsd_to_linux_ioflags(retval[0]);
260 		return 0;
261 
262 	case LINUX_F_SETFL: {
263 		file_t	*fp1 = NULL;
264 
265 		val = linux_to_bsd_ioflags((unsigned long)SCARG(uap, arg));
266 		/*
267 		 * Linux seems to have same semantics for sending SIGIO to the
268 		 * read side of socket, but slightly different semantics
269 		 * for SIGIO to the write side.  Rather than sending the SIGIO
270 		 * every time it's possible to write (directly) more data, it
271 		 * only sends SIGIO if last write(2) failed due to insufficient
272 		 * memory to hold the data. This is compatible enough
273 		 * with NetBSD semantics to not do anything about the
274 		 * difference.
275 		 *
276 		 * Linux does NOT send SIGIO for pipes. Deal with socketpair
277 		 * ones and DTYPE_PIPE ones. For these, we don't set
278 		 * the underlying flags (we don't pass O_ASYNC flag down
279 		 * to sys_fcntl()), but set the FASYNC flag for file descriptor,
280 		 * so that F_GETFL would report the ASYNC i/o is on.
281 		 */
282 		if (val & O_ASYNC) {
283 			if (((fp1 = fd_getfile(fd)) == NULL))
284 			    return (EBADF);
285 			if (((fp1->f_type == DTYPE_SOCKET) && fp1->f_data
286 			      && ((struct socket *)fp1->f_data)->so_state & SS_ISAPIPE)
287 			    || (fp1->f_type == DTYPE_PIPE))
288 				val &= ~O_ASYNC;
289 			else {
290 				/* not a pipe, do not modify anything */
291 				fd_putfile(fd);
292 				fp1 = NULL;
293 			}
294 		}
295 
296 		SCARG(&fca, fd) = fd;
297 		SCARG(&fca, cmd) = F_SETFL;
298 		SCARG(&fca, arg) = (void *) val;
299 
300 		error = sys_fcntl(l, &fca, retval);
301 
302 		/* Now set the FASYNC flag for pipes */
303 		if (fp1) {
304 			if (!error) {
305 				mutex_enter(&fp1->f_lock);
306 				fp1->f_flag |= FASYNC;
307 				mutex_exit(&fp1->f_lock);
308 			}
309 			fd_putfile(fd);
310 		}
311 
312 		return (error);
313 	    }
314 
315 	case LINUX_F_GETLK:
316 		do_linux_getlk(fd, cmd, arg, linux, flock);
317 
318 	case LINUX_F_SETLK:
319 	case LINUX_F_SETLKW:
320 		do_linux_setlk(fd, cmd, arg, linux, flock, LINUX_F_SETLK);
321 
322 	case LINUX_F_SETOWN:
323 	case LINUX_F_GETOWN:
324 		/*
325 		 * We need to route fcntl() for tty descriptors around normal
326 		 * fcntl(), since NetBSD tty TIOC{G,S}PGRP semantics is too
327 		 * restrictive for Linux F_{G,S}ETOWN. For non-tty descriptors,
328 		 * this is not a problem.
329 		 */
330 		if ((fp = fd_getfile(fd)) == NULL)
331 			return EBADF;
332 
333 		/* Check it's a character device vnode */
334 		if (fp->f_type != DTYPE_VNODE
335 		    || (vp = (struct vnode *)fp->f_data) == NULL
336 		    || vp->v_type != VCHR) {
337 			fd_putfile(fd);
338 
339 	    not_tty:
340 			/* Not a tty, proceed with common fcntl() */
341 			cmd = cmd == LINUX_F_SETOWN ? F_SETOWN : F_GETOWN;
342 			break;
343 		}
344 
345 		error = VOP_GETATTR(vp, &va, l->l_cred);
346 
347 		fd_putfile(fd);
348 
349 		if (error)
350 			return error;
351 
352 		if ((tp = cdev_tty(va.va_rdev)) == NULL)
353 			goto not_tty;
354 
355 		/* set tty pg_id appropriately */
356 		mutex_enter(proc_lock);
357 		if (cmd == LINUX_F_GETOWN) {
358 			retval[0] = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PGID;
359 			mutex_exit(proc_lock);
360 			return 0;
361 		}
362 		if ((long)arg <= 0) {
363 			pgid = -(long)arg;
364 		} else {
365 			struct proc *p1 = p_find((long)arg, PFIND_LOCKED | PFIND_UNLOCK_FAIL);
366 			if (p1 == NULL)
367 				return (ESRCH);
368 			pgid = (long)p1->p_pgrp->pg_id;
369 		}
370 		pgrp = pg_find(pgid, PFIND_LOCKED);
371 		if (pgrp == NULL || pgrp->pg_session != p->p_session) {
372 			mutex_exit(proc_lock);
373 			return EPERM;
374 		}
375 		tp->t_pgrp = pgrp;
376 		mutex_exit(proc_lock);
377 		return 0;
378 
379 	default:
380 		return EOPNOTSUPP;
381 	}
382 
383 	SCARG(&fca, fd) = fd;
384 	SCARG(&fca, cmd) = cmd;
385 	SCARG(&fca, arg) = arg;
386 
387 	return sys_fcntl(l, &fca, retval);
388 }
389 
390 #if !defined(__amd64__)
391 /*
392  * Convert a NetBSD stat structure to a Linux stat structure.
393  * Only the order of the fields and the padding in the structure
394  * is different. linux_fakedev is a machine-dependent function
395  * which optionally converts device driver major/minor numbers
396  * (XXX horrible, but what can you do against code that compares
397  * things against constant major device numbers? sigh)
398  */
399 static void
400 bsd_to_linux_stat(struct stat *bsp, struct linux_stat *lsp)
401 {
402 
403 	lsp->lst_dev     = linux_fakedev(bsp->st_dev, 0);
404 	lsp->lst_ino     = bsp->st_ino;
405 	lsp->lst_mode    = (linux_mode_t)bsp->st_mode;
406 	if (bsp->st_nlink >= (1 << 15))
407 		lsp->lst_nlink = (1 << 15) - 1;
408 	else
409 		lsp->lst_nlink = (linux_nlink_t)bsp->st_nlink;
410 	lsp->lst_uid     = bsp->st_uid;
411 	lsp->lst_gid     = bsp->st_gid;
412 	lsp->lst_rdev    = linux_fakedev(bsp->st_rdev, 1);
413 	lsp->lst_size    = bsp->st_size;
414 	lsp->lst_blksize = bsp->st_blksize;
415 	lsp->lst_blocks  = bsp->st_blocks;
416 	lsp->lst_atime   = bsp->st_atime;
417 	lsp->lst_mtime   = bsp->st_mtime;
418 	lsp->lst_ctime   = bsp->st_ctime;
419 #ifdef LINUX_STAT_HAS_NSEC
420 	lsp->lst_atime_nsec   = bsp->st_atimensec;
421 	lsp->lst_mtime_nsec   = bsp->st_mtimensec;
422 	lsp->lst_ctime_nsec   = bsp->st_ctimensec;
423 #endif
424 }
425 
426 /*
427  * The stat functions below are plain sailing. stat and lstat are handled
428  * by one function to avoid code duplication.
429  */
430 int
431 linux_sys_fstat(struct lwp *l, const struct linux_sys_fstat_args *uap, register_t *retval)
432 {
433 	/* {
434 		syscallarg(int) fd;
435 		syscallarg(linux_stat *) sp;
436 	} */
437 	struct linux_stat tmplst;
438 	struct stat tmpst;
439 	int error;
440 
441 	error = do_sys_fstat(SCARG(uap, fd), &tmpst);
442 	if (error != 0)
443 		return error;
444 	bsd_to_linux_stat(&tmpst, &tmplst);
445 
446 	return copyout(&tmplst, SCARG(uap, sp), sizeof tmplst);
447 }
448 
449 static int
450 linux_stat1(const struct linux_sys_stat_args *uap, register_t *retval, int flags)
451 {
452 	struct linux_stat tmplst;
453 	struct stat tmpst;
454 	int error;
455 
456 	error = do_sys_stat(SCARG(uap, path), flags, &tmpst);
457 	if (error != 0)
458 		return error;
459 
460 	bsd_to_linux_stat(&tmpst, &tmplst);
461 
462 	return copyout(&tmplst, SCARG(uap, sp), sizeof tmplst);
463 }
464 
465 int
466 linux_sys_stat(struct lwp *l, const struct linux_sys_stat_args *uap, register_t *retval)
467 {
468 	/* {
469 		syscallarg(const char *) path;
470 		syscallarg(struct linux_stat *) sp;
471 	} */
472 
473 	return linux_stat1(uap, retval, FOLLOW);
474 }
475 
476 /* Note: this is "newlstat" in the Linux sources */
477 /*	(we don't bother with the old lstat currently) */
478 int
479 linux_sys_lstat(struct lwp *l, const struct linux_sys_lstat_args *uap, register_t *retval)
480 {
481 	/* {
482 		syscallarg(const char *) path;
483 		syscallarg(struct linux_stat *) sp;
484 	} */
485 
486 	return linux_stat1((const void *)uap, retval, NOFOLLOW);
487 }
488 #endif /* !__amd64__ */
489 
490 /*
491  * The following syscalls are mostly here because of the alternate path check.
492  */
493 int
494 linux_sys_unlink(struct lwp *l, const struct linux_sys_unlink_args *uap, register_t *retval)
495 {
496 	/* {
497 		syscallarg(const char *) path;
498 	} */
499 	int error;
500 	struct nameidata nd;
501 
502 	error = sys_unlink(l, (const void *)uap, retval);
503 	if (error != EPERM)
504 		return (error);
505 
506 	/*
507 	 * Linux returns EISDIR if unlink(2) is called on a directory.
508 	 * We return EPERM in such cases. To emulate correct behaviour,
509 	 * check if the path points to directory and return EISDIR if this
510 	 * is the case.
511 	 */
512 	NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | TRYEMULROOT, UIO_USERSPACE,
513 	    SCARG(uap, path));
514 	if (namei(&nd) == 0) {
515 		struct stat sb;
516 
517 		if (vn_stat(nd.ni_vp, &sb) == 0
518 		    && S_ISDIR(sb.st_mode))
519 			error = EISDIR;
520 
521 		vput(nd.ni_vp);
522 	}
523 
524 	return (error);
525 }
526 
527 int
528 linux_sys_mknod(struct lwp *l, const struct linux_sys_mknod_args *uap, register_t *retval)
529 {
530 	/* {
531 		syscallarg(const char *) path;
532 		syscallarg(int) mode;
533 		syscallarg(int) dev;
534 	} */
535 
536 	/*
537 	 * BSD handles FIFOs separately
538 	 */
539 	if (S_ISFIFO(SCARG(uap, mode))) {
540 		struct sys_mkfifo_args bma;
541 
542 		SCARG(&bma, path) = SCARG(uap, path);
543 		SCARG(&bma, mode) = SCARG(uap, mode);
544 		return sys_mkfifo(l, &bma, retval);
545 	} else {
546 		struct sys_mknod_args bma;
547 
548 		SCARG(&bma, path) = SCARG(uap, path);
549 		SCARG(&bma, mode) = SCARG(uap, mode);
550 		/*
551 		 * Linux device numbers uses 8 bits for minor and 8 bits
552 		 * for major. Due to how we map our major and minor,
553 		 * this just fits into our dev_t. Just mask off the
554 		 * upper 16bit to remove any random junk.
555 		 */
556 		SCARG(&bma, dev) = SCARG(uap, dev) & 0xffff;
557 		return sys_mknod(l, &bma, retval);
558 	}
559 }
560 
561 /*
562  * This is just fsync() for now (just as it is in the Linux kernel)
563  * Note: this is not implemented under Linux on Alpha and Arm
564  *	but should still be defined in our syscalls.master.
565  *	(syscall #148 on the arm)
566  */
567 int
568 linux_sys_fdatasync(struct lwp *l, const struct linux_sys_fdatasync_args *uap, register_t *retval)
569 {
570 	/* {
571 		syscallarg(int) fd;
572 	} */
573 
574 	return sys_fsync(l, (const void *)uap, retval);
575 }
576 
577 /*
578  * pread(2).
579  */
580 int
581 linux_sys_pread(struct lwp *l, const struct linux_sys_pread_args *uap, register_t *retval)
582 {
583 	/* {
584 		syscallarg(int) fd;
585 		syscallarg(void *) buf;
586 		syscallarg(size_t) nbyte;
587 		syscallarg(linux_off_t) offset;
588 	} */
589 	struct sys_pread_args pra;
590 
591 	SCARG(&pra, fd) = SCARG(uap, fd);
592 	SCARG(&pra, buf) = SCARG(uap, buf);
593 	SCARG(&pra, nbyte) = SCARG(uap, nbyte);
594 	SCARG(&pra, offset) = SCARG(uap, offset);
595 
596 	return sys_pread(l, &pra, retval);
597 }
598 
599 /*
600  * pwrite(2).
601  */
602 int
603 linux_sys_pwrite(struct lwp *l, const struct linux_sys_pwrite_args *uap, register_t *retval)
604 {
605 	/* {
606 		syscallarg(int) fd;
607 		syscallarg(void *) buf;
608 		syscallarg(size_t) nbyte;
609 		syscallarg(linux_off_t) offset;
610 	} */
611 	struct sys_pwrite_args pra;
612 
613 	SCARG(&pra, fd) = SCARG(uap, fd);
614 	SCARG(&pra, buf) = SCARG(uap, buf);
615 	SCARG(&pra, nbyte) = SCARG(uap, nbyte);
616 	SCARG(&pra, offset) = SCARG(uap, offset);
617 
618 	return sys_pwrite(l, &pra, retval);
619 }
620 
621 #define LINUX_NOT_SUPPORTED(fun) \
622 int \
623 fun(struct lwp *l, const struct fun##_args *uap, register_t *retval) \
624 { \
625 	return EOPNOTSUPP; \
626 }
627 
628 LINUX_NOT_SUPPORTED(linux_sys_setxattr)
629 LINUX_NOT_SUPPORTED(linux_sys_lsetxattr)
630 LINUX_NOT_SUPPORTED(linux_sys_fsetxattr)
631 
632 LINUX_NOT_SUPPORTED(linux_sys_getxattr)
633 LINUX_NOT_SUPPORTED(linux_sys_lgetxattr)
634 LINUX_NOT_SUPPORTED(linux_sys_fgetxattr)
635 
636 LINUX_NOT_SUPPORTED(linux_sys_listxattr)
637 LINUX_NOT_SUPPORTED(linux_sys_llistxattr)
638 LINUX_NOT_SUPPORTED(linux_sys_flistxattr)
639 
640 LINUX_NOT_SUPPORTED(linux_sys_removexattr)
641 LINUX_NOT_SUPPORTED(linux_sys_lremovexattr)
642 LINUX_NOT_SUPPORTED(linux_sys_fremovexattr)
643 
644