Home | History | Annotate | Line # | Download | only in freebsd
freebsd_file.c revision 1.13.2.1
      1  1.13.2.1   nathanw /*	$NetBSD: freebsd_file.c,v 1.13.2.1 2001/03/05 22:49:20 nathanw Exp $	*/
      2       1.1   mycroft 
      3       1.1   mycroft /*
      4       1.1   mycroft  * Copyright (c) 1995 Frank van der Linden
      5       1.1   mycroft  * All rights reserved.
      6       1.1   mycroft  *
      7       1.1   mycroft  * Redistribution and use in source and binary forms, with or without
      8       1.1   mycroft  * modification, are permitted provided that the following conditions
      9       1.1   mycroft  * are met:
     10       1.1   mycroft  * 1. Redistributions of source code must retain the above copyright
     11       1.1   mycroft  *    notice, this list of conditions and the following disclaimer.
     12       1.1   mycroft  * 2. Redistributions in binary form must reproduce the above copyright
     13       1.1   mycroft  *    notice, this list of conditions and the following disclaimer in the
     14       1.1   mycroft  *    documentation and/or other materials provided with the distribution.
     15       1.1   mycroft  * 3. All advertising materials mentioning features or use of this software
     16       1.1   mycroft  *    must display the following acknowledgement:
     17       1.1   mycroft  *      This product includes software developed for the NetBSD Project
     18       1.1   mycroft  *      by Frank van der Linden
     19       1.1   mycroft  * 4. The name of the author may not be used to endorse or promote products
     20       1.1   mycroft  *    derived from this software without specific prior written permission
     21       1.1   mycroft  *
     22       1.1   mycroft  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     23       1.1   mycroft  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24       1.1   mycroft  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25       1.1   mycroft  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     26       1.1   mycroft  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     27       1.1   mycroft  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     28       1.1   mycroft  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     29       1.1   mycroft  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30       1.1   mycroft  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     31       1.1   mycroft  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32       1.1   mycroft  *
     33       1.1   mycroft  *	from: linux_file.c,v 1.3 1995/04/04 04:21:30 mycroft Exp
     34       1.1   mycroft  */
     35       1.9   thorpej 
     36      1.11  jdolecek #if defined(_KERNEL) && !defined(_LKM)
     37       1.9   thorpej #include "fs_nfs.h"
     38      1.11  jdolecek #endif
     39       1.1   mycroft 
     40       1.1   mycroft #include <sys/param.h>
     41       1.1   mycroft #include <sys/systm.h>
     42       1.1   mycroft #include <sys/namei.h>
     43  1.13.2.1   nathanw #include <sys/lwp.h>
     44       1.1   mycroft #include <sys/proc.h>
     45       1.1   mycroft #include <sys/file.h>
     46       1.1   mycroft #include <sys/stat.h>
     47       1.1   mycroft #include <sys/filedesc.h>
     48       1.1   mycroft #include <sys/ioctl.h>
     49       1.1   mycroft #include <sys/kernel.h>
     50       1.1   mycroft #include <sys/mount.h>
     51       1.1   mycroft #include <sys/malloc.h>
     52       1.1   mycroft 
     53       1.1   mycroft #include <sys/syscallargs.h>
     54       1.1   mycroft 
     55       1.1   mycroft #include <compat/freebsd/freebsd_syscallargs.h>
     56      1.10  jdolecek #include <compat/common/compat_util.h>
     57       1.1   mycroft 
     58       1.1   mycroft #define	ARRAY_LENGTH(array)	(sizeof(array)/sizeof(array[0]))
     59       1.1   mycroft 
     60      1.12  jdolecek static const char * convert_from_freebsd_mount_type __P((int));
     61       1.3  christos 
     62      1.12  jdolecek static const char *
     63       1.1   mycroft convert_from_freebsd_mount_type(type)
     64       1.1   mycroft 	int type;
     65       1.1   mycroft {
     66      1.12  jdolecek 	static const char * const netbsd_mount_type[] = {
     67       1.1   mycroft 		NULL,     /*  0 = MOUNT_NONE */
     68       1.2       gwr 		"ffs",	  /*  1 = "Fast" Filesystem */
     69       1.1   mycroft 		"nfs",	  /*  2 = Network Filesystem */
     70       1.1   mycroft 		"mfs",	  /*  3 = Memory Filesystem */
     71       1.1   mycroft 		"msdos",  /*  4 = MSDOS Filesystem */
     72       1.1   mycroft 		"lfs",	  /*  5 = Log-based Filesystem */
     73       1.1   mycroft 		"lofs",	  /*  6 = Loopback filesystem */
     74       1.1   mycroft 		"fdesc",  /*  7 = File Descriptor Filesystem */
     75       1.1   mycroft 		"portal", /*  8 = Portal Filesystem */
     76       1.1   mycroft 		"null",	  /*  9 = Minimal Filesystem Layer */
     77       1.1   mycroft 		"umap",	  /* 10 = User/Group Identifier Remapping Filesystem */
     78       1.1   mycroft 		"kernfs", /* 11 = Kernel Information Filesystem */
     79       1.1   mycroft 		"procfs", /* 12 = /proc Filesystem */
     80       1.1   mycroft 		"afs",	  /* 13 = Andrew Filesystem */
     81       1.1   mycroft 		"cd9660", /* 14 = ISO9660 (aka CDROM) Filesystem */
     82       1.1   mycroft 		"union",  /* 15 = Union (translucent) Filesystem */
     83       1.1   mycroft 		NULL,     /* 16 = "devfs" - existing device Filesystem */
     84       1.1   mycroft #if 0 /* These filesystems don't exist in FreeBSD */
     85       1.1   mycroft 		"adosfs", /* ?? = AmigaDOS Filesystem */
     86       1.1   mycroft #endif
     87       1.1   mycroft 	};
     88       1.1   mycroft 
     89       1.1   mycroft 	if (type < 0 || type >= ARRAY_LENGTH(netbsd_mount_type))
     90       1.1   mycroft 		return (NULL);
     91       1.1   mycroft 	return (netbsd_mount_type[type]);
     92       1.1   mycroft }
     93       1.1   mycroft 
     94       1.1   mycroft int
     95  1.13.2.1   nathanw freebsd_sys_mount(l, v, retval)
     96  1.13.2.1   nathanw 	struct lwp *l;
     97       1.1   mycroft 	void *v;
     98       1.1   mycroft 	register_t *retval;
     99       1.1   mycroft {
    100       1.1   mycroft 	struct freebsd_sys_mount_args /* {
    101       1.1   mycroft 		syscallarg(int) type;
    102       1.1   mycroft 		syscallarg(char *) path;
    103       1.1   mycroft 		syscallarg(int) flags;
    104       1.1   mycroft 		syscallarg(caddr_t) data;
    105       1.1   mycroft 	} */ *uap = v;
    106  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    107       1.1   mycroft 	int error;
    108      1.12  jdolecek 	const char *type;
    109      1.12  jdolecek 	char *s;
    110       1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    111       1.1   mycroft 	struct sys_mount_args bma;
    112       1.1   mycroft 
    113       1.1   mycroft 	if ((type = convert_from_freebsd_mount_type(SCARG(uap, type))) == NULL)
    114       1.1   mycroft 		return ENODEV;
    115       1.1   mycroft 	s = stackgap_alloc(&sg, MFSNAMELEN + 1);
    116       1.3  christos 	if ((error = copyout(type, s, strlen(type) + 1)) != 0)
    117       1.1   mycroft 		return error;
    118       1.1   mycroft 	SCARG(&bma, type) = s;
    119      1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    120       1.1   mycroft 	SCARG(&bma, path) = SCARG(uap, path);
    121       1.1   mycroft 	SCARG(&bma, flags) = SCARG(uap, flags);
    122       1.1   mycroft 	SCARG(&bma, data) = SCARG(uap, data);
    123  1.13.2.1   nathanw 	return sys_mount(l, &bma, retval);
    124       1.1   mycroft }
    125       1.1   mycroft 
    126       1.1   mycroft /*
    127       1.1   mycroft  * The following syscalls are only here because of the alternate path check.
    128       1.1   mycroft  */
    129       1.1   mycroft 
    130       1.1   mycroft /* XXX - UNIX domain: int freebsd_sys_bind(int s, caddr_t name, int namelen); */
    131       1.1   mycroft /* XXX - UNIX domain: int freebsd_sys_connect(int s, caddr_t name, int namelen); */
    132       1.1   mycroft 
    133       1.1   mycroft 
    134       1.1   mycroft int
    135  1.13.2.1   nathanw freebsd_sys_open(l, v, retval)
    136  1.13.2.1   nathanw 	struct lwp *l;
    137       1.1   mycroft 	void *v;
    138       1.1   mycroft 	register_t *retval;
    139       1.1   mycroft {
    140       1.1   mycroft 	struct freebsd_sys_open_args /* {
    141       1.1   mycroft 		syscallarg(char *) path;
    142       1.1   mycroft 		syscallarg(int) flags;
    143       1.1   mycroft 		syscallarg(int) mode;
    144       1.1   mycroft 	} */ *uap = v;
    145  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    146       1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    147       1.1   mycroft 
    148       1.1   mycroft 	if (SCARG(uap, flags) & O_CREAT)
    149      1.10  jdolecek 		CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
    150       1.1   mycroft 	else
    151      1.10  jdolecek 		CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    152  1.13.2.1   nathanw 	return sys_open(l, uap, retval);
    153       1.1   mycroft }
    154       1.1   mycroft 
    155       1.1   mycroft int
    156  1.13.2.1   nathanw compat_43_freebsd_sys_creat(l, v, retval)
    157  1.13.2.1   nathanw 	struct lwp *l;
    158       1.1   mycroft 	void *v;
    159       1.1   mycroft 	register_t *retval;
    160       1.1   mycroft {
    161       1.1   mycroft 	struct compat_43_freebsd_sys_creat_args /* {
    162       1.1   mycroft 		syscallarg(char *) path;
    163       1.1   mycroft 		syscallarg(int) mode;
    164       1.1   mycroft 	} */ *uap = v;
    165  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    166       1.1   mycroft 	caddr_t sg  = stackgap_init(p->p_emul);
    167       1.1   mycroft 
    168      1.10  jdolecek 	CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
    169  1.13.2.1   nathanw 	return compat_43_sys_creat(l, uap, retval);
    170       1.1   mycroft }
    171       1.1   mycroft 
    172       1.1   mycroft int
    173  1.13.2.1   nathanw freebsd_sys_link(l, v, retval)
    174  1.13.2.1   nathanw 	struct lwp *l;
    175       1.1   mycroft 	void *v;
    176       1.1   mycroft 	register_t *retval;
    177       1.1   mycroft {
    178       1.1   mycroft 	struct freebsd_sys_link_args /* {
    179       1.1   mycroft 		syscallarg(char *) path;
    180       1.1   mycroft 		syscallarg(char *) link;
    181       1.1   mycroft 	} */ *uap = v;
    182  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    183       1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    184       1.1   mycroft 
    185      1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    186      1.10  jdolecek 	CHECK_ALT_CREAT(p, &sg, SCARG(uap, link));
    187  1.13.2.1   nathanw 	return sys_link(l, uap, retval);
    188       1.1   mycroft }
    189       1.1   mycroft 
    190       1.1   mycroft int
    191  1.13.2.1   nathanw freebsd_sys_unlink(l, v, retval)
    192  1.13.2.1   nathanw 	struct lwp *l;
    193       1.1   mycroft 	void *v;
    194       1.1   mycroft 	register_t *retval;
    195       1.1   mycroft {
    196       1.1   mycroft 	struct freebsd_sys_unlink_args /* {
    197       1.1   mycroft 		syscallarg(char *) path;
    198       1.1   mycroft 	} */ *uap = v;
    199  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    200       1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    201       1.1   mycroft 
    202      1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    203  1.13.2.1   nathanw 	return sys_unlink(l, uap, retval);
    204       1.1   mycroft }
    205       1.1   mycroft 
    206       1.1   mycroft int
    207  1.13.2.1   nathanw freebsd_sys_chdir(l, v, retval)
    208  1.13.2.1   nathanw 	struct lwp *l;
    209       1.1   mycroft 	void *v;
    210       1.1   mycroft 	register_t *retval;
    211       1.1   mycroft {
    212       1.1   mycroft 	struct freebsd_sys_chdir_args /* {
    213       1.1   mycroft 		syscallarg(char *) path;
    214       1.1   mycroft 	} */ *uap = v;
    215  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    216       1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    217       1.1   mycroft 
    218      1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    219  1.13.2.1   nathanw 	return sys_chdir(l, uap, retval);
    220       1.1   mycroft }
    221       1.1   mycroft 
    222       1.1   mycroft int
    223  1.13.2.1   nathanw freebsd_sys_mknod(l, v, retval)
    224  1.13.2.1   nathanw 	struct lwp *l;
    225       1.1   mycroft 	void *v;
    226       1.1   mycroft 	register_t *retval;
    227       1.1   mycroft {
    228       1.1   mycroft 	struct freebsd_sys_mknod_args /* {
    229       1.1   mycroft 		syscallarg(char *) path;
    230       1.1   mycroft 		syscallarg(int) mode;
    231       1.1   mycroft 		syscallarg(int) dev;
    232       1.1   mycroft 	} */ *uap = v;
    233  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    234       1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    235       1.1   mycroft 
    236      1.10  jdolecek 	CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
    237  1.13.2.1   nathanw 	return sys_mknod(l, uap, retval);
    238       1.1   mycroft }
    239       1.1   mycroft 
    240       1.1   mycroft int
    241  1.13.2.1   nathanw freebsd_sys_chmod(l, v, retval)
    242  1.13.2.1   nathanw 	struct lwp *l;
    243       1.1   mycroft 	void *v;
    244       1.1   mycroft 	register_t *retval;
    245       1.1   mycroft {
    246       1.1   mycroft 	struct freebsd_sys_chmod_args /* {
    247       1.1   mycroft 		syscallarg(char *) path;
    248       1.1   mycroft 		syscallarg(int) mode;
    249       1.1   mycroft 	} */ *uap = v;
    250  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    251       1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    252       1.1   mycroft 
    253      1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    254  1.13.2.1   nathanw 	return sys_chmod(l, uap, retval);
    255       1.1   mycroft }
    256       1.1   mycroft 
    257       1.1   mycroft int
    258  1.13.2.1   nathanw freebsd_sys_chown(l, v, retval)
    259  1.13.2.1   nathanw 	struct lwp *l;
    260       1.1   mycroft 	void *v;
    261       1.1   mycroft 	register_t *retval;
    262       1.1   mycroft {
    263       1.1   mycroft 	struct freebsd_sys_chown_args /* {
    264       1.1   mycroft 		syscallarg(char *) path;
    265       1.1   mycroft 		syscallarg(int) uid;
    266       1.1   mycroft 		syscallarg(int) gid;
    267       1.1   mycroft 	} */ *uap = v;
    268  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    269       1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    270       1.1   mycroft 
    271      1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    272  1.13.2.1   nathanw 	return sys_chown(l, uap, retval);
    273       1.6     enami }
    274       1.6     enami 
    275       1.6     enami int
    276  1.13.2.1   nathanw freebsd_sys_lchown(l, v, retval)
    277  1.13.2.1   nathanw 	struct lwp *l;
    278       1.6     enami 	void *v;
    279       1.6     enami 	register_t *retval;
    280       1.6     enami {
    281       1.6     enami 	struct freebsd_sys_lchown_args /* {
    282       1.6     enami 		syscallarg(char *) path;
    283       1.6     enami 		syscallarg(int) uid;
    284       1.6     enami 		syscallarg(int) gid;
    285       1.6     enami 	} */ *uap = v;
    286  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    287       1.6     enami 	caddr_t sg = stackgap_init(p->p_emul);
    288       1.6     enami 
    289      1.13  jdolecek 	CHECK_ALT_SYMLINK(p, &sg, SCARG(uap, path));
    290  1.13.2.1   nathanw 	return sys_lchown(l, uap, retval);
    291       1.1   mycroft }
    292       1.1   mycroft 
    293       1.1   mycroft int
    294  1.13.2.1   nathanw freebsd_sys_unmount(l, v, retval)
    295  1.13.2.1   nathanw 	struct lwp *l;
    296       1.1   mycroft 	void *v;
    297       1.1   mycroft 	register_t *retval;
    298       1.1   mycroft {
    299       1.1   mycroft 	struct freebsd_sys_unmount_args /* {
    300       1.1   mycroft 		syscallarg(char *) path;
    301       1.1   mycroft 		syscallarg(int) flags;
    302       1.1   mycroft 	} */ *uap = v;
    303  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    304       1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    305       1.1   mycroft 
    306      1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    307  1.13.2.1   nathanw 	return sys_unmount(l, uap, retval);
    308       1.1   mycroft }
    309       1.1   mycroft 
    310       1.1   mycroft int
    311  1.13.2.1   nathanw freebsd_sys_access(l, v, retval)
    312  1.13.2.1   nathanw 	struct lwp *l;
    313       1.1   mycroft 	void *v;
    314       1.1   mycroft 	register_t *retval;
    315       1.1   mycroft {
    316       1.1   mycroft 	struct freebsd_sys_access_args /* {
    317       1.1   mycroft 		syscallarg(char *) path;
    318       1.1   mycroft 		syscallarg(int) flags;
    319       1.1   mycroft 	} */ *uap = v;
    320  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    321       1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    322       1.1   mycroft 
    323      1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    324  1.13.2.1   nathanw 	return sys_access(l, uap, retval);
    325       1.1   mycroft }
    326       1.1   mycroft 
    327       1.1   mycroft int
    328  1.13.2.1   nathanw freebsd_sys_chflags(l, v, retval)
    329  1.13.2.1   nathanw 	struct lwp *l;
    330       1.1   mycroft 	void *v;
    331       1.1   mycroft 	register_t *retval;
    332       1.1   mycroft {
    333       1.1   mycroft 	struct freebsd_sys_chflags_args /* {
    334       1.1   mycroft 		syscallarg(char *) path;
    335       1.1   mycroft 		syscallarg(int) flags;
    336       1.1   mycroft 	} */ *uap = v;
    337  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    338       1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    339       1.1   mycroft 
    340      1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    341  1.13.2.1   nathanw 	return sys_chflags(l, uap, retval);
    342       1.1   mycroft }
    343       1.1   mycroft 
    344       1.1   mycroft int
    345  1.13.2.1   nathanw compat_43_freebsd_sys_stat(l, v, retval)
    346  1.13.2.1   nathanw 	struct lwp *l;
    347       1.1   mycroft 	void *v;
    348       1.1   mycroft 	register_t *retval;
    349       1.1   mycroft {
    350       1.1   mycroft 	struct compat_43_freebsd_sys_stat_args /* {
    351       1.1   mycroft 		syscallarg(char *) path;
    352       1.7  christos 		syscallarg(struct stat43 *) ub;
    353       1.1   mycroft 	} */ *uap = v;
    354  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    355       1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    356       1.1   mycroft 
    357      1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    358  1.13.2.1   nathanw 	return compat_43_sys_stat(l, uap, retval);
    359       1.1   mycroft }
    360       1.1   mycroft 
    361       1.1   mycroft int
    362  1.13.2.1   nathanw compat_43_freebsd_sys_lstat(l, v, retval)
    363  1.13.2.1   nathanw 	struct lwp *l;
    364       1.1   mycroft 	void *v;
    365       1.1   mycroft 	register_t *retval;
    366       1.1   mycroft {
    367       1.1   mycroft 	struct compat_43_freebsd_sys_lstat_args /* {
    368       1.1   mycroft 		syscallarg(char *) path;
    369       1.7  christos 		syscallarg(struct stat43 *) ub;
    370       1.1   mycroft 	} */ *uap = v;
    371  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    372       1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    373       1.1   mycroft 
    374      1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    375  1.13.2.1   nathanw 	return compat_43_sys_lstat(l, uap, retval);
    376       1.1   mycroft }
    377       1.1   mycroft 
    378       1.1   mycroft int
    379  1.13.2.1   nathanw freebsd_sys_revoke(l, v, retval)
    380  1.13.2.1   nathanw 	struct lwp *l;
    381       1.1   mycroft 	void *v;
    382       1.1   mycroft 	register_t *retval;
    383       1.1   mycroft {
    384       1.1   mycroft 	struct freebsd_sys_revoke_args /* {
    385       1.1   mycroft 		syscallarg(char *) path;
    386       1.1   mycroft 	} */ *uap = v;
    387  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    388       1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    389       1.1   mycroft 
    390      1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    391  1.13.2.1   nathanw 	return sys_revoke(l, uap, retval);
    392       1.1   mycroft }
    393       1.1   mycroft 
    394       1.1   mycroft int
    395  1.13.2.1   nathanw freebsd_sys_symlink(l, v, retval)
    396  1.13.2.1   nathanw 	struct lwp *l;
    397       1.1   mycroft 	void *v;
    398       1.1   mycroft 	register_t *retval;
    399       1.1   mycroft {
    400       1.1   mycroft 	struct freebsd_sys_symlink_args /* {
    401       1.1   mycroft 		syscallarg(char *) path;
    402       1.1   mycroft 		syscallarg(char *) link;
    403       1.1   mycroft 	} */ *uap = v;
    404  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    405       1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    406       1.1   mycroft 
    407      1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    408      1.10  jdolecek 	CHECK_ALT_CREAT(p, &sg, SCARG(uap, link));
    409  1.13.2.1   nathanw 	return sys_symlink(l, uap, retval);
    410       1.1   mycroft }
    411       1.1   mycroft 
    412       1.1   mycroft int
    413  1.13.2.1   nathanw freebsd_sys_readlink(l, v, retval)
    414  1.13.2.1   nathanw 	struct lwp *l;
    415       1.1   mycroft 	void *v;
    416       1.1   mycroft 	register_t *retval;
    417       1.1   mycroft {
    418       1.1   mycroft 	struct freebsd_sys_readlink_args /* {
    419       1.1   mycroft 		syscallarg(char *) path;
    420       1.1   mycroft 		syscallarg(char *) buf;
    421       1.1   mycroft 		syscallarg(int) count;
    422       1.1   mycroft 	} */ *uap = v;
    423  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    424       1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    425       1.1   mycroft 
    426      1.13  jdolecek 	CHECK_ALT_SYMLINK(p, &sg, SCARG(uap, path));
    427  1.13.2.1   nathanw 	return sys_readlink(l, uap, retval);
    428       1.1   mycroft }
    429       1.1   mycroft 
    430       1.1   mycroft int
    431  1.13.2.1   nathanw freebsd_sys_execve(l, v, retval)
    432  1.13.2.1   nathanw 	struct lwp *l;
    433       1.1   mycroft 	void *v;
    434       1.1   mycroft 	register_t *retval;
    435       1.1   mycroft {
    436       1.1   mycroft 	struct freebsd_sys_execve_args /* {
    437       1.1   mycroft 		syscallarg(char *) path;
    438       1.1   mycroft 		syscallarg(char **) argp;
    439       1.1   mycroft 		syscallarg(char **) envp;
    440       1.1   mycroft 	} */ *uap = v;
    441  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    442       1.4   mycroft 	struct sys_execve_args ap;
    443       1.4   mycroft 	caddr_t sg;
    444       1.1   mycroft 
    445       1.4   mycroft 	sg = stackgap_init(p->p_emul);
    446      1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    447       1.4   mycroft 
    448       1.4   mycroft 	SCARG(&ap, path) = SCARG(uap, path);
    449       1.4   mycroft 	SCARG(&ap, argp) = SCARG(uap, argp);
    450       1.4   mycroft 	SCARG(&ap, envp) = SCARG(uap, envp);
    451       1.4   mycroft 
    452  1.13.2.1   nathanw 	return sys_execve(l, &ap, retval);
    453       1.1   mycroft }
    454       1.1   mycroft 
    455       1.1   mycroft int
    456  1.13.2.1   nathanw freebsd_sys_chroot(l, v, retval)
    457  1.13.2.1   nathanw 	struct lwp *l;
    458       1.1   mycroft 	void *v;
    459       1.1   mycroft 	register_t *retval;
    460       1.1   mycroft {
    461       1.1   mycroft 	struct freebsd_sys_chroot_args /* {
    462       1.1   mycroft 		syscallarg(char *) path;
    463       1.1   mycroft 	} */ *uap = v;
    464  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    465       1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    466       1.1   mycroft 
    467      1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    468  1.13.2.1   nathanw 	return sys_chroot(l, uap, retval);
    469       1.1   mycroft }
    470       1.1   mycroft 
    471       1.1   mycroft int
    472  1.13.2.1   nathanw freebsd_sys_rename(l, v, retval)
    473  1.13.2.1   nathanw 	struct lwp *l;
    474       1.1   mycroft 	void *v;
    475       1.1   mycroft 	register_t *retval;
    476       1.1   mycroft {
    477       1.1   mycroft 	struct freebsd_sys_rename_args /* {
    478       1.1   mycroft 		syscallarg(char *) from;
    479       1.1   mycroft 		syscallarg(char *) to;
    480       1.1   mycroft 	} */ *uap = v;
    481  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    482       1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    483       1.1   mycroft 
    484      1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, from));
    485      1.10  jdolecek 	CHECK_ALT_CREAT(p, &sg, SCARG(uap, to));
    486  1.13.2.1   nathanw 	return sys_rename(l, uap, retval);
    487       1.1   mycroft }
    488       1.1   mycroft 
    489       1.1   mycroft int
    490  1.13.2.1   nathanw compat_43_freebsd_sys_truncate(l, v, retval)
    491  1.13.2.1   nathanw 	struct lwp *l;
    492       1.1   mycroft 	void *v;
    493       1.1   mycroft 	register_t *retval;
    494       1.1   mycroft {
    495       1.1   mycroft 	struct compat_43_freebsd_sys_truncate_args /* {
    496       1.1   mycroft 		syscallarg(char *) path;
    497       1.1   mycroft 		syscallarg(long) length;
    498       1.1   mycroft 	} */ *uap = v;
    499  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    500       1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    501       1.1   mycroft 
    502      1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    503  1.13.2.1   nathanw 	return compat_43_sys_truncate(l, uap, retval);
    504       1.1   mycroft }
    505       1.1   mycroft 
    506       1.1   mycroft int
    507  1.13.2.1   nathanw freebsd_sys_mkfifo(l, v, retval)
    508  1.13.2.1   nathanw 	struct lwp *l;
    509       1.1   mycroft 	void *v;
    510       1.1   mycroft 	register_t *retval;
    511       1.1   mycroft {
    512       1.1   mycroft 	struct freebsd_sys_mkfifo_args /* {
    513       1.1   mycroft 		syscallarg(char *) path;
    514       1.1   mycroft 		syscallarg(int) mode;
    515       1.1   mycroft 	} */ *uap = v;
    516  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    517       1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    518       1.1   mycroft 
    519      1.10  jdolecek 	CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
    520  1.13.2.1   nathanw 	return sys_mkfifo(l, uap, retval);
    521       1.1   mycroft }
    522       1.1   mycroft 
    523       1.1   mycroft int
    524  1.13.2.1   nathanw freebsd_sys_mkdir(l, v, retval)
    525  1.13.2.1   nathanw 	struct lwp *l;
    526       1.1   mycroft 	void *v;
    527       1.1   mycroft 	register_t *retval;
    528       1.1   mycroft {
    529       1.1   mycroft 	struct freebsd_sys_mkdir_args /* {
    530       1.1   mycroft 		syscallarg(char *) path;
    531       1.1   mycroft 		syscallarg(int) mode;
    532       1.1   mycroft 	} */ *uap = v;
    533  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    534       1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    535       1.1   mycroft 
    536      1.10  jdolecek 	CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
    537  1.13.2.1   nathanw 	return sys_mkdir(l, uap, retval);
    538       1.1   mycroft }
    539       1.1   mycroft 
    540       1.1   mycroft int
    541  1.13.2.1   nathanw freebsd_sys_rmdir(l, v, retval)
    542  1.13.2.1   nathanw 	struct lwp *l;
    543       1.1   mycroft 	void *v;
    544       1.1   mycroft 	register_t *retval;
    545       1.1   mycroft {
    546       1.1   mycroft 	struct freebsd_sys_rmdir_args /* {
    547       1.1   mycroft 		syscallarg(char *) path;
    548       1.1   mycroft 	} */ *uap = v;
    549  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    550       1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    551       1.1   mycroft 
    552      1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    553  1.13.2.1   nathanw 	return sys_rmdir(l, uap, retval);
    554       1.1   mycroft }
    555       1.1   mycroft 
    556       1.1   mycroft int
    557  1.13.2.1   nathanw freebsd_sys_statfs(l, v, retval)
    558  1.13.2.1   nathanw 	struct lwp *l;
    559       1.1   mycroft 	void *v;
    560       1.1   mycroft 	register_t *retval;
    561       1.1   mycroft {
    562       1.1   mycroft 	struct freebsd_sys_stat_args /* {
    563       1.1   mycroft 		syscallarg(char *) path;
    564       1.1   mycroft 		syscallarg(struct statfs *) buf;
    565       1.1   mycroft 	} */ *uap = v;
    566  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    567       1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    568       1.1   mycroft 
    569      1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    570  1.13.2.1   nathanw 	return sys_statfs(l, uap, retval);
    571       1.1   mycroft }
    572       1.1   mycroft 
    573       1.5   thorpej #ifdef NFS
    574       1.1   mycroft int
    575  1.13.2.1   nathanw freebsd_sys_getfh(l, v, retval)
    576  1.13.2.1   nathanw 	struct lwp *l;
    577       1.1   mycroft 	void *v;
    578       1.1   mycroft 	register_t *retval;
    579       1.1   mycroft {
    580       1.1   mycroft 	struct freebsd_sys_getfh_args /* {
    581       1.1   mycroft 		syscallarg(char *) fname;
    582       1.1   mycroft 		syscallarg(fhandle_t *) fhp;
    583       1.1   mycroft 	} */ *uap = v;
    584  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    585       1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    586       1.1   mycroft 
    587      1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, fname));
    588  1.13.2.1   nathanw 	return sys_getfh(l, uap, retval);
    589       1.1   mycroft }
    590       1.5   thorpej #endif /* NFS */
    591       1.1   mycroft 
    592       1.1   mycroft int
    593  1.13.2.1   nathanw freebsd_sys_stat(l, v, retval)
    594  1.13.2.1   nathanw 	struct lwp *l;
    595       1.1   mycroft 	void *v;
    596       1.1   mycroft 	register_t *retval;
    597       1.1   mycroft {
    598       1.1   mycroft 	struct freebsd_sys_stat_args /* {
    599       1.1   mycroft 		syscallarg(char *) path;
    600       1.8  christos 		syscallarg(struct stat12 *) ub;
    601       1.1   mycroft 	} */ *uap = v;
    602  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    603       1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    604       1.1   mycroft 
    605      1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    606  1.13.2.1   nathanw 	return compat_12_sys_stat(l, uap, retval);
    607       1.1   mycroft }
    608       1.1   mycroft 
    609       1.1   mycroft int
    610  1.13.2.1   nathanw freebsd_sys_lstat(l, v, retval)
    611  1.13.2.1   nathanw 	struct lwp *l;
    612       1.1   mycroft 	void *v;
    613       1.1   mycroft 	register_t *retval;
    614       1.1   mycroft {
    615       1.1   mycroft 	struct freebsd_sys_lstat_args /* {
    616       1.1   mycroft 		syscallarg(char *) path;
    617       1.8  christos 		syscallarg(struct stat12 *) ub;
    618       1.1   mycroft 	} */ *uap = v;
    619  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    620       1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    621       1.1   mycroft 
    622      1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    623  1.13.2.1   nathanw 	return compat_12_sys_lstat(l, uap, retval);
    624       1.1   mycroft }
    625       1.1   mycroft 
    626       1.1   mycroft int
    627  1.13.2.1   nathanw freebsd_sys_pathconf(l, v, retval)
    628  1.13.2.1   nathanw 	struct lwp *l;
    629       1.1   mycroft 	void *v;
    630       1.1   mycroft 	register_t *retval;
    631       1.1   mycroft {
    632       1.1   mycroft 	struct freebsd_sys_pathconf_args /* {
    633       1.1   mycroft 		syscallarg(char *) path;
    634       1.1   mycroft 		syscallarg(int) name;
    635       1.1   mycroft 	} */ *uap = v;
    636  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    637       1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    638       1.1   mycroft 
    639      1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    640  1.13.2.1   nathanw 	return sys_pathconf(l, uap, retval);
    641       1.1   mycroft }
    642       1.1   mycroft 
    643       1.1   mycroft int
    644  1.13.2.1   nathanw freebsd_sys_truncate(l, v, retval)
    645  1.13.2.1   nathanw 	struct lwp *l;
    646       1.1   mycroft 	void *v;
    647       1.1   mycroft 	register_t *retval;
    648       1.1   mycroft {
    649       1.1   mycroft 	struct freebsd_sys_truncate_args /* {
    650       1.1   mycroft 		syscallarg(char *) path;
    651       1.1   mycroft 		syscallarg(int) pad;
    652       1.1   mycroft 		syscallarg(off_t) length;
    653       1.1   mycroft 	} */ *uap = v;
    654  1.13.2.1   nathanw 	struct proc *p = l->l_proc;
    655       1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    656       1.1   mycroft 
    657      1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    658  1.13.2.1   nathanw 	return sys_truncate(l, uap, retval);
    659       1.1   mycroft }
    660