Home | History | Annotate | Line # | Download | only in freebsd
freebsd_file.c revision 1.15
      1  1.15     lukem /*	$NetBSD: freebsd_file.c,v 1.15 2001/11/13 02:08:07 lukem 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.15     lukem 
     36  1.15     lukem #include <sys/cdefs.h>
     37  1.15     lukem __KERNEL_RCSID(0, "$NetBSD: freebsd_file.c,v 1.15 2001/11/13 02:08:07 lukem Exp $");
     38   1.9   thorpej 
     39  1.14       mrg #if defined(_KERNEL_OPT)
     40   1.9   thorpej #include "fs_nfs.h"
     41  1.11  jdolecek #endif
     42   1.1   mycroft 
     43   1.1   mycroft #include <sys/param.h>
     44   1.1   mycroft #include <sys/systm.h>
     45   1.1   mycroft #include <sys/namei.h>
     46   1.1   mycroft #include <sys/proc.h>
     47   1.1   mycroft #include <sys/file.h>
     48   1.1   mycroft #include <sys/stat.h>
     49   1.1   mycroft #include <sys/filedesc.h>
     50   1.1   mycroft #include <sys/ioctl.h>
     51   1.1   mycroft #include <sys/kernel.h>
     52   1.1   mycroft #include <sys/mount.h>
     53   1.1   mycroft #include <sys/malloc.h>
     54   1.1   mycroft 
     55   1.1   mycroft #include <sys/syscallargs.h>
     56   1.1   mycroft 
     57   1.1   mycroft #include <compat/freebsd/freebsd_syscallargs.h>
     58  1.10  jdolecek #include <compat/common/compat_util.h>
     59   1.1   mycroft 
     60   1.1   mycroft #define	ARRAY_LENGTH(array)	(sizeof(array)/sizeof(array[0]))
     61   1.1   mycroft 
     62  1.12  jdolecek static const char * convert_from_freebsd_mount_type __P((int));
     63   1.3  christos 
     64  1.12  jdolecek static const char *
     65   1.1   mycroft convert_from_freebsd_mount_type(type)
     66   1.1   mycroft 	int type;
     67   1.1   mycroft {
     68  1.12  jdolecek 	static const char * const netbsd_mount_type[] = {
     69   1.1   mycroft 		NULL,     /*  0 = MOUNT_NONE */
     70   1.2       gwr 		"ffs",	  /*  1 = "Fast" Filesystem */
     71   1.1   mycroft 		"nfs",	  /*  2 = Network Filesystem */
     72   1.1   mycroft 		"mfs",	  /*  3 = Memory Filesystem */
     73   1.1   mycroft 		"msdos",  /*  4 = MSDOS Filesystem */
     74   1.1   mycroft 		"lfs",	  /*  5 = Log-based Filesystem */
     75   1.1   mycroft 		"lofs",	  /*  6 = Loopback filesystem */
     76   1.1   mycroft 		"fdesc",  /*  7 = File Descriptor Filesystem */
     77   1.1   mycroft 		"portal", /*  8 = Portal Filesystem */
     78   1.1   mycroft 		"null",	  /*  9 = Minimal Filesystem Layer */
     79   1.1   mycroft 		"umap",	  /* 10 = User/Group Identifier Remapping Filesystem */
     80   1.1   mycroft 		"kernfs", /* 11 = Kernel Information Filesystem */
     81   1.1   mycroft 		"procfs", /* 12 = /proc Filesystem */
     82   1.1   mycroft 		"afs",	  /* 13 = Andrew Filesystem */
     83   1.1   mycroft 		"cd9660", /* 14 = ISO9660 (aka CDROM) Filesystem */
     84   1.1   mycroft 		"union",  /* 15 = Union (translucent) Filesystem */
     85   1.1   mycroft 		NULL,     /* 16 = "devfs" - existing device Filesystem */
     86   1.1   mycroft #if 0 /* These filesystems don't exist in FreeBSD */
     87   1.1   mycroft 		"adosfs", /* ?? = AmigaDOS Filesystem */
     88   1.1   mycroft #endif
     89   1.1   mycroft 	};
     90   1.1   mycroft 
     91   1.1   mycroft 	if (type < 0 || type >= ARRAY_LENGTH(netbsd_mount_type))
     92   1.1   mycroft 		return (NULL);
     93   1.1   mycroft 	return (netbsd_mount_type[type]);
     94   1.1   mycroft }
     95   1.1   mycroft 
     96   1.1   mycroft int
     97   1.1   mycroft freebsd_sys_mount(p, v, retval)
     98   1.1   mycroft 	struct proc *p;
     99   1.1   mycroft 	void *v;
    100   1.1   mycroft 	register_t *retval;
    101   1.1   mycroft {
    102   1.1   mycroft 	struct freebsd_sys_mount_args /* {
    103   1.1   mycroft 		syscallarg(int) type;
    104   1.1   mycroft 		syscallarg(char *) path;
    105   1.1   mycroft 		syscallarg(int) flags;
    106   1.1   mycroft 		syscallarg(caddr_t) data;
    107   1.1   mycroft 	} */ *uap = v;
    108   1.1   mycroft 	int error;
    109  1.12  jdolecek 	const char *type;
    110  1.12  jdolecek 	char *s;
    111   1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    112   1.1   mycroft 	struct sys_mount_args bma;
    113   1.1   mycroft 
    114   1.1   mycroft 	if ((type = convert_from_freebsd_mount_type(SCARG(uap, type))) == NULL)
    115   1.1   mycroft 		return ENODEV;
    116   1.1   mycroft 	s = stackgap_alloc(&sg, MFSNAMELEN + 1);
    117   1.3  christos 	if ((error = copyout(type, s, strlen(type) + 1)) != 0)
    118   1.1   mycroft 		return error;
    119   1.1   mycroft 	SCARG(&bma, type) = s;
    120  1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    121   1.1   mycroft 	SCARG(&bma, path) = SCARG(uap, path);
    122   1.1   mycroft 	SCARG(&bma, flags) = SCARG(uap, flags);
    123   1.1   mycroft 	SCARG(&bma, data) = SCARG(uap, data);
    124   1.1   mycroft 	return sys_mount(p, &bma, retval);
    125   1.1   mycroft }
    126   1.1   mycroft 
    127   1.1   mycroft /*
    128   1.1   mycroft  * The following syscalls are only here because of the alternate path check.
    129   1.1   mycroft  */
    130   1.1   mycroft 
    131   1.1   mycroft /* XXX - UNIX domain: int freebsd_sys_bind(int s, caddr_t name, int namelen); */
    132   1.1   mycroft /* XXX - UNIX domain: int freebsd_sys_connect(int s, caddr_t name, int namelen); */
    133   1.1   mycroft 
    134   1.1   mycroft 
    135   1.1   mycroft int
    136   1.1   mycroft freebsd_sys_open(p, v, retval)
    137   1.1   mycroft 	struct proc *p;
    138   1.1   mycroft 	void *v;
    139   1.1   mycroft 	register_t *retval;
    140   1.1   mycroft {
    141   1.1   mycroft 	struct freebsd_sys_open_args /* {
    142   1.1   mycroft 		syscallarg(char *) path;
    143   1.1   mycroft 		syscallarg(int) flags;
    144   1.1   mycroft 		syscallarg(int) mode;
    145   1.1   mycroft 	} */ *uap = v;
    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.1   mycroft 	return sys_open(p, uap, retval);
    153   1.1   mycroft }
    154   1.1   mycroft 
    155   1.1   mycroft int
    156   1.1   mycroft compat_43_freebsd_sys_creat(p, v, retval)
    157   1.1   mycroft 	struct proc *p;
    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.1   mycroft 	caddr_t sg  = stackgap_init(p->p_emul);
    166   1.1   mycroft 
    167  1.10  jdolecek 	CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
    168   1.1   mycroft 	return compat_43_sys_creat(p, uap, retval);
    169   1.1   mycroft }
    170   1.1   mycroft 
    171   1.1   mycroft int
    172   1.1   mycroft freebsd_sys_link(p, v, retval)
    173   1.1   mycroft 	struct proc *p;
    174   1.1   mycroft 	void *v;
    175   1.1   mycroft 	register_t *retval;
    176   1.1   mycroft {
    177   1.1   mycroft 	struct freebsd_sys_link_args /* {
    178   1.1   mycroft 		syscallarg(char *) path;
    179   1.1   mycroft 		syscallarg(char *) link;
    180   1.1   mycroft 	} */ *uap = v;
    181   1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    182   1.1   mycroft 
    183  1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    184  1.10  jdolecek 	CHECK_ALT_CREAT(p, &sg, SCARG(uap, link));
    185   1.1   mycroft 	return sys_link(p, uap, retval);
    186   1.1   mycroft }
    187   1.1   mycroft 
    188   1.1   mycroft int
    189   1.1   mycroft freebsd_sys_unlink(p, v, retval)
    190   1.1   mycroft 	struct proc *p;
    191   1.1   mycroft 	void *v;
    192   1.1   mycroft 	register_t *retval;
    193   1.1   mycroft {
    194   1.1   mycroft 	struct freebsd_sys_unlink_args /* {
    195   1.1   mycroft 		syscallarg(char *) path;
    196   1.1   mycroft 	} */ *uap = v;
    197   1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    198   1.1   mycroft 
    199  1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    200   1.1   mycroft 	return sys_unlink(p, uap, retval);
    201   1.1   mycroft }
    202   1.1   mycroft 
    203   1.1   mycroft int
    204   1.1   mycroft freebsd_sys_chdir(p, v, retval)
    205   1.1   mycroft 	struct proc *p;
    206   1.1   mycroft 	void *v;
    207   1.1   mycroft 	register_t *retval;
    208   1.1   mycroft {
    209   1.1   mycroft 	struct freebsd_sys_chdir_args /* {
    210   1.1   mycroft 		syscallarg(char *) path;
    211   1.1   mycroft 	} */ *uap = v;
    212   1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    213   1.1   mycroft 
    214  1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    215   1.1   mycroft 	return sys_chdir(p, uap, retval);
    216   1.1   mycroft }
    217   1.1   mycroft 
    218   1.1   mycroft int
    219   1.1   mycroft freebsd_sys_mknod(p, v, retval)
    220   1.1   mycroft 	struct proc *p;
    221   1.1   mycroft 	void *v;
    222   1.1   mycroft 	register_t *retval;
    223   1.1   mycroft {
    224   1.1   mycroft 	struct freebsd_sys_mknod_args /* {
    225   1.1   mycroft 		syscallarg(char *) path;
    226   1.1   mycroft 		syscallarg(int) mode;
    227   1.1   mycroft 		syscallarg(int) dev;
    228   1.1   mycroft 	} */ *uap = v;
    229   1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    230   1.1   mycroft 
    231  1.10  jdolecek 	CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
    232   1.1   mycroft 	return sys_mknod(p, uap, retval);
    233   1.1   mycroft }
    234   1.1   mycroft 
    235   1.1   mycroft int
    236   1.1   mycroft freebsd_sys_chmod(p, v, retval)
    237   1.1   mycroft 	struct proc *p;
    238   1.1   mycroft 	void *v;
    239   1.1   mycroft 	register_t *retval;
    240   1.1   mycroft {
    241   1.1   mycroft 	struct freebsd_sys_chmod_args /* {
    242   1.1   mycroft 		syscallarg(char *) path;
    243   1.1   mycroft 		syscallarg(int) mode;
    244   1.1   mycroft 	} */ *uap = v;
    245   1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    246   1.1   mycroft 
    247  1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    248   1.1   mycroft 	return sys_chmod(p, uap, retval);
    249   1.1   mycroft }
    250   1.1   mycroft 
    251   1.1   mycroft int
    252   1.1   mycroft freebsd_sys_chown(p, v, retval)
    253   1.1   mycroft 	struct proc *p;
    254   1.1   mycroft 	void *v;
    255   1.1   mycroft 	register_t *retval;
    256   1.1   mycroft {
    257   1.1   mycroft 	struct freebsd_sys_chown_args /* {
    258   1.1   mycroft 		syscallarg(char *) path;
    259   1.1   mycroft 		syscallarg(int) uid;
    260   1.1   mycroft 		syscallarg(int) gid;
    261   1.1   mycroft 	} */ *uap = v;
    262   1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    263   1.1   mycroft 
    264  1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    265   1.1   mycroft 	return sys_chown(p, uap, retval);
    266   1.6     enami }
    267   1.6     enami 
    268   1.6     enami int
    269   1.6     enami freebsd_sys_lchown(p, v, retval)
    270   1.6     enami 	struct proc *p;
    271   1.6     enami 	void *v;
    272   1.6     enami 	register_t *retval;
    273   1.6     enami {
    274   1.6     enami 	struct freebsd_sys_lchown_args /* {
    275   1.6     enami 		syscallarg(char *) path;
    276   1.6     enami 		syscallarg(int) uid;
    277   1.6     enami 		syscallarg(int) gid;
    278   1.6     enami 	} */ *uap = v;
    279   1.6     enami 	caddr_t sg = stackgap_init(p->p_emul);
    280   1.6     enami 
    281  1.13  jdolecek 	CHECK_ALT_SYMLINK(p, &sg, SCARG(uap, path));
    282   1.6     enami 	return sys_lchown(p, uap, retval);
    283   1.1   mycroft }
    284   1.1   mycroft 
    285   1.1   mycroft int
    286   1.1   mycroft freebsd_sys_unmount(p, v, retval)
    287   1.1   mycroft 	struct proc *p;
    288   1.1   mycroft 	void *v;
    289   1.1   mycroft 	register_t *retval;
    290   1.1   mycroft {
    291   1.1   mycroft 	struct freebsd_sys_unmount_args /* {
    292   1.1   mycroft 		syscallarg(char *) path;
    293   1.1   mycroft 		syscallarg(int) flags;
    294   1.1   mycroft 	} */ *uap = v;
    295   1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    296   1.1   mycroft 
    297  1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    298   1.1   mycroft 	return sys_unmount(p, uap, retval);
    299   1.1   mycroft }
    300   1.1   mycroft 
    301   1.1   mycroft int
    302   1.1   mycroft freebsd_sys_access(p, v, retval)
    303   1.1   mycroft 	struct proc *p;
    304   1.1   mycroft 	void *v;
    305   1.1   mycroft 	register_t *retval;
    306   1.1   mycroft {
    307   1.1   mycroft 	struct freebsd_sys_access_args /* {
    308   1.1   mycroft 		syscallarg(char *) path;
    309   1.1   mycroft 		syscallarg(int) flags;
    310   1.1   mycroft 	} */ *uap = v;
    311   1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    312   1.1   mycroft 
    313  1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    314   1.1   mycroft 	return sys_access(p, uap, retval);
    315   1.1   mycroft }
    316   1.1   mycroft 
    317   1.1   mycroft int
    318   1.1   mycroft freebsd_sys_chflags(p, v, retval)
    319   1.1   mycroft 	struct proc *p;
    320   1.1   mycroft 	void *v;
    321   1.1   mycroft 	register_t *retval;
    322   1.1   mycroft {
    323   1.1   mycroft 	struct freebsd_sys_chflags_args /* {
    324   1.1   mycroft 		syscallarg(char *) path;
    325   1.1   mycroft 		syscallarg(int) flags;
    326   1.1   mycroft 	} */ *uap = v;
    327   1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    328   1.1   mycroft 
    329  1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    330   1.1   mycroft 	return sys_chflags(p, uap, retval);
    331   1.1   mycroft }
    332   1.1   mycroft 
    333   1.1   mycroft int
    334   1.1   mycroft compat_43_freebsd_sys_stat(p, v, retval)
    335   1.1   mycroft 	struct proc *p;
    336   1.1   mycroft 	void *v;
    337   1.1   mycroft 	register_t *retval;
    338   1.1   mycroft {
    339   1.1   mycroft 	struct compat_43_freebsd_sys_stat_args /* {
    340   1.1   mycroft 		syscallarg(char *) path;
    341   1.7  christos 		syscallarg(struct stat43 *) ub;
    342   1.1   mycroft 	} */ *uap = v;
    343   1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    344   1.1   mycroft 
    345  1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    346   1.1   mycroft 	return compat_43_sys_stat(p, uap, retval);
    347   1.1   mycroft }
    348   1.1   mycroft 
    349   1.1   mycroft int
    350   1.1   mycroft compat_43_freebsd_sys_lstat(p, v, retval)
    351   1.1   mycroft 	struct proc *p;
    352   1.1   mycroft 	void *v;
    353   1.1   mycroft 	register_t *retval;
    354   1.1   mycroft {
    355   1.1   mycroft 	struct compat_43_freebsd_sys_lstat_args /* {
    356   1.1   mycroft 		syscallarg(char *) path;
    357   1.7  christos 		syscallarg(struct stat43 *) ub;
    358   1.1   mycroft 	} */ *uap = v;
    359   1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    360   1.1   mycroft 
    361  1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    362   1.1   mycroft 	return compat_43_sys_lstat(p, uap, retval);
    363   1.1   mycroft }
    364   1.1   mycroft 
    365   1.1   mycroft int
    366   1.1   mycroft freebsd_sys_revoke(p, v, retval)
    367   1.1   mycroft 	struct proc *p;
    368   1.1   mycroft 	void *v;
    369   1.1   mycroft 	register_t *retval;
    370   1.1   mycroft {
    371   1.1   mycroft 	struct freebsd_sys_revoke_args /* {
    372   1.1   mycroft 		syscallarg(char *) path;
    373   1.1   mycroft 	} */ *uap = v;
    374   1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    375   1.1   mycroft 
    376  1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    377   1.1   mycroft 	return sys_revoke(p, uap, retval);
    378   1.1   mycroft }
    379   1.1   mycroft 
    380   1.1   mycroft int
    381   1.1   mycroft freebsd_sys_symlink(p, v, retval)
    382   1.1   mycroft 	struct proc *p;
    383   1.1   mycroft 	void *v;
    384   1.1   mycroft 	register_t *retval;
    385   1.1   mycroft {
    386   1.1   mycroft 	struct freebsd_sys_symlink_args /* {
    387   1.1   mycroft 		syscallarg(char *) path;
    388   1.1   mycroft 		syscallarg(char *) link;
    389   1.1   mycroft 	} */ *uap = v;
    390   1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    391   1.1   mycroft 
    392  1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    393  1.10  jdolecek 	CHECK_ALT_CREAT(p, &sg, SCARG(uap, link));
    394   1.1   mycroft 	return sys_symlink(p, uap, retval);
    395   1.1   mycroft }
    396   1.1   mycroft 
    397   1.1   mycroft int
    398   1.1   mycroft freebsd_sys_readlink(p, v, retval)
    399   1.1   mycroft 	struct proc *p;
    400   1.1   mycroft 	void *v;
    401   1.1   mycroft 	register_t *retval;
    402   1.1   mycroft {
    403   1.1   mycroft 	struct freebsd_sys_readlink_args /* {
    404   1.1   mycroft 		syscallarg(char *) path;
    405   1.1   mycroft 		syscallarg(char *) buf;
    406   1.1   mycroft 		syscallarg(int) count;
    407   1.1   mycroft 	} */ *uap = v;
    408   1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    409   1.1   mycroft 
    410  1.13  jdolecek 	CHECK_ALT_SYMLINK(p, &sg, SCARG(uap, path));
    411   1.1   mycroft 	return sys_readlink(p, uap, retval);
    412   1.1   mycroft }
    413   1.1   mycroft 
    414   1.1   mycroft int
    415   1.1   mycroft freebsd_sys_execve(p, v, retval)
    416   1.1   mycroft 	struct proc *p;
    417   1.1   mycroft 	void *v;
    418   1.1   mycroft 	register_t *retval;
    419   1.1   mycroft {
    420   1.1   mycroft 	struct freebsd_sys_execve_args /* {
    421   1.1   mycroft 		syscallarg(char *) path;
    422   1.1   mycroft 		syscallarg(char **) argp;
    423   1.1   mycroft 		syscallarg(char **) envp;
    424   1.1   mycroft 	} */ *uap = v;
    425   1.4   mycroft 	struct sys_execve_args ap;
    426   1.4   mycroft 	caddr_t sg;
    427   1.1   mycroft 
    428   1.4   mycroft 	sg = stackgap_init(p->p_emul);
    429  1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    430   1.4   mycroft 
    431   1.4   mycroft 	SCARG(&ap, path) = SCARG(uap, path);
    432   1.4   mycroft 	SCARG(&ap, argp) = SCARG(uap, argp);
    433   1.4   mycroft 	SCARG(&ap, envp) = SCARG(uap, envp);
    434   1.4   mycroft 
    435   1.4   mycroft 	return sys_execve(p, &ap, retval);
    436   1.1   mycroft }
    437   1.1   mycroft 
    438   1.1   mycroft int
    439   1.1   mycroft freebsd_sys_chroot(p, v, retval)
    440   1.1   mycroft 	struct proc *p;
    441   1.1   mycroft 	void *v;
    442   1.1   mycroft 	register_t *retval;
    443   1.1   mycroft {
    444   1.1   mycroft 	struct freebsd_sys_chroot_args /* {
    445   1.1   mycroft 		syscallarg(char *) path;
    446   1.1   mycroft 	} */ *uap = v;
    447   1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    448   1.1   mycroft 
    449  1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    450   1.1   mycroft 	return sys_chroot(p, uap, retval);
    451   1.1   mycroft }
    452   1.1   mycroft 
    453   1.1   mycroft int
    454   1.1   mycroft freebsd_sys_rename(p, v, retval)
    455   1.1   mycroft 	struct proc *p;
    456   1.1   mycroft 	void *v;
    457   1.1   mycroft 	register_t *retval;
    458   1.1   mycroft {
    459   1.1   mycroft 	struct freebsd_sys_rename_args /* {
    460   1.1   mycroft 		syscallarg(char *) from;
    461   1.1   mycroft 		syscallarg(char *) to;
    462   1.1   mycroft 	} */ *uap = v;
    463   1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    464   1.1   mycroft 
    465  1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, from));
    466  1.10  jdolecek 	CHECK_ALT_CREAT(p, &sg, SCARG(uap, to));
    467   1.1   mycroft 	return sys_rename(p, uap, retval);
    468   1.1   mycroft }
    469   1.1   mycroft 
    470   1.1   mycroft int
    471   1.1   mycroft compat_43_freebsd_sys_truncate(p, v, retval)
    472   1.1   mycroft 	struct proc *p;
    473   1.1   mycroft 	void *v;
    474   1.1   mycroft 	register_t *retval;
    475   1.1   mycroft {
    476   1.1   mycroft 	struct compat_43_freebsd_sys_truncate_args /* {
    477   1.1   mycroft 		syscallarg(char *) path;
    478   1.1   mycroft 		syscallarg(long) length;
    479   1.1   mycroft 	} */ *uap = v;
    480   1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    481   1.1   mycroft 
    482  1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    483   1.1   mycroft 	return compat_43_sys_truncate(p, uap, retval);
    484   1.1   mycroft }
    485   1.1   mycroft 
    486   1.1   mycroft int
    487   1.1   mycroft freebsd_sys_mkfifo(p, v, retval)
    488   1.1   mycroft 	struct proc *p;
    489   1.1   mycroft 	void *v;
    490   1.1   mycroft 	register_t *retval;
    491   1.1   mycroft {
    492   1.1   mycroft 	struct freebsd_sys_mkfifo_args /* {
    493   1.1   mycroft 		syscallarg(char *) path;
    494   1.1   mycroft 		syscallarg(int) mode;
    495   1.1   mycroft 	} */ *uap = v;
    496   1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    497   1.1   mycroft 
    498  1.10  jdolecek 	CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
    499   1.1   mycroft 	return sys_mkfifo(p, uap, retval);
    500   1.1   mycroft }
    501   1.1   mycroft 
    502   1.1   mycroft int
    503   1.1   mycroft freebsd_sys_mkdir(p, v, retval)
    504   1.1   mycroft 	struct proc *p;
    505   1.1   mycroft 	void *v;
    506   1.1   mycroft 	register_t *retval;
    507   1.1   mycroft {
    508   1.1   mycroft 	struct freebsd_sys_mkdir_args /* {
    509   1.1   mycroft 		syscallarg(char *) path;
    510   1.1   mycroft 		syscallarg(int) mode;
    511   1.1   mycroft 	} */ *uap = v;
    512   1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    513   1.1   mycroft 
    514  1.10  jdolecek 	CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
    515   1.1   mycroft 	return sys_mkdir(p, uap, retval);
    516   1.1   mycroft }
    517   1.1   mycroft 
    518   1.1   mycroft int
    519   1.1   mycroft freebsd_sys_rmdir(p, v, retval)
    520   1.1   mycroft 	struct proc *p;
    521   1.1   mycroft 	void *v;
    522   1.1   mycroft 	register_t *retval;
    523   1.1   mycroft {
    524   1.1   mycroft 	struct freebsd_sys_rmdir_args /* {
    525   1.1   mycroft 		syscallarg(char *) path;
    526   1.1   mycroft 	} */ *uap = v;
    527   1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    528   1.1   mycroft 
    529  1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    530   1.1   mycroft 	return sys_rmdir(p, uap, retval);
    531   1.1   mycroft }
    532   1.1   mycroft 
    533   1.1   mycroft int
    534   1.1   mycroft freebsd_sys_statfs(p, v, retval)
    535   1.1   mycroft 	struct proc *p;
    536   1.1   mycroft 	void *v;
    537   1.1   mycroft 	register_t *retval;
    538   1.1   mycroft {
    539   1.1   mycroft 	struct freebsd_sys_stat_args /* {
    540   1.1   mycroft 		syscallarg(char *) path;
    541   1.1   mycroft 		syscallarg(struct statfs *) buf;
    542   1.1   mycroft 	} */ *uap = v;
    543   1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    544   1.1   mycroft 
    545  1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    546   1.1   mycroft 	return sys_statfs(p, uap, retval);
    547   1.1   mycroft }
    548   1.1   mycroft 
    549   1.5   thorpej #ifdef NFS
    550   1.1   mycroft int
    551   1.1   mycroft freebsd_sys_getfh(p, v, retval)
    552   1.1   mycroft 	struct proc *p;
    553   1.1   mycroft 	void *v;
    554   1.1   mycroft 	register_t *retval;
    555   1.1   mycroft {
    556   1.1   mycroft 	struct freebsd_sys_getfh_args /* {
    557   1.1   mycroft 		syscallarg(char *) fname;
    558   1.1   mycroft 		syscallarg(fhandle_t *) fhp;
    559   1.1   mycroft 	} */ *uap = v;
    560   1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    561   1.1   mycroft 
    562  1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, fname));
    563   1.1   mycroft 	return sys_getfh(p, uap, retval);
    564   1.1   mycroft }
    565   1.5   thorpej #endif /* NFS */
    566   1.1   mycroft 
    567   1.1   mycroft int
    568   1.1   mycroft freebsd_sys_stat(p, v, retval)
    569   1.1   mycroft 	struct proc *p;
    570   1.1   mycroft 	void *v;
    571   1.1   mycroft 	register_t *retval;
    572   1.1   mycroft {
    573   1.1   mycroft 	struct freebsd_sys_stat_args /* {
    574   1.1   mycroft 		syscallarg(char *) path;
    575   1.8  christos 		syscallarg(struct stat12 *) ub;
    576   1.1   mycroft 	} */ *uap = v;
    577   1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    578   1.1   mycroft 
    579  1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    580   1.8  christos 	return compat_12_sys_stat(p, uap, retval);
    581   1.1   mycroft }
    582   1.1   mycroft 
    583   1.1   mycroft int
    584   1.1   mycroft freebsd_sys_lstat(p, v, retval)
    585   1.1   mycroft 	struct proc *p;
    586   1.1   mycroft 	void *v;
    587   1.1   mycroft 	register_t *retval;
    588   1.1   mycroft {
    589   1.1   mycroft 	struct freebsd_sys_lstat_args /* {
    590   1.1   mycroft 		syscallarg(char *) path;
    591   1.8  christos 		syscallarg(struct stat12 *) ub;
    592   1.1   mycroft 	} */ *uap = v;
    593   1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    594   1.1   mycroft 
    595  1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    596   1.8  christos 	return compat_12_sys_lstat(p, uap, retval);
    597   1.1   mycroft }
    598   1.1   mycroft 
    599   1.1   mycroft int
    600   1.1   mycroft freebsd_sys_pathconf(p, v, retval)
    601   1.1   mycroft 	struct proc *p;
    602   1.1   mycroft 	void *v;
    603   1.1   mycroft 	register_t *retval;
    604   1.1   mycroft {
    605   1.1   mycroft 	struct freebsd_sys_pathconf_args /* {
    606   1.1   mycroft 		syscallarg(char *) path;
    607   1.1   mycroft 		syscallarg(int) name;
    608   1.1   mycroft 	} */ *uap = v;
    609   1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    610   1.1   mycroft 
    611  1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    612   1.1   mycroft 	return sys_pathconf(p, uap, retval);
    613   1.1   mycroft }
    614   1.1   mycroft 
    615   1.1   mycroft int
    616   1.1   mycroft freebsd_sys_truncate(p, v, retval)
    617   1.1   mycroft 	struct proc *p;
    618   1.1   mycroft 	void *v;
    619   1.1   mycroft 	register_t *retval;
    620   1.1   mycroft {
    621   1.1   mycroft 	struct freebsd_sys_truncate_args /* {
    622   1.1   mycroft 		syscallarg(char *) path;
    623   1.1   mycroft 		syscallarg(int) pad;
    624   1.1   mycroft 		syscallarg(off_t) length;
    625   1.1   mycroft 	} */ *uap = v;
    626   1.1   mycroft 	caddr_t sg = stackgap_init(p->p_emul);
    627   1.1   mycroft 
    628  1.10  jdolecek 	CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
    629   1.1   mycroft 	return sys_truncate(p, uap, retval);
    630   1.1   mycroft }
    631