Home | History | Annotate | Line # | Download | only in common
linux_file.c revision 1.110
      1  1.110     njoly /*	$NetBSD: linux_file.c,v 1.110 2014/05/06 13:21:50 njoly Exp $	*/
      2   1.23       erh 
      3   1.23       erh /*-
      4   1.93        ad  * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
      5   1.23       erh  * All rights reserved.
      6   1.23       erh  *
      7   1.23       erh  * This code is derived from software contributed to The NetBSD Foundation
      8   1.25      fvdl  * by Frank van der Linden and Eric Haszlakiewicz.
      9   1.23       erh  *
     10   1.23       erh  * Redistribution and use in source and binary forms, with or without
     11   1.23       erh  * modification, are permitted provided that the following conditions
     12   1.23       erh  * are met:
     13   1.23       erh  * 1. Redistributions of source code must retain the above copyright
     14   1.23       erh  *    notice, this list of conditions and the following disclaimer.
     15   1.23       erh  * 2. Redistributions in binary form must reproduce the above copyright
     16   1.23       erh  *    notice, this list of conditions and the following disclaimer in the
     17   1.23       erh  *    documentation and/or other materials provided with the distribution.
     18   1.23       erh  *
     19   1.23       erh  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20   1.23       erh  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21   1.23       erh  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22   1.23       erh  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23   1.23       erh  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24   1.23       erh  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25   1.23       erh  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26   1.23       erh  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27   1.23       erh  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28   1.23       erh  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29   1.23       erh  * POSSIBILITY OF SUCH DAMAGE.
     30    1.1      fvdl  */
     31    1.1      fvdl 
     32   1.23       erh /*
     33   1.23       erh  * Functions in multiarch:
     34   1.23       erh  *	linux_sys_llseek	: linux_llseek.c
     35   1.23       erh  */
     36   1.43     lukem 
     37   1.43     lukem #include <sys/cdefs.h>
     38  1.110     njoly __KERNEL_RCSID(0, "$NetBSD: linux_file.c,v 1.110 2014/05/06 13:21:50 njoly Exp $");
     39   1.23       erh 
     40    1.1      fvdl #include <sys/param.h>
     41    1.1      fvdl #include <sys/systm.h>
     42    1.1      fvdl #include <sys/namei.h>
     43    1.1      fvdl #include <sys/proc.h>
     44    1.1      fvdl #include <sys/file.h>
     45  1.103  christos #include <sys/fcntl.h>
     46    1.1      fvdl #include <sys/stat.h>
     47    1.1      fvdl #include <sys/filedesc.h>
     48    1.1      fvdl #include <sys/ioctl.h>
     49    1.1      fvdl #include <sys/kernel.h>
     50    1.1      fvdl #include <sys/mount.h>
     51    1.1      fvdl #include <sys/malloc.h>
     52   1.81       dsl #include <sys/namei.h>
     53   1.13      fvdl #include <sys/vnode.h>
     54   1.13      fvdl #include <sys/tty.h>
     55   1.39      manu #include <sys/socketvar.h>
     56   1.13      fvdl #include <sys/conf.h>
     57   1.41  jdolecek #include <sys/pipe.h>
     58    1.1      fvdl 
     59    1.1      fvdl #include <sys/syscallargs.h>
     60   1.81       dsl #include <sys/vfs_syscalls.h>
     61    1.1      fvdl 
     62   1.24  christos #include <compat/linux/common/linux_types.h>
     63   1.24  christos #include <compat/linux/common/linux_signal.h>
     64   1.24  christos #include <compat/linux/common/linux_fcntl.h>
     65   1.24  christos #include <compat/linux/common/linux_util.h>
     66   1.24  christos #include <compat/linux/common/linux_machdep.h>
     67   1.84     njoly #include <compat/linux/common/linux_ipc.h>
     68   1.84     njoly #include <compat/linux/common/linux_sem.h>
     69   1.24  christos 
     70    1.1      fvdl #include <compat/linux/linux_syscallargs.h>
     71   1.14  christos 
     72   1.87       dsl static int linux_to_bsd_ioflags(int);
     73   1.87       dsl static int bsd_to_linux_ioflags(int);
     74   1.67      manu #ifndef __amd64__
     75   1.87       dsl static void bsd_to_linux_stat(struct stat *, struct linux_stat *);
     76   1.67      manu #endif
     77   1.14  christos 
     78   1.92       dsl conv_linux_flock(linux, flock)
     79   1.92       dsl 
     80    1.1      fvdl /*
     81    1.1      fvdl  * Some file-related calls are handled here. The usual flag conversion
     82    1.1      fvdl  * an structure conversion is done, and alternate emul path searching.
     83    1.1      fvdl  */
     84    1.1      fvdl 
     85    1.1      fvdl /*
     86    1.1      fvdl  * The next two functions convert between the Linux and NetBSD values
     87    1.1      fvdl  * of the flags used in open(2) and fcntl(2).
     88    1.1      fvdl  */
     89    1.1      fvdl static int
     90   1.88       dsl linux_to_bsd_ioflags(int lflags)
     91    1.1      fvdl {
     92    1.1      fvdl 	int res = 0;
     93    1.1      fvdl 
     94    1.1      fvdl 	res |= cvtto_bsd_mask(lflags, LINUX_O_WRONLY, O_WRONLY);
     95    1.1      fvdl 	res |= cvtto_bsd_mask(lflags, LINUX_O_RDONLY, O_RDONLY);
     96    1.1      fvdl 	res |= cvtto_bsd_mask(lflags, LINUX_O_RDWR, O_RDWR);
     97    1.1      fvdl 	res |= cvtto_bsd_mask(lflags, LINUX_O_CREAT, O_CREAT);
     98    1.1      fvdl 	res |= cvtto_bsd_mask(lflags, LINUX_O_EXCL, O_EXCL);
     99    1.1      fvdl 	res |= cvtto_bsd_mask(lflags, LINUX_O_NOCTTY, O_NOCTTY);
    100    1.1      fvdl 	res |= cvtto_bsd_mask(lflags, LINUX_O_TRUNC, O_TRUNC);
    101    1.1      fvdl 	res |= cvtto_bsd_mask(lflags, LINUX_O_NDELAY, O_NDELAY);
    102    1.1      fvdl 	res |= cvtto_bsd_mask(lflags, LINUX_O_SYNC, O_FSYNC);
    103    1.1      fvdl 	res |= cvtto_bsd_mask(lflags, LINUX_FASYNC, O_ASYNC);
    104    1.1      fvdl 	res |= cvtto_bsd_mask(lflags, LINUX_O_APPEND, O_APPEND);
    105  1.100       chs 	res |= cvtto_bsd_mask(lflags, LINUX_O_DIRECTORY, O_DIRECTORY);
    106  1.102  christos 	res |= cvtto_bsd_mask(lflags, LINUX_O_CLOEXEC, O_CLOEXEC);
    107    1.1      fvdl 
    108    1.1      fvdl 	return res;
    109    1.1      fvdl }
    110    1.1      fvdl 
    111    1.1      fvdl static int
    112   1.88       dsl bsd_to_linux_ioflags(int bflags)
    113    1.1      fvdl {
    114    1.1      fvdl 	int res = 0;
    115    1.1      fvdl 
    116    1.1      fvdl 	res |= cvtto_linux_mask(bflags, O_WRONLY, LINUX_O_WRONLY);
    117    1.1      fvdl 	res |= cvtto_linux_mask(bflags, O_RDONLY, LINUX_O_RDONLY);
    118    1.1      fvdl 	res |= cvtto_linux_mask(bflags, O_RDWR, LINUX_O_RDWR);
    119    1.1      fvdl 	res |= cvtto_linux_mask(bflags, O_CREAT, LINUX_O_CREAT);
    120    1.1      fvdl 	res |= cvtto_linux_mask(bflags, O_EXCL, LINUX_O_EXCL);
    121    1.1      fvdl 	res |= cvtto_linux_mask(bflags, O_NOCTTY, LINUX_O_NOCTTY);
    122    1.1      fvdl 	res |= cvtto_linux_mask(bflags, O_TRUNC, LINUX_O_TRUNC);
    123    1.1      fvdl 	res |= cvtto_linux_mask(bflags, O_NDELAY, LINUX_O_NDELAY);
    124    1.1      fvdl 	res |= cvtto_linux_mask(bflags, O_FSYNC, LINUX_O_SYNC);
    125    1.1      fvdl 	res |= cvtto_linux_mask(bflags, O_ASYNC, LINUX_FASYNC);
    126    1.1      fvdl 	res |= cvtto_linux_mask(bflags, O_APPEND, LINUX_O_APPEND);
    127  1.100       chs 	res |= cvtto_linux_mask(bflags, O_DIRECTORY, LINUX_O_DIRECTORY);
    128  1.102  christos 	res |= cvtto_linux_mask(bflags, O_CLOEXEC, LINUX_O_CLOEXEC);
    129    1.1      fvdl 
    130    1.1      fvdl 	return res;
    131    1.1      fvdl }
    132    1.1      fvdl 
    133    1.1      fvdl /*
    134    1.1      fvdl  * creat(2) is an obsolete function, but it's present as a Linux
    135    1.1      fvdl  * system call, so let's deal with it.
    136    1.1      fvdl  *
    137   1.23       erh  * Note: On the Alpha this doesn't really exist in Linux, but it's defined
    138   1.23       erh  * in syscalls.master anyway so this doesn't have to be special cased.
    139   1.23       erh  *
    140    1.1      fvdl  * Just call open(2) with the TRUNC, CREAT and WRONLY flags.
    141    1.1      fvdl  */
    142    1.1      fvdl int
    143   1.90       dsl linux_sys_creat(struct lwp *l, const struct linux_sys_creat_args *uap, register_t *retval)
    144   1.11   thorpej {
    145   1.90       dsl 	/* {
    146   1.27  christos 		syscallarg(const char *) path;
    147  1.108     njoly 		syscallarg(linux_umode_t) mode;
    148   1.90       dsl 	} */
    149   1.12   mycroft 	struct sys_open_args oa;
    150    1.1      fvdl 
    151    1.1      fvdl 	SCARG(&oa, path) = SCARG(uap, path);
    152    1.1      fvdl 	SCARG(&oa, flags) = O_CREAT | O_TRUNC | O_WRONLY;
    153    1.1      fvdl 	SCARG(&oa, mode) = SCARG(uap, mode);
    154   1.12   mycroft 
    155   1.56   thorpej 	return sys_open(l, &oa, retval);
    156    1.1      fvdl }
    157    1.1      fvdl 
    158  1.106       chs static void
    159  1.106       chs linux_open_ctty(struct lwp *l, int flags, int fd)
    160  1.106       chs {
    161  1.106       chs 	struct proc *p = l->l_proc;
    162  1.106       chs 
    163  1.106       chs 	/*
    164  1.106       chs 	 * this bit from sunos_misc.c (and svr4_fcntl.c).
    165  1.106       chs 	 * If we are a session leader, and we don't have a controlling
    166  1.106       chs 	 * terminal yet, and the O_NOCTTY flag is not set, try to make
    167  1.106       chs 	 * this the controlling terminal.
    168  1.106       chs 	 */
    169  1.106       chs         if (!(flags & O_NOCTTY) && SESS_LEADER(p) && !(p->p_lflag & PL_CONTROLT)) {
    170  1.106       chs                 file_t *fp;
    171  1.106       chs 
    172  1.106       chs 		fp = fd_getfile(fd);
    173  1.106       chs 
    174  1.106       chs                 /* ignore any error, just give it a try */
    175  1.106       chs                 if (fp != NULL) {
    176  1.106       chs 			if (fp->f_type == DTYPE_VNODE) {
    177  1.106       chs 				(fp->f_ops->fo_ioctl) (fp, TIOCSCTTY, NULL);
    178  1.106       chs 			}
    179  1.106       chs 			fd_putfile(fd);
    180  1.106       chs 		}
    181  1.106       chs         }
    182  1.106       chs }
    183  1.106       chs 
    184    1.1      fvdl /*
    185    1.1      fvdl  * open(2). Take care of the different flag values, and let the
    186    1.1      fvdl  * NetBSD syscall do the real work. See if this operation
    187    1.1      fvdl  * gives the current process a controlling terminal.
    188    1.1      fvdl  * (XXX is this necessary?)
    189    1.1      fvdl  */
    190    1.1      fvdl int
    191   1.90       dsl linux_sys_open(struct lwp *l, const struct linux_sys_open_args *uap, register_t *retval)
    192   1.11   thorpej {
    193   1.90       dsl 	/* {
    194   1.27  christos 		syscallarg(const char *) path;
    195    1.1      fvdl 		syscallarg(int) flags;
    196  1.108     njoly 		syscallarg(linux_umode_t) mode;
    197   1.90       dsl 	} */
    198    1.1      fvdl 	int error, fl;
    199   1.12   mycroft 	struct sys_open_args boa;
    200    1.1      fvdl 
    201    1.2      fvdl 	fl = linux_to_bsd_ioflags(SCARG(uap, flags));
    202    1.1      fvdl 
    203    1.1      fvdl 	SCARG(&boa, path) = SCARG(uap, path);
    204    1.1      fvdl 	SCARG(&boa, flags) = fl;
    205    1.1      fvdl 	SCARG(&boa, mode) = SCARG(uap, mode);
    206    1.2      fvdl 
    207   1.56   thorpej 	if ((error = sys_open(l, &boa, retval)))
    208    1.1      fvdl 		return error;
    209    1.1      fvdl 
    210  1.106       chs 	linux_open_ctty(l, fl, *retval);
    211  1.106       chs 	return 0;
    212  1.106       chs }
    213  1.106       chs 
    214  1.106       chs int
    215  1.106       chs linux_sys_openat(struct lwp *l, const struct linux_sys_openat_args *uap, register_t *retval)
    216  1.106       chs {
    217  1.106       chs 	/* {
    218  1.107     njoly 		syscallarg(int) fd;
    219  1.106       chs 		syscallarg(const char *) path;
    220  1.106       chs 		syscallarg(int) flags;
    221  1.108     njoly 		syscallarg(linux_umode_t) mode;
    222  1.106       chs 	} */
    223  1.106       chs 	int error, fl;
    224  1.106       chs 	struct sys_openat_args boa;
    225  1.106       chs 
    226  1.106       chs 	fl = linux_to_bsd_ioflags(SCARG(uap, flags));
    227  1.106       chs 
    228  1.106       chs 	SCARG(&boa, fd) = SCARG(uap, fd);
    229  1.106       chs 	SCARG(&boa, path) = SCARG(uap, path);
    230  1.106       chs 	SCARG(&boa, oflags) = fl;
    231  1.106       chs 	SCARG(&boa, mode) = SCARG(uap, mode);
    232   1.38   thorpej 
    233  1.106       chs 	if ((error = sys_openat(l, &boa, retval)))
    234  1.106       chs 		return error;
    235    1.1      fvdl 
    236  1.106       chs 	linux_open_ctty(l, fl, *retval);
    237    1.1      fvdl 	return 0;
    238    1.1      fvdl }
    239    1.1      fvdl 
    240    1.1      fvdl /*
    241    1.1      fvdl  * Most actions in the fcntl() call are straightforward; simply
    242    1.1      fvdl  * pass control to the NetBSD system call. A few commands need
    243    1.1      fvdl  * conversions after the actual system call has done its work,
    244    1.1      fvdl  * because the flag values and lock structure are different.
    245    1.1      fvdl  */
    246    1.1      fvdl int
    247   1.90       dsl linux_sys_fcntl(struct lwp *l, const struct linux_sys_fcntl_args *uap, register_t *retval)
    248   1.11   thorpej {
    249   1.90       dsl 	/* {
    250    1.1      fvdl 		syscallarg(int) fd;
    251    1.1      fvdl 		syscallarg(int) cmd;
    252    1.1      fvdl 		syscallarg(void *) arg;
    253   1.90       dsl 	} */
    254   1.56   thorpej 	struct proc *p = l->l_proc;
    255   1.23       erh 	int fd, cmd, error;
    256   1.23       erh 	u_long val;
    257   1.83       dsl 	void *arg;
    258   1.12   mycroft 	struct sys_fcntl_args fca;
    259   1.93        ad 	file_t *fp;
    260   1.13      fvdl 	struct vnode *vp;
    261   1.13      fvdl 	struct vattr va;
    262   1.13      fvdl 	long pgid;
    263   1.13      fvdl 	struct pgrp *pgrp;
    264   1.94        ad 	struct tty *tp;
    265    1.1      fvdl 
    266    1.1      fvdl 	fd = SCARG(uap, fd);
    267    1.1      fvdl 	cmd = SCARG(uap, cmd);
    268   1.92       dsl 	arg = SCARG(uap, arg);
    269    1.1      fvdl 
    270    1.1      fvdl 	switch (cmd) {
    271   1.92       dsl 
    272    1.1      fvdl 	case LINUX_F_DUPFD:
    273    1.1      fvdl 		cmd = F_DUPFD;
    274    1.1      fvdl 		break;
    275   1.92       dsl 
    276    1.1      fvdl 	case LINUX_F_GETFD:
    277    1.1      fvdl 		cmd = F_GETFD;
    278    1.1      fvdl 		break;
    279   1.92       dsl 
    280    1.1      fvdl 	case LINUX_F_SETFD:
    281    1.1      fvdl 		cmd = F_SETFD;
    282    1.1      fvdl 		break;
    283   1.92       dsl 
    284    1.1      fvdl 	case LINUX_F_GETFL:
    285    1.1      fvdl 		SCARG(&fca, fd) = fd;
    286    1.1      fvdl 		SCARG(&fca, cmd) = F_GETFL;
    287    1.1      fvdl 		SCARG(&fca, arg) = arg;
    288   1.56   thorpej 		if ((error = sys_fcntl(l, &fca, retval)))
    289    1.1      fvdl 			return error;
    290    1.1      fvdl 		retval[0] = bsd_to_linux_ioflags(retval[0]);
    291    1.1      fvdl 		return 0;
    292   1.92       dsl 
    293   1.41  jdolecek 	case LINUX_F_SETFL: {
    294   1.93        ad 		file_t	*fp1 = NULL;
    295   1.41  jdolecek 
    296   1.23       erh 		val = linux_to_bsd_ioflags((unsigned long)SCARG(uap, arg));
    297   1.39      manu 		/*
    298   1.41  jdolecek 		 * Linux seems to have same semantics for sending SIGIO to the
    299   1.64       abs 		 * read side of socket, but slightly different semantics
    300   1.41  jdolecek 		 * for SIGIO to the write side.  Rather than sending the SIGIO
    301   1.41  jdolecek 		 * every time it's possible to write (directly) more data, it
    302   1.41  jdolecek 		 * only sends SIGIO if last write(2) failed due to insufficient
    303   1.41  jdolecek 		 * memory to hold the data. This is compatible enough
    304   1.41  jdolecek 		 * with NetBSD semantics to not do anything about the
    305   1.41  jdolecek 		 * difference.
    306   1.65     perry 		 *
    307   1.41  jdolecek 		 * Linux does NOT send SIGIO for pipes. Deal with socketpair
    308   1.41  jdolecek 		 * ones and DTYPE_PIPE ones. For these, we don't set
    309   1.41  jdolecek 		 * the underlying flags (we don't pass O_ASYNC flag down
    310   1.41  jdolecek 		 * to sys_fcntl()), but set the FASYNC flag for file descriptor,
    311   1.41  jdolecek 		 * so that F_GETFL would report the ASYNC i/o is on.
    312   1.39      manu 		 */
    313   1.41  jdolecek 		if (val & O_ASYNC) {
    314   1.93        ad 			if (((fp1 = fd_getfile(fd)) == NULL))
    315   1.39      manu 			    return (EBADF);
    316   1.69  christos 			if (((fp1->f_type == DTYPE_SOCKET) && fp1->f_data
    317   1.69  christos 			      && ((struct socket *)fp1->f_data)->so_state & SS_ISAPIPE)
    318   1.69  christos 			    || (fp1->f_type == DTYPE_PIPE))
    319   1.41  jdolecek 				val &= ~O_ASYNC;
    320   1.41  jdolecek 			else {
    321   1.41  jdolecek 				/* not a pipe, do not modify anything */
    322   1.93        ad 				fd_putfile(fd);
    323   1.69  christos 				fp1 = NULL;
    324   1.39      manu 			}
    325   1.41  jdolecek 		}
    326   1.41  jdolecek 
    327   1.41  jdolecek 		SCARG(&fca, fd) = fd;
    328   1.41  jdolecek 		SCARG(&fca, cmd) = F_SETFL;
    329   1.79  christos 		SCARG(&fca, arg) = (void *) val;
    330   1.39      manu 
    331   1.56   thorpej 		error = sys_fcntl(l, &fca, retval);
    332   1.41  jdolecek 
    333   1.41  jdolecek 		/* Now set the FASYNC flag for pipes */
    334   1.69  christos 		if (fp1) {
    335   1.93        ad 			if (!error) {
    336   1.93        ad 				mutex_enter(&fp1->f_lock);
    337   1.69  christos 				fp1->f_flag |= FASYNC;
    338   1.93        ad 				mutex_exit(&fp1->f_lock);
    339   1.93        ad 			}
    340   1.93        ad 			fd_putfile(fd);
    341   1.39      manu 		}
    342   1.41  jdolecek 
    343   1.41  jdolecek 		return (error);
    344   1.41  jdolecek 	    }
    345   1.92       dsl 
    346    1.1      fvdl 	case LINUX_F_GETLK:
    347   1.92       dsl 		do_linux_getlk(fd, cmd, arg, linux, flock);
    348   1.47  christos 
    349    1.1      fvdl 	case LINUX_F_SETLK:
    350    1.1      fvdl 	case LINUX_F_SETLKW:
    351   1.92       dsl 		do_linux_setlk(fd, cmd, arg, linux, flock, LINUX_F_SETLK);
    352   1.47  christos 
    353    1.1      fvdl 	case LINUX_F_SETOWN:
    354   1.65     perry 	case LINUX_F_GETOWN:
    355   1.13      fvdl 		/*
    356   1.49  jdolecek 		 * We need to route fcntl() for tty descriptors around normal
    357   1.49  jdolecek 		 * fcntl(), since NetBSD tty TIOC{G,S}PGRP semantics is too
    358   1.49  jdolecek 		 * restrictive for Linux F_{G,S}ETOWN. For non-tty descriptors,
    359   1.49  jdolecek 		 * this is not a problem.
    360   1.13      fvdl 		 */
    361   1.93        ad 		if ((fp = fd_getfile(fd)) == NULL)
    362   1.13      fvdl 			return EBADF;
    363   1.60  jdolecek 
    364   1.60  jdolecek 		/* Check it's a character device vnode */
    365   1.60  jdolecek 		if (fp->f_type != DTYPE_VNODE
    366   1.60  jdolecek 		    || (vp = (struct vnode *)fp->f_data) == NULL
    367   1.60  jdolecek 		    || vp->v_type != VCHR) {
    368   1.93        ad 			fd_putfile(fd);
    369   1.60  jdolecek 
    370   1.53   gehenna 	    not_tty:
    371   1.49  jdolecek 			/* Not a tty, proceed with common fcntl() */
    372   1.13      fvdl 			cmd = cmd == LINUX_F_SETOWN ? F_SETOWN : F_GETOWN;
    373   1.49  jdolecek 			break;
    374   1.49  jdolecek 		}
    375   1.47  christos 
    376  1.104   hannken 		vn_lock(vp, LK_SHARED | LK_RETRY);
    377   1.86     pooka 		error = VOP_GETATTR(vp, &va, l->l_cred);
    378  1.104   hannken 		VOP_UNLOCK(vp);
    379   1.60  jdolecek 
    380   1.93        ad 		fd_putfile(fd);
    381   1.60  jdolecek 
    382   1.60  jdolecek 		if (error)
    383   1.49  jdolecek 			return error;
    384   1.60  jdolecek 
    385   1.94        ad 		if ((tp = cdev_tty(va.va_rdev)) == NULL)
    386   1.53   gehenna 			goto not_tty;
    387   1.49  jdolecek 
    388   1.49  jdolecek 		/* set tty pg_id appropriately */
    389   1.95        ad 		mutex_enter(proc_lock);
    390   1.49  jdolecek 		if (cmd == LINUX_F_GETOWN) {
    391   1.58       dsl 			retval[0] = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PGID;
    392   1.95        ad 			mutex_exit(proc_lock);
    393   1.49  jdolecek 			return 0;
    394   1.49  jdolecek 		}
    395   1.49  jdolecek 		if ((long)arg <= 0) {
    396   1.49  jdolecek 			pgid = -(long)arg;
    397   1.49  jdolecek 		} else {
    398   1.99     rmind 			struct proc *p1 = proc_find((long)arg);
    399   1.99     rmind 			if (p1 == NULL) {
    400   1.99     rmind 				mutex_exit(proc_lock);
    401   1.49  jdolecek 				return (ESRCH);
    402   1.99     rmind 			}
    403   1.49  jdolecek 			pgid = (long)p1->p_pgrp->pg_id;
    404   1.13      fvdl 		}
    405   1.99     rmind 		pgrp = pgrp_find(pgid);
    406   1.78       dsl 		if (pgrp == NULL || pgrp->pg_session != p->p_session) {
    407   1.95        ad 			mutex_exit(proc_lock);
    408   1.49  jdolecek 			return EPERM;
    409   1.78       dsl 		}
    410   1.49  jdolecek 		tp->t_pgrp = pgrp;
    411   1.95        ad 		mutex_exit(proc_lock);
    412   1.49  jdolecek 		return 0;
    413   1.47  christos 
    414    1.1      fvdl 	default:
    415    1.1      fvdl 		return EOPNOTSUPP;
    416    1.1      fvdl 	}
    417    1.1      fvdl 
    418    1.1      fvdl 	SCARG(&fca, fd) = fd;
    419    1.1      fvdl 	SCARG(&fca, cmd) = cmd;
    420    1.1      fvdl 	SCARG(&fca, arg) = arg;
    421   1.12   mycroft 
    422   1.56   thorpej 	return sys_fcntl(l, &fca, retval);
    423    1.1      fvdl }
    424    1.1      fvdl 
    425   1.67      manu #if !defined(__amd64__)
    426    1.1      fvdl /*
    427    1.1      fvdl  * Convert a NetBSD stat structure to a Linux stat structure.
    428    1.1      fvdl  * Only the order of the fields and the padding in the structure
    429    1.9      fvdl  * is different. linux_fakedev is a machine-dependent function
    430    1.9      fvdl  * which optionally converts device driver major/minor numbers
    431    1.9      fvdl  * (XXX horrible, but what can you do against code that compares
    432    1.9      fvdl  * things against constant major device numbers? sigh)
    433    1.1      fvdl  */
    434    1.1      fvdl static void
    435   1.88       dsl bsd_to_linux_stat(struct stat *bsp, struct linux_stat *lsp)
    436    1.1      fvdl {
    437   1.12   mycroft 
    438   1.45  christos 	lsp->lst_dev     = linux_fakedev(bsp->st_dev, 0);
    439    1.1      fvdl 	lsp->lst_ino     = bsp->st_ino;
    440   1.19  christos 	lsp->lst_mode    = (linux_mode_t)bsp->st_mode;
    441   1.19  christos 	if (bsp->st_nlink >= (1 << 15))
    442   1.19  christos 		lsp->lst_nlink = (1 << 15) - 1;
    443   1.19  christos 	else
    444   1.19  christos 		lsp->lst_nlink = (linux_nlink_t)bsp->st_nlink;
    445    1.1      fvdl 	lsp->lst_uid     = bsp->st_uid;
    446    1.1      fvdl 	lsp->lst_gid     = bsp->st_gid;
    447   1.45  christos 	lsp->lst_rdev    = linux_fakedev(bsp->st_rdev, 1);
    448    1.1      fvdl 	lsp->lst_size    = bsp->st_size;
    449    1.1      fvdl 	lsp->lst_blksize = bsp->st_blksize;
    450    1.1      fvdl 	lsp->lst_blocks  = bsp->st_blocks;
    451    1.1      fvdl 	lsp->lst_atime   = bsp->st_atime;
    452    1.1      fvdl 	lsp->lst_mtime   = bsp->st_mtime;
    453    1.1      fvdl 	lsp->lst_ctime   = bsp->st_ctime;
    454   1.66  christos #ifdef LINUX_STAT_HAS_NSEC
    455   1.66  christos 	lsp->lst_atime_nsec   = bsp->st_atimensec;
    456   1.66  christos 	lsp->lst_mtime_nsec   = bsp->st_mtimensec;
    457   1.66  christos 	lsp->lst_ctime_nsec   = bsp->st_ctimensec;
    458   1.66  christos #endif
    459    1.1      fvdl }
    460    1.1      fvdl 
    461    1.1      fvdl /*
    462    1.1      fvdl  * The stat functions below are plain sailing. stat and lstat are handled
    463    1.1      fvdl  * by one function to avoid code duplication.
    464    1.1      fvdl  */
    465    1.1      fvdl int
    466   1.90       dsl linux_sys_fstat(struct lwp *l, const struct linux_sys_fstat_args *uap, register_t *retval)
    467   1.11   thorpej {
    468   1.90       dsl 	/* {
    469    1.1      fvdl 		syscallarg(int) fd;
    470    1.1      fvdl 		syscallarg(linux_stat *) sp;
    471   1.90       dsl 	} */
    472    1.1      fvdl 	struct linux_stat tmplst;
    473   1.81       dsl 	struct stat tmpst;
    474    1.1      fvdl 	int error;
    475    1.1      fvdl 
    476   1.93        ad 	error = do_sys_fstat(SCARG(uap, fd), &tmpst);
    477   1.81       dsl 	if (error != 0)
    478    1.1      fvdl 		return error;
    479    1.1      fvdl 	bsd_to_linux_stat(&tmpst, &tmplst);
    480    1.1      fvdl 
    481   1.81       dsl 	return copyout(&tmplst, SCARG(uap, sp), sizeof tmplst);
    482    1.1      fvdl }
    483    1.1      fvdl 
    484    1.1      fvdl static int
    485   1.93        ad linux_stat1(const struct linux_sys_stat_args *uap, register_t *retval, int flags)
    486    1.1      fvdl {
    487    1.1      fvdl 	struct linux_stat tmplst;
    488   1.81       dsl 	struct stat tmpst;
    489    1.1      fvdl 	int error;
    490    1.1      fvdl 
    491   1.93        ad 	error = do_sys_stat(SCARG(uap, path), flags, &tmpst);
    492   1.81       dsl 	if (error != 0)
    493    1.1      fvdl 		return error;
    494    1.1      fvdl 
    495    1.1      fvdl 	bsd_to_linux_stat(&tmpst, &tmplst);
    496    1.1      fvdl 
    497   1.81       dsl 	return copyout(&tmplst, SCARG(uap, sp), sizeof tmplst);
    498    1.1      fvdl }
    499    1.1      fvdl 
    500    1.1      fvdl int
    501   1.90       dsl linux_sys_stat(struct lwp *l, const struct linux_sys_stat_args *uap, register_t *retval)
    502   1.11   thorpej {
    503   1.90       dsl 	/* {
    504   1.27  christos 		syscallarg(const char *) path;
    505    1.1      fvdl 		syscallarg(struct linux_stat *) sp;
    506   1.90       dsl 	} */
    507   1.11   thorpej 
    508   1.93        ad 	return linux_stat1(uap, retval, FOLLOW);
    509    1.1      fvdl }
    510    1.1      fvdl 
    511   1.23       erh /* Note: this is "newlstat" in the Linux sources */
    512   1.23       erh /*	(we don't bother with the old lstat currently) */
    513    1.1      fvdl int
    514   1.90       dsl linux_sys_lstat(struct lwp *l, const struct linux_sys_lstat_args *uap, register_t *retval)
    515   1.11   thorpej {
    516   1.90       dsl 	/* {
    517   1.27  christos 		syscallarg(const char *) path;
    518    1.1      fvdl 		syscallarg(struct linux_stat *) sp;
    519   1.90       dsl 	} */
    520   1.11   thorpej 
    521   1.93        ad 	return linux_stat1((const void *)uap, retval, NOFOLLOW);
    522    1.1      fvdl }
    523   1.67      manu #endif /* !__amd64__ */
    524    1.1      fvdl 
    525    1.1      fvdl /*
    526   1.10      fvdl  * The following syscalls are mostly here because of the alternate path check.
    527    1.1      fvdl  */
    528  1.106       chs 
    529    1.1      fvdl int
    530  1.106       chs linux_sys_linkat(struct lwp *l, const struct linux_sys_linkat_args *uap, register_t *retval)
    531    1.2      fvdl {
    532   1.90       dsl 	/* {
    533  1.106       chs 		syscallarg(int) fd1;
    534  1.106       chs 		syscallarg(const char *) name1;
    535  1.106       chs 		syscallarg(int) fd2;
    536  1.106       chs 		syscallarg(const char *) name2;
    537  1.106       chs 		syscallarg(int) flags;
    538   1.90       dsl 	} */
    539  1.106       chs 	int fd1 = SCARG(uap, fd1);
    540  1.106       chs 	const char *name1 = SCARG(uap, name1);
    541  1.106       chs 	int fd2 = SCARG(uap, fd2);
    542  1.106       chs 	const char *name2 = SCARG(uap, name2);
    543  1.106       chs 	int follow;
    544  1.106       chs 
    545  1.106       chs 	follow = SCARG(uap, flags) & LINUX_AT_SYMLINK_FOLLOW;
    546  1.106       chs 
    547  1.106       chs 	return do_sys_linkat(l, fd1, name1, fd2, name2, follow, retval);
    548  1.106       chs }
    549  1.106       chs 
    550  1.106       chs static int
    551  1.106       chs linux_unlink_dircheck(const char *path)
    552  1.106       chs {
    553  1.106       chs 	struct nameidata nd;
    554  1.101  dholland 	struct pathbuf *pb;
    555  1.106       chs 	int error;
    556   1.63  jdolecek 
    557   1.63  jdolecek 	/*
    558   1.63  jdolecek 	 * Linux returns EISDIR if unlink(2) is called on a directory.
    559   1.63  jdolecek 	 * We return EPERM in such cases. To emulate correct behaviour,
    560   1.63  jdolecek 	 * check if the path points to directory and return EISDIR if this
    561   1.63  jdolecek 	 * is the case.
    562  1.101  dholland 	 *
    563  1.101  dholland 	 * XXX this should really not copy in the path buffer twice...
    564   1.63  jdolecek 	 */
    565  1.106       chs 	error = pathbuf_copyin(path, &pb);
    566  1.106       chs 	if (error) {
    567  1.106       chs 		return error;
    568  1.101  dholland 	}
    569  1.101  dholland 	NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | TRYEMULROOT, pb);
    570   1.63  jdolecek 	if (namei(&nd) == 0) {
    571   1.63  jdolecek 		struct stat sb;
    572   1.63  jdolecek 
    573   1.93        ad 		if (vn_stat(nd.ni_vp, &sb) == 0
    574   1.63  jdolecek 		    && S_ISDIR(sb.st_mode))
    575   1.63  jdolecek 			error = EISDIR;
    576   1.63  jdolecek 
    577   1.63  jdolecek 		vput(nd.ni_vp);
    578   1.63  jdolecek 	}
    579  1.101  dholland 	pathbuf_destroy(pb);
    580  1.106       chs 	return error ? error : EPERM;
    581  1.106       chs }
    582   1.63  jdolecek 
    583  1.106       chs int
    584  1.106       chs linux_sys_unlink(struct lwp *l, const struct linux_sys_unlink_args *uap, register_t *retval)
    585  1.106       chs {
    586  1.106       chs 	/* {
    587  1.106       chs 		syscallarg(const char *) path;
    588  1.106       chs 	} */
    589  1.106       chs 	int error;
    590  1.106       chs 
    591  1.106       chs 	error = sys_unlink(l, (const void *)uap, retval);
    592  1.106       chs 	if (error == EPERM)
    593  1.106       chs 		error = linux_unlink_dircheck(SCARG(uap, path));
    594  1.106       chs 
    595  1.106       chs 	return error;
    596  1.106       chs }
    597  1.106       chs 
    598  1.106       chs int
    599  1.106       chs linux_sys_unlinkat(struct lwp *l, const struct linux_sys_unlinkat_args *uap, register_t *retval)
    600  1.106       chs {
    601  1.106       chs 	/* {
    602  1.106       chs 		syscallarg(int) fd;
    603  1.106       chs 		syscallarg(const char *) path;
    604  1.106       chs 		syscallarg(int) flag;
    605  1.106       chs 	} */
    606  1.106       chs 	struct sys_unlinkat_args ua;
    607  1.106       chs 	int error;
    608  1.106       chs 
    609  1.106       chs 	SCARG(&ua, fd) = SCARG(uap, fd);
    610  1.106       chs 	SCARG(&ua, path) = SCARG(uap, path);
    611  1.106       chs 	SCARG(&ua, flag) = linux_to_bsd_atflags(SCARG(uap, flag));
    612  1.106       chs 
    613  1.106       chs 	error = sys_unlinkat(l, &ua, retval);
    614  1.106       chs 	if (error == EPERM)
    615  1.106       chs 		error = linux_unlink_dircheck(SCARG(uap, path));
    616  1.106       chs 
    617  1.106       chs 	return error;
    618    1.2      fvdl }
    619    1.2      fvdl 
    620   1.10      fvdl int
    621   1.90       dsl linux_sys_mknod(struct lwp *l, const struct linux_sys_mknod_args *uap, register_t *retval)
    622   1.11   thorpej {
    623   1.90       dsl 	/* {
    624   1.27  christos 		syscallarg(const char *) path;
    625  1.106       chs 		syscallarg(linux_umode_t) mode;
    626  1.106       chs 		syscallarg(unsigned) dev;
    627  1.106       chs 	} */
    628  1.106       chs 	struct linux_sys_mknodat_args ua;
    629  1.106       chs 
    630  1.106       chs 	SCARG(&ua, fd) = LINUX_AT_FDCWD;
    631  1.106       chs 	SCARG(&ua, path) = SCARG(uap, path);
    632  1.106       chs 	SCARG(&ua, mode) = SCARG(uap, mode);
    633  1.106       chs 	SCARG(&ua, dev) = SCARG(uap, dev);
    634  1.106       chs 
    635  1.106       chs 	return linux_sys_mknodat(l, &ua, retval);
    636  1.106       chs }
    637  1.106       chs 
    638  1.106       chs int
    639  1.106       chs linux_sys_mknodat(struct lwp *l, const struct linux_sys_mknodat_args *uap, register_t *retval)
    640  1.106       chs {
    641  1.106       chs 	/* {
    642  1.106       chs 		syscallarg(int) fd;
    643  1.106       chs 		syscallarg(const char *) path;
    644  1.106       chs 		syscallarg(linux_umode_t) mode;
    645  1.106       chs 		syscallarg(unsigned) dev;
    646   1.90       dsl 	} */
    647    1.2      fvdl 
    648   1.10      fvdl 	/*
    649   1.40       wiz 	 * BSD handles FIFOs separately
    650   1.10      fvdl 	 */
    651   1.74     pavel 	if (S_ISFIFO(SCARG(uap, mode))) {
    652  1.106       chs 		struct sys_mkfifoat_args bma;
    653   1.54  jdolecek 
    654  1.106       chs 		SCARG(&bma, fd) = SCARG(uap, fd);
    655   1.21   thorpej 		SCARG(&bma, path) = SCARG(uap, path);
    656   1.21   thorpej 		SCARG(&bma, mode) = SCARG(uap, mode);
    657  1.106       chs 		return sys_mkfifoat(l, &bma, retval);
    658   1.54  jdolecek 	} else {
    659   1.54  jdolecek 
    660   1.54  jdolecek 		/*
    661   1.54  jdolecek 		 * Linux device numbers uses 8 bits for minor and 8 bits
    662   1.54  jdolecek 		 * for major. Due to how we map our major and minor,
    663   1.82       dsl 		 * this just fits into our dev_t. Just mask off the
    664   1.54  jdolecek 		 * upper 16bit to remove any random junk.
    665   1.54  jdolecek 		 */
    666  1.106       chs 
    667  1.106       chs 		return do_sys_mknodat(l, SCARG(uap, fd), SCARG(uap, path),
    668  1.106       chs 		    SCARG(uap, mode), SCARG(uap, dev) & 0xffff, retval,
    669  1.106       chs 		    UIO_USERSPACE);
    670   1.54  jdolecek 	}
    671    1.2      fvdl }
    672    1.2      fvdl 
    673  1.106       chs int
    674  1.106       chs linux_sys_fchmodat(struct lwp *l, const struct linux_sys_fchmodat_args *uap, register_t *retval)
    675  1.106       chs {
    676  1.106       chs 	/* {
    677  1.106       chs 		syscallarg(int) fd;
    678  1.106       chs 		syscallarg(const char *) path;
    679  1.106       chs 		syscallarg(linux_umode_t) mode;
    680  1.106       chs 	} */
    681  1.106       chs 
    682  1.106       chs 	return do_sys_chmodat(l, SCARG(uap, fd), SCARG(uap, path),
    683  1.106       chs 			      SCARG(uap, mode), AT_SYMLINK_FOLLOW);
    684  1.106       chs }
    685  1.106       chs 
    686  1.106       chs int
    687  1.106       chs linux_sys_fchownat(struct lwp *l, const struct linux_sys_fchownat_args *uap, register_t *retval)
    688  1.106       chs {
    689  1.106       chs 	/* {
    690  1.106       chs 		syscallarg(int) fd;
    691  1.106       chs 		syscallarg(const char *) path;
    692  1.106       chs 		syscallarg(uid_t) owner;
    693  1.106       chs 		syscallarg(gid_t) group;
    694  1.106       chs 		syscallarg(int) flag;
    695  1.106       chs 	} */
    696  1.106       chs 	int flag;
    697  1.106       chs 
    698  1.106       chs 	flag = linux_to_bsd_atflags(SCARG(uap, flag));
    699  1.106       chs 	return do_sys_chownat(l, SCARG(uap, fd), SCARG(uap, path),
    700  1.106       chs 			      SCARG(uap, owner), SCARG(uap, group), flag);
    701  1.106       chs }
    702  1.106       chs 
    703  1.106       chs int
    704  1.106       chs linux_sys_faccessat(struct lwp *l, const struct linux_sys_faccessat_args *uap, register_t *retval)
    705  1.106       chs {
    706  1.106       chs 	/* {
    707  1.106       chs 		syscallarg(int) fd;
    708  1.106       chs 		syscallarg(const char *) path;
    709  1.106       chs 		syscallarg(int) amode;
    710  1.106       chs 	} */
    711  1.106       chs 
    712  1.106       chs 	return do_sys_accessat(l, SCARG(uap, fd), SCARG(uap, path),
    713  1.106       chs 	     SCARG(uap, amode), AT_SYMLINK_FOLLOW);
    714  1.106       chs }
    715  1.106       chs 
    716   1.15      fvdl /*
    717   1.15      fvdl  * This is just fsync() for now (just as it is in the Linux kernel)
    718   1.23       erh  * Note: this is not implemented under Linux on Alpha and Arm
    719   1.23       erh  *	but should still be defined in our syscalls.master.
    720   1.23       erh  *	(syscall #148 on the arm)
    721   1.15      fvdl  */
    722   1.15      fvdl int
    723   1.90       dsl linux_sys_fdatasync(struct lwp *l, const struct linux_sys_fdatasync_args *uap, register_t *retval)
    724   1.15      fvdl {
    725   1.90       dsl 	/* {
    726   1.15      fvdl 		syscallarg(int) fd;
    727   1.90       dsl 	} */
    728   1.90       dsl 
    729   1.90       dsl 	return sys_fsync(l, (const void *)uap, retval);
    730   1.28      tron }
    731   1.28      tron 
    732   1.28      tron /*
    733   1.28      tron  * pread(2).
    734   1.28      tron  */
    735   1.28      tron int
    736   1.90       dsl linux_sys_pread(struct lwp *l, const struct linux_sys_pread_args *uap, register_t *retval)
    737   1.28      tron {
    738   1.90       dsl 	/* {
    739   1.28      tron 		syscallarg(int) fd;
    740   1.28      tron 		syscallarg(void *) buf;
    741   1.28      tron 		syscallarg(size_t) nbyte;
    742  1.109     njoly 		syscallarg(off_t) offset;
    743   1.90       dsl 	} */
    744   1.28      tron 	struct sys_pread_args pra;
    745   1.28      tron 
    746   1.28      tron 	SCARG(&pra, fd) = SCARG(uap, fd);
    747   1.28      tron 	SCARG(&pra, buf) = SCARG(uap, buf);
    748   1.28      tron 	SCARG(&pra, nbyte) = SCARG(uap, nbyte);
    749  1.109     njoly 	SCARG(&pra, PAD) = 0;
    750   1.28      tron 	SCARG(&pra, offset) = SCARG(uap, offset);
    751   1.28      tron 
    752   1.62  jdolecek 	return sys_pread(l, &pra, retval);
    753   1.28      tron }
    754   1.28      tron 
    755   1.28      tron /*
    756   1.28      tron  * pwrite(2).
    757   1.28      tron  */
    758   1.28      tron int
    759   1.90       dsl linux_sys_pwrite(struct lwp *l, const struct linux_sys_pwrite_args *uap, register_t *retval)
    760   1.28      tron {
    761   1.90       dsl 	/* {
    762   1.28      tron 		syscallarg(int) fd;
    763   1.28      tron 		syscallarg(void *) buf;
    764   1.28      tron 		syscallarg(size_t) nbyte;
    765  1.110     njoly 		syscallarg(off_t) offset;
    766   1.90       dsl 	} */
    767   1.28      tron 	struct sys_pwrite_args pra;
    768   1.28      tron 
    769   1.28      tron 	SCARG(&pra, fd) = SCARG(uap, fd);
    770   1.28      tron 	SCARG(&pra, buf) = SCARG(uap, buf);
    771   1.28      tron 	SCARG(&pra, nbyte) = SCARG(uap, nbyte);
    772  1.109     njoly 	SCARG(&pra, PAD) = 0;
    773   1.28      tron 	SCARG(&pra, offset) = SCARG(uap, offset);
    774   1.28      tron 
    775   1.62  jdolecek 	return sys_pwrite(l, &pra, retval);
    776    1.1      fvdl }
    777   1.68      fvdl 
    778  1.103  christos int
    779  1.103  christos linux_sys_dup3(struct lwp *l, const struct linux_sys_dup3_args *uap,
    780  1.103  christos     register_t *retval)
    781  1.103  christos {
    782  1.103  christos 	/* {
    783  1.103  christos 		syscallarg(int) from;
    784  1.103  christos 		syscallarg(int) to;
    785  1.103  christos 		syscallarg(int) flags;
    786  1.103  christos 	} */
    787  1.103  christos 	int error;
    788  1.103  christos 	if ((error = sys_dup2(l, (const struct sys_dup2_args *)uap, retval)))
    789  1.103  christos 		return error;
    790  1.103  christos 
    791  1.103  christos 	if (SCARG(uap, flags) & LINUX_O_CLOEXEC)
    792  1.103  christos 		fd_set_exclose(l, SCARG(uap, to), true);
    793  1.103  christos 
    794  1.103  christos 	return 0;
    795  1.103  christos }
    796  1.103  christos 
    797  1.105     njoly 
    798  1.105     njoly int
    799  1.105     njoly linux_to_bsd_atflags(int lflags)
    800  1.105     njoly {
    801  1.105     njoly 	int bflags = 0;
    802  1.105     njoly 
    803  1.105     njoly 	if (lflags & LINUX_AT_SYMLINK_NOFOLLOW)
    804  1.105     njoly 		bflags |= AT_SYMLINK_NOFOLLOW;
    805  1.105     njoly 	if (lflags & LINUX_AT_REMOVEDIR)
    806  1.105     njoly 		bflags |= AT_REMOVEDIR;
    807  1.105     njoly 	if (lflags & LINUX_AT_SYMLINK_FOLLOW)
    808  1.105     njoly 		bflags |= AT_SYMLINK_FOLLOW;
    809  1.105     njoly 
    810  1.105     njoly 	return bflags;
    811  1.105     njoly }
    812  1.105     njoly 
    813  1.105     njoly 
    814   1.75  christos #define LINUX_NOT_SUPPORTED(fun) \
    815   1.75  christos int \
    816   1.90       dsl fun(struct lwp *l, const struct fun##_args *uap, register_t *retval) \
    817   1.75  christos { \
    818   1.75  christos 	return EOPNOTSUPP; \
    819   1.75  christos }
    820   1.75  christos 
    821   1.75  christos LINUX_NOT_SUPPORTED(linux_sys_setxattr)
    822   1.75  christos LINUX_NOT_SUPPORTED(linux_sys_lsetxattr)
    823   1.75  christos LINUX_NOT_SUPPORTED(linux_sys_fsetxattr)
    824   1.75  christos 
    825   1.75  christos LINUX_NOT_SUPPORTED(linux_sys_getxattr)
    826   1.75  christos LINUX_NOT_SUPPORTED(linux_sys_lgetxattr)
    827   1.75  christos LINUX_NOT_SUPPORTED(linux_sys_fgetxattr)
    828   1.75  christos 
    829   1.75  christos LINUX_NOT_SUPPORTED(linux_sys_listxattr)
    830   1.75  christos LINUX_NOT_SUPPORTED(linux_sys_llistxattr)
    831   1.75  christos LINUX_NOT_SUPPORTED(linux_sys_flistxattr)
    832   1.75  christos 
    833   1.75  christos LINUX_NOT_SUPPORTED(linux_sys_removexattr)
    834   1.75  christos LINUX_NOT_SUPPORTED(linux_sys_lremovexattr)
    835   1.75  christos LINUX_NOT_SUPPORTED(linux_sys_fremovexattr)
    836