Home | History | Annotate | Line # | Download | only in freebsd
freebsd_file.c revision 1.23
      1  1.23        ad /*	$NetBSD: freebsd_file.c,v 1.23 2007/02/09 21:55:16 ad 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.23        ad __KERNEL_RCSID(0, "$NetBSD: freebsd_file.c,v 1.23 2007/02/09 21:55:16 ad 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.17   thorpej freebsd_sys_mount(l, v, retval)
     98  1.17   thorpej 	struct lwp *l;
     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.17   thorpej 	struct proc *p = l->l_proc;
    109   1.1   mycroft 	int error;
    110  1.12  jdolecek 	const char *type;
    111  1.12  jdolecek 	char *s;
    112  1.16  christos 	caddr_t sg = stackgap_init(p, 0);
    113   1.1   mycroft 	struct sys_mount_args bma;
    114   1.1   mycroft 
    115   1.1   mycroft 	if ((type = convert_from_freebsd_mount_type(SCARG(uap, type))) == NULL)
    116   1.1   mycroft 		return ENODEV;
    117  1.16  christos 	s = stackgap_alloc(p, &sg, MFSNAMELEN + 1);
    118   1.3  christos 	if ((error = copyout(type, s, strlen(type) + 1)) != 0)
    119   1.1   mycroft 		return error;
    120   1.1   mycroft 	SCARG(&bma, type) = s;
    121  1.21  christos 	CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
    122   1.1   mycroft 	SCARG(&bma, path) = SCARG(uap, path);
    123   1.1   mycroft 	SCARG(&bma, flags) = SCARG(uap, flags);
    124   1.1   mycroft 	SCARG(&bma, data) = SCARG(uap, data);
    125  1.17   thorpej 	return sys_mount(l, &bma, retval);
    126   1.1   mycroft }
    127   1.1   mycroft 
    128   1.1   mycroft /*
    129   1.1   mycroft  * The following syscalls are only here because of the alternate path check.
    130   1.1   mycroft  */
    131   1.1   mycroft 
    132   1.1   mycroft /* XXX - UNIX domain: int freebsd_sys_bind(int s, caddr_t name, int namelen); */
    133   1.1   mycroft /* XXX - UNIX domain: int freebsd_sys_connect(int s, caddr_t name, int namelen); */
    134   1.1   mycroft 
    135   1.1   mycroft 
    136   1.1   mycroft int
    137  1.17   thorpej freebsd_sys_open(l, v, retval)
    138  1.17   thorpej 	struct lwp *l;
    139   1.1   mycroft 	void *v;
    140   1.1   mycroft 	register_t *retval;
    141   1.1   mycroft {
    142   1.1   mycroft 	struct freebsd_sys_open_args /* {
    143   1.1   mycroft 		syscallarg(char *) path;
    144   1.1   mycroft 		syscallarg(int) flags;
    145   1.1   mycroft 		syscallarg(int) mode;
    146   1.1   mycroft 	} */ *uap = v;
    147  1.17   thorpej 	struct proc *p = l->l_proc;
    148  1.16  christos 	caddr_t sg = stackgap_init(p, 0);
    149   1.1   mycroft 
    150   1.1   mycroft 	if (SCARG(uap, flags) & O_CREAT)
    151  1.21  christos 		CHECK_ALT_CREAT(l, &sg, SCARG(uap, path));
    152   1.1   mycroft 	else
    153  1.21  christos 		CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
    154  1.17   thorpej 	return sys_open(l, uap, retval);
    155   1.1   mycroft }
    156   1.1   mycroft 
    157   1.1   mycroft int
    158  1.17   thorpej compat_43_freebsd_sys_creat(l, v, retval)
    159  1.17   thorpej 	struct lwp *l;
    160   1.1   mycroft 	void *v;
    161   1.1   mycroft 	register_t *retval;
    162   1.1   mycroft {
    163   1.1   mycroft 	struct compat_43_freebsd_sys_creat_args /* {
    164   1.1   mycroft 		syscallarg(char *) path;
    165   1.1   mycroft 		syscallarg(int) mode;
    166   1.1   mycroft 	} */ *uap = v;
    167  1.17   thorpej 	struct proc *p = l->l_proc;
    168  1.16  christos 	caddr_t sg  = stackgap_init(p, 0);
    169   1.1   mycroft 
    170  1.21  christos 	CHECK_ALT_CREAT(l, &sg, SCARG(uap, path));
    171  1.17   thorpej 	return compat_43_sys_creat(l, uap, retval);
    172   1.1   mycroft }
    173   1.1   mycroft 
    174   1.1   mycroft int
    175  1.17   thorpej freebsd_sys_link(l, v, retval)
    176  1.17   thorpej 	struct lwp *l;
    177   1.1   mycroft 	void *v;
    178   1.1   mycroft 	register_t *retval;
    179   1.1   mycroft {
    180   1.1   mycroft 	struct freebsd_sys_link_args /* {
    181   1.1   mycroft 		syscallarg(char *) path;
    182   1.1   mycroft 		syscallarg(char *) link;
    183   1.1   mycroft 	} */ *uap = v;
    184  1.17   thorpej 	struct proc *p = l->l_proc;
    185  1.16  christos 	caddr_t sg = stackgap_init(p, 0);
    186   1.1   mycroft 
    187  1.21  christos 	CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
    188  1.21  christos 	CHECK_ALT_CREAT(l, &sg, SCARG(uap, link));
    189  1.17   thorpej 	return sys_link(l, uap, retval);
    190   1.1   mycroft }
    191   1.1   mycroft 
    192   1.1   mycroft int
    193  1.17   thorpej freebsd_sys_unlink(l, v, retval)
    194  1.17   thorpej 	struct lwp *l;
    195   1.1   mycroft 	void *v;
    196   1.1   mycroft 	register_t *retval;
    197   1.1   mycroft {
    198   1.1   mycroft 	struct freebsd_sys_unlink_args /* {
    199   1.1   mycroft 		syscallarg(char *) path;
    200   1.1   mycroft 	} */ *uap = v;
    201  1.17   thorpej 	struct proc *p = l->l_proc;
    202  1.16  christos 	caddr_t sg = stackgap_init(p, 0);
    203   1.1   mycroft 
    204  1.21  christos 	CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
    205  1.17   thorpej 	return sys_unlink(l, uap, retval);
    206   1.1   mycroft }
    207   1.1   mycroft 
    208   1.1   mycroft int
    209  1.17   thorpej freebsd_sys_chdir(l, v, retval)
    210  1.17   thorpej 	struct lwp *l;
    211   1.1   mycroft 	void *v;
    212   1.1   mycroft 	register_t *retval;
    213   1.1   mycroft {
    214   1.1   mycroft 	struct freebsd_sys_chdir_args /* {
    215   1.1   mycroft 		syscallarg(char *) path;
    216   1.1   mycroft 	} */ *uap = v;
    217  1.17   thorpej 	struct proc *p = l->l_proc;
    218  1.16  christos 	caddr_t sg = stackgap_init(p, 0);
    219   1.1   mycroft 
    220  1.21  christos 	CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
    221  1.17   thorpej 	return sys_chdir(l, uap, retval);
    222   1.1   mycroft }
    223   1.1   mycroft 
    224   1.1   mycroft int
    225  1.17   thorpej freebsd_sys_mknod(l, v, retval)
    226  1.17   thorpej 	struct lwp *l;
    227   1.1   mycroft 	void *v;
    228   1.1   mycroft 	register_t *retval;
    229   1.1   mycroft {
    230   1.1   mycroft 	struct freebsd_sys_mknod_args /* {
    231   1.1   mycroft 		syscallarg(char *) path;
    232   1.1   mycroft 		syscallarg(int) mode;
    233   1.1   mycroft 		syscallarg(int) dev;
    234   1.1   mycroft 	} */ *uap = v;
    235  1.17   thorpej 	struct proc *p = l->l_proc;
    236  1.16  christos 	caddr_t sg = stackgap_init(p, 0);
    237   1.1   mycroft 
    238  1.21  christos 	CHECK_ALT_CREAT(l, &sg, SCARG(uap, path));
    239  1.17   thorpej 	return sys_mknod(l, uap, retval);
    240   1.1   mycroft }
    241   1.1   mycroft 
    242   1.1   mycroft int
    243  1.17   thorpej freebsd_sys_chmod(l, v, retval)
    244  1.17   thorpej 	struct lwp *l;
    245   1.1   mycroft 	void *v;
    246   1.1   mycroft 	register_t *retval;
    247   1.1   mycroft {
    248   1.1   mycroft 	struct freebsd_sys_chmod_args /* {
    249   1.1   mycroft 		syscallarg(char *) path;
    250   1.1   mycroft 		syscallarg(int) mode;
    251   1.1   mycroft 	} */ *uap = v;
    252  1.17   thorpej 	struct proc *p = l->l_proc;
    253  1.16  christos 	caddr_t sg = stackgap_init(p, 0);
    254   1.1   mycroft 
    255  1.21  christos 	CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
    256  1.17   thorpej 	return sys_chmod(l, uap, retval);
    257   1.1   mycroft }
    258   1.1   mycroft 
    259   1.1   mycroft int
    260  1.17   thorpej freebsd_sys_chown(l, v, retval)
    261  1.17   thorpej 	struct lwp *l;
    262   1.1   mycroft 	void *v;
    263   1.1   mycroft 	register_t *retval;
    264   1.1   mycroft {
    265   1.1   mycroft 	struct freebsd_sys_chown_args /* {
    266   1.1   mycroft 		syscallarg(char *) path;
    267   1.1   mycroft 		syscallarg(int) uid;
    268   1.1   mycroft 		syscallarg(int) gid;
    269   1.1   mycroft 	} */ *uap = v;
    270  1.17   thorpej 	struct proc *p = l->l_proc;
    271  1.16  christos 	caddr_t sg = stackgap_init(p, 0);
    272   1.1   mycroft 
    273  1.21  christos 	CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
    274  1.17   thorpej 	return sys_chown(l, uap, retval);
    275   1.6     enami }
    276   1.6     enami 
    277   1.6     enami int
    278  1.17   thorpej freebsd_sys_lchown(l, v, retval)
    279  1.17   thorpej 	struct lwp *l;
    280   1.6     enami 	void *v;
    281   1.6     enami 	register_t *retval;
    282   1.6     enami {
    283   1.6     enami 	struct freebsd_sys_lchown_args /* {
    284   1.6     enami 		syscallarg(char *) path;
    285   1.6     enami 		syscallarg(int) uid;
    286   1.6     enami 		syscallarg(int) gid;
    287   1.6     enami 	} */ *uap = v;
    288  1.17   thorpej 	struct proc *p = l->l_proc;
    289  1.16  christos 	caddr_t sg = stackgap_init(p, 0);
    290   1.6     enami 
    291  1.21  christos 	CHECK_ALT_SYMLINK(l, &sg, SCARG(uap, path));
    292  1.17   thorpej 	return sys_lchown(l, uap, retval);
    293   1.1   mycroft }
    294   1.1   mycroft 
    295   1.1   mycroft int
    296  1.17   thorpej freebsd_sys_unmount(l, v, retval)
    297  1.17   thorpej 	struct lwp *l;
    298   1.1   mycroft 	void *v;
    299   1.1   mycroft 	register_t *retval;
    300   1.1   mycroft {
    301   1.1   mycroft 	struct freebsd_sys_unmount_args /* {
    302   1.1   mycroft 		syscallarg(char *) path;
    303   1.1   mycroft 		syscallarg(int) flags;
    304   1.1   mycroft 	} */ *uap = v;
    305  1.17   thorpej 	struct proc *p = l->l_proc;
    306  1.16  christos 	caddr_t sg = stackgap_init(p, 0);
    307   1.1   mycroft 
    308  1.21  christos 	CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
    309  1.17   thorpej 	return sys_unmount(l, uap, retval);
    310   1.1   mycroft }
    311   1.1   mycroft 
    312   1.1   mycroft int
    313  1.17   thorpej freebsd_sys_access(l, v, retval)
    314  1.17   thorpej 	struct lwp *l;
    315   1.1   mycroft 	void *v;
    316   1.1   mycroft 	register_t *retval;
    317   1.1   mycroft {
    318   1.1   mycroft 	struct freebsd_sys_access_args /* {
    319   1.1   mycroft 		syscallarg(char *) path;
    320   1.1   mycroft 		syscallarg(int) flags;
    321   1.1   mycroft 	} */ *uap = v;
    322  1.17   thorpej 	struct proc *p = l->l_proc;
    323  1.16  christos 	caddr_t sg = stackgap_init(p, 0);
    324   1.1   mycroft 
    325  1.21  christos 	CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
    326  1.17   thorpej 	return sys_access(l, uap, retval);
    327   1.1   mycroft }
    328   1.1   mycroft 
    329   1.1   mycroft int
    330  1.17   thorpej freebsd_sys_chflags(l, v, retval)
    331  1.17   thorpej 	struct lwp *l;
    332   1.1   mycroft 	void *v;
    333   1.1   mycroft 	register_t *retval;
    334   1.1   mycroft {
    335   1.1   mycroft 	struct freebsd_sys_chflags_args /* {
    336   1.1   mycroft 		syscallarg(char *) path;
    337   1.1   mycroft 		syscallarg(int) flags;
    338   1.1   mycroft 	} */ *uap = v;
    339  1.17   thorpej 	struct proc *p = l->l_proc;
    340  1.16  christos 	caddr_t sg = stackgap_init(p, 0);
    341   1.1   mycroft 
    342  1.21  christos 	CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
    343  1.17   thorpej 	return sys_chflags(l, uap, retval);
    344   1.1   mycroft }
    345   1.1   mycroft 
    346   1.1   mycroft int
    347  1.17   thorpej compat_43_freebsd_sys_stat(l, v, retval)
    348  1.17   thorpej 	struct lwp *l;
    349   1.1   mycroft 	void *v;
    350   1.1   mycroft 	register_t *retval;
    351   1.1   mycroft {
    352   1.1   mycroft 	struct compat_43_freebsd_sys_stat_args /* {
    353   1.1   mycroft 		syscallarg(char *) path;
    354   1.7  christos 		syscallarg(struct stat43 *) ub;
    355   1.1   mycroft 	} */ *uap = v;
    356  1.17   thorpej 	struct proc *p = l->l_proc;
    357  1.16  christos 	caddr_t sg = stackgap_init(p, 0);
    358   1.1   mycroft 
    359  1.21  christos 	CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
    360  1.17   thorpej 	return compat_43_sys_stat(l, uap, retval);
    361   1.1   mycroft }
    362   1.1   mycroft 
    363   1.1   mycroft int
    364  1.17   thorpej compat_43_freebsd_sys_lstat(l, v, retval)
    365  1.17   thorpej 	struct lwp *l;
    366   1.1   mycroft 	void *v;
    367   1.1   mycroft 	register_t *retval;
    368   1.1   mycroft {
    369   1.1   mycroft 	struct compat_43_freebsd_sys_lstat_args /* {
    370   1.1   mycroft 		syscallarg(char *) path;
    371   1.7  christos 		syscallarg(struct stat43 *) ub;
    372   1.1   mycroft 	} */ *uap = v;
    373  1.17   thorpej 	struct proc *p = l->l_proc;
    374  1.16  christos 	caddr_t sg = stackgap_init(p, 0);
    375   1.1   mycroft 
    376  1.21  christos 	CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
    377  1.17   thorpej 	return compat_43_sys_lstat(l, uap, retval);
    378   1.1   mycroft }
    379   1.1   mycroft 
    380   1.1   mycroft int
    381  1.17   thorpej freebsd_sys_revoke(l, v, retval)
    382  1.17   thorpej 	struct lwp *l;
    383   1.1   mycroft 	void *v;
    384   1.1   mycroft 	register_t *retval;
    385   1.1   mycroft {
    386   1.1   mycroft 	struct freebsd_sys_revoke_args /* {
    387   1.1   mycroft 		syscallarg(char *) path;
    388   1.1   mycroft 	} */ *uap = v;
    389  1.17   thorpej 	struct proc *p = l->l_proc;
    390  1.16  christos 	caddr_t sg = stackgap_init(p, 0);
    391   1.1   mycroft 
    392  1.21  christos 	CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
    393  1.17   thorpej 	return sys_revoke(l, uap, retval);
    394   1.1   mycroft }
    395   1.1   mycroft 
    396   1.1   mycroft int
    397  1.17   thorpej freebsd_sys_symlink(l, v, retval)
    398  1.17   thorpej 	struct lwp *l;
    399   1.1   mycroft 	void *v;
    400   1.1   mycroft 	register_t *retval;
    401   1.1   mycroft {
    402   1.1   mycroft 	struct freebsd_sys_symlink_args /* {
    403   1.1   mycroft 		syscallarg(char *) path;
    404   1.1   mycroft 		syscallarg(char *) link;
    405   1.1   mycroft 	} */ *uap = v;
    406  1.17   thorpej 	struct proc *p = l->l_proc;
    407  1.16  christos 	caddr_t sg = stackgap_init(p, 0);
    408   1.1   mycroft 
    409  1.21  christos 	CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
    410  1.21  christos 	CHECK_ALT_CREAT(l, &sg, SCARG(uap, link));
    411  1.17   thorpej 	return sys_symlink(l, uap, retval);
    412   1.1   mycroft }
    413   1.1   mycroft 
    414   1.1   mycroft int
    415  1.17   thorpej freebsd_sys_readlink(l, v, retval)
    416  1.17   thorpej 	struct lwp *l;
    417   1.1   mycroft 	void *v;
    418   1.1   mycroft 	register_t *retval;
    419   1.1   mycroft {
    420   1.1   mycroft 	struct freebsd_sys_readlink_args /* {
    421   1.1   mycroft 		syscallarg(char *) path;
    422   1.1   mycroft 		syscallarg(char *) buf;
    423   1.1   mycroft 		syscallarg(int) count;
    424   1.1   mycroft 	} */ *uap = v;
    425  1.17   thorpej 	struct proc *p = l->l_proc;
    426  1.16  christos 	caddr_t sg = stackgap_init(p, 0);
    427   1.1   mycroft 
    428  1.21  christos 	CHECK_ALT_SYMLINK(l, &sg, SCARG(uap, path));
    429  1.17   thorpej 	return sys_readlink(l, uap, retval);
    430   1.1   mycroft }
    431   1.1   mycroft 
    432   1.1   mycroft int
    433  1.17   thorpej freebsd_sys_execve(l, v, retval)
    434  1.17   thorpej 	struct lwp *l;
    435   1.1   mycroft 	void *v;
    436   1.1   mycroft 	register_t *retval;
    437   1.1   mycroft {
    438   1.1   mycroft 	struct freebsd_sys_execve_args /* {
    439   1.1   mycroft 		syscallarg(char *) path;
    440   1.1   mycroft 		syscallarg(char **) argp;
    441   1.1   mycroft 		syscallarg(char **) envp;
    442   1.1   mycroft 	} */ *uap = v;
    443  1.17   thorpej 	struct proc *p = l->l_proc;
    444   1.4   mycroft 	struct sys_execve_args ap;
    445   1.4   mycroft 	caddr_t sg;
    446   1.1   mycroft 
    447  1.16  christos 	sg = stackgap_init(p, 0);
    448  1.21  christos 	CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
    449   1.4   mycroft 
    450   1.4   mycroft 	SCARG(&ap, path) = SCARG(uap, path);
    451   1.4   mycroft 	SCARG(&ap, argp) = SCARG(uap, argp);
    452   1.4   mycroft 	SCARG(&ap, envp) = SCARG(uap, envp);
    453   1.4   mycroft 
    454  1.17   thorpej 	return sys_execve(l, &ap, retval);
    455   1.1   mycroft }
    456   1.1   mycroft 
    457   1.1   mycroft int
    458  1.17   thorpej freebsd_sys_chroot(l, v, retval)
    459  1.17   thorpej 	struct lwp *l;
    460   1.1   mycroft 	void *v;
    461   1.1   mycroft 	register_t *retval;
    462   1.1   mycroft {
    463   1.1   mycroft 	struct freebsd_sys_chroot_args /* {
    464   1.1   mycroft 		syscallarg(char *) path;
    465   1.1   mycroft 	} */ *uap = v;
    466  1.17   thorpej 	struct proc *p = l->l_proc;
    467  1.16  christos 	caddr_t sg = stackgap_init(p, 0);
    468   1.1   mycroft 
    469  1.21  christos 	CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
    470  1.17   thorpej 	return sys_chroot(l, uap, retval);
    471   1.1   mycroft }
    472   1.1   mycroft 
    473   1.1   mycroft int
    474  1.17   thorpej freebsd_sys_rename(l, v, retval)
    475  1.17   thorpej 	struct lwp *l;
    476   1.1   mycroft 	void *v;
    477   1.1   mycroft 	register_t *retval;
    478   1.1   mycroft {
    479   1.1   mycroft 	struct freebsd_sys_rename_args /* {
    480   1.1   mycroft 		syscallarg(char *) from;
    481   1.1   mycroft 		syscallarg(char *) to;
    482   1.1   mycroft 	} */ *uap = v;
    483  1.17   thorpej 	struct proc *p = l->l_proc;
    484  1.16  christos 	caddr_t sg = stackgap_init(p, 0);
    485   1.1   mycroft 
    486  1.21  christos 	CHECK_ALT_EXIST(l, &sg, SCARG(uap, from));
    487  1.21  christos 	CHECK_ALT_CREAT(l, &sg, SCARG(uap, to));
    488  1.17   thorpej 	return sys_rename(l, uap, retval);
    489   1.1   mycroft }
    490   1.1   mycroft 
    491   1.1   mycroft int
    492  1.17   thorpej compat_43_freebsd_sys_truncate(l, v, retval)
    493  1.17   thorpej 	struct lwp *l;
    494   1.1   mycroft 	void *v;
    495   1.1   mycroft 	register_t *retval;
    496   1.1   mycroft {
    497   1.1   mycroft 	struct compat_43_freebsd_sys_truncate_args /* {
    498   1.1   mycroft 		syscallarg(char *) path;
    499   1.1   mycroft 		syscallarg(long) length;
    500   1.1   mycroft 	} */ *uap = v;
    501  1.17   thorpej 	struct proc *p = l->l_proc;
    502  1.16  christos 	caddr_t sg = stackgap_init(p, 0);
    503   1.1   mycroft 
    504  1.21  christos 	CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
    505  1.17   thorpej 	return compat_43_sys_truncate(l, uap, retval);
    506   1.1   mycroft }
    507   1.1   mycroft 
    508   1.1   mycroft int
    509  1.17   thorpej freebsd_sys_mkfifo(l, v, retval)
    510  1.17   thorpej 	struct lwp *l;
    511   1.1   mycroft 	void *v;
    512   1.1   mycroft 	register_t *retval;
    513   1.1   mycroft {
    514   1.1   mycroft 	struct freebsd_sys_mkfifo_args /* {
    515   1.1   mycroft 		syscallarg(char *) path;
    516   1.1   mycroft 		syscallarg(int) mode;
    517   1.1   mycroft 	} */ *uap = v;
    518  1.17   thorpej 	struct proc *p = l->l_proc;
    519  1.16  christos 	caddr_t sg = stackgap_init(p, 0);
    520   1.1   mycroft 
    521  1.21  christos 	CHECK_ALT_CREAT(l, &sg, SCARG(uap, path));
    522  1.17   thorpej 	return sys_mkfifo(l, uap, retval);
    523   1.1   mycroft }
    524   1.1   mycroft 
    525   1.1   mycroft int
    526  1.17   thorpej freebsd_sys_mkdir(l, v, retval)
    527  1.17   thorpej 	struct lwp *l;
    528   1.1   mycroft 	void *v;
    529   1.1   mycroft 	register_t *retval;
    530   1.1   mycroft {
    531   1.1   mycroft 	struct freebsd_sys_mkdir_args /* {
    532   1.1   mycroft 		syscallarg(char *) path;
    533   1.1   mycroft 		syscallarg(int) mode;
    534   1.1   mycroft 	} */ *uap = v;
    535  1.17   thorpej 	struct proc *p = l->l_proc;
    536  1.16  christos 	caddr_t sg = stackgap_init(p, 0);
    537   1.1   mycroft 
    538  1.21  christos 	CHECK_ALT_CREAT(l, &sg, SCARG(uap, path));
    539  1.17   thorpej 	return sys_mkdir(l, uap, retval);
    540   1.1   mycroft }
    541   1.1   mycroft 
    542   1.1   mycroft int
    543  1.17   thorpej freebsd_sys_rmdir(l, v, retval)
    544  1.17   thorpej 	struct lwp *l;
    545   1.1   mycroft 	void *v;
    546   1.1   mycroft 	register_t *retval;
    547   1.1   mycroft {
    548   1.1   mycroft 	struct freebsd_sys_rmdir_args /* {
    549   1.1   mycroft 		syscallarg(char *) path;
    550   1.1   mycroft 	} */ *uap = v;
    551  1.17   thorpej 	struct proc *p = l->l_proc;
    552  1.16  christos 	caddr_t sg = stackgap_init(p, 0);
    553   1.1   mycroft 
    554  1.21  christos 	CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
    555  1.17   thorpej 	return sys_rmdir(l, uap, retval);
    556   1.1   mycroft }
    557   1.1   mycroft 
    558   1.1   mycroft int
    559  1.17   thorpej freebsd_sys_statfs(l, v, retval)
    560  1.17   thorpej 	struct lwp *l;
    561   1.1   mycroft 	void *v;
    562   1.1   mycroft 	register_t *retval;
    563   1.1   mycroft {
    564   1.1   mycroft 	struct freebsd_sys_stat_args /* {
    565   1.1   mycroft 		syscallarg(char *) path;
    566  1.20  christos 		syscallarg(struct statfs12 *) buf;
    567   1.1   mycroft 	} */ *uap = v;
    568  1.17   thorpej 	struct proc *p = l->l_proc;
    569  1.16  christos 	caddr_t sg = stackgap_init(p, 0);
    570   1.1   mycroft 
    571  1.21  christos 	CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
    572  1.20  christos 	return compat_20_sys_statfs(l, uap, retval);
    573   1.1   mycroft }
    574   1.1   mycroft 
    575   1.5   thorpej #ifdef NFS
    576   1.1   mycroft int
    577  1.17   thorpej freebsd_sys_getfh(l, v, retval)
    578  1.17   thorpej 	struct lwp *l;
    579   1.1   mycroft 	void *v;
    580   1.1   mycroft 	register_t *retval;
    581   1.1   mycroft {
    582   1.1   mycroft 	struct freebsd_sys_getfh_args /* {
    583   1.1   mycroft 		syscallarg(char *) fname;
    584   1.1   mycroft 		syscallarg(fhandle_t *) fhp;
    585   1.1   mycroft 	} */ *uap = v;
    586  1.17   thorpej 	struct proc *p = l->l_proc;
    587  1.16  christos 	caddr_t sg = stackgap_init(p, 0);
    588   1.1   mycroft 
    589  1.21  christos 	CHECK_ALT_EXIST(l, &sg, SCARG(uap, fname));
    590  1.22    martin 	return compat_30_sys_getfh(l, uap, retval);
    591   1.1   mycroft }
    592   1.5   thorpej #endif /* NFS */
    593   1.1   mycroft 
    594   1.1   mycroft int
    595  1.17   thorpej freebsd_sys_stat(l, v, retval)
    596  1.17   thorpej 	struct lwp *l;
    597   1.1   mycroft 	void *v;
    598   1.1   mycroft 	register_t *retval;
    599   1.1   mycroft {
    600   1.1   mycroft 	struct freebsd_sys_stat_args /* {
    601   1.1   mycroft 		syscallarg(char *) path;
    602   1.8  christos 		syscallarg(struct stat12 *) ub;
    603   1.1   mycroft 	} */ *uap = v;
    604  1.17   thorpej 	struct proc *p = l->l_proc;
    605  1.16  christos 	caddr_t sg = stackgap_init(p, 0);
    606   1.1   mycroft 
    607  1.21  christos 	CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
    608  1.17   thorpej 	return compat_12_sys_stat(l, uap, retval);
    609   1.1   mycroft }
    610   1.1   mycroft 
    611   1.1   mycroft int
    612  1.17   thorpej freebsd_sys_lstat(l, v, retval)
    613  1.17   thorpej 	struct lwp *l;
    614   1.1   mycroft 	void *v;
    615   1.1   mycroft 	register_t *retval;
    616   1.1   mycroft {
    617   1.1   mycroft 	struct freebsd_sys_lstat_args /* {
    618   1.1   mycroft 		syscallarg(char *) path;
    619   1.8  christos 		syscallarg(struct stat12 *) ub;
    620   1.1   mycroft 	} */ *uap = v;
    621  1.17   thorpej 	struct proc *p = l->l_proc;
    622  1.16  christos 	caddr_t sg = stackgap_init(p, 0);
    623   1.1   mycroft 
    624  1.21  christos 	CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
    625  1.17   thorpej 	return compat_12_sys_lstat(l, uap, retval);
    626   1.1   mycroft }
    627   1.1   mycroft 
    628   1.1   mycroft int
    629  1.17   thorpej freebsd_sys_pathconf(l, v, retval)
    630  1.17   thorpej 	struct lwp *l;
    631   1.1   mycroft 	void *v;
    632   1.1   mycroft 	register_t *retval;
    633   1.1   mycroft {
    634   1.1   mycroft 	struct freebsd_sys_pathconf_args /* {
    635   1.1   mycroft 		syscallarg(char *) path;
    636   1.1   mycroft 		syscallarg(int) name;
    637   1.1   mycroft 	} */ *uap = v;
    638  1.17   thorpej 	struct proc *p = l->l_proc;
    639  1.16  christos 	caddr_t sg = stackgap_init(p, 0);
    640   1.1   mycroft 
    641  1.21  christos 	CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
    642  1.17   thorpej 	return sys_pathconf(l, uap, retval);
    643   1.1   mycroft }
    644   1.1   mycroft 
    645   1.1   mycroft int
    646  1.17   thorpej freebsd_sys_truncate(l, v, retval)
    647  1.17   thorpej 	struct lwp *l;
    648   1.1   mycroft 	void *v;
    649   1.1   mycroft 	register_t *retval;
    650   1.1   mycroft {
    651   1.1   mycroft 	struct freebsd_sys_truncate_args /* {
    652   1.1   mycroft 		syscallarg(char *) path;
    653   1.1   mycroft 		syscallarg(int) pad;
    654   1.1   mycroft 		syscallarg(off_t) length;
    655   1.1   mycroft 	} */ *uap = v;
    656  1.17   thorpej 	struct proc *p = l->l_proc;
    657  1.16  christos 	caddr_t sg = stackgap_init(p, 0);
    658   1.1   mycroft 
    659  1.21  christos 	CHECK_ALT_EXIST(l, &sg, SCARG(uap, path));
    660  1.17   thorpej 	return sys_truncate(l, uap, retval);
    661   1.1   mycroft }
    662