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