Home | History | Annotate | Line # | Download | only in freebsd
freebsd_file.c revision 1.28.16.2
      1  1.28.16.2        ad /*	$NetBSD: freebsd_file.c,v 1.28.16.2 2007/12/26 21:38:52 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.28.16.2        ad __KERNEL_RCSID(0, "$NetBSD: freebsd_file.c,v 1.28.16.2 2007/12/26 21:38:52 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.28  christos #include <compat/sys/mount.h>
     60        1.1   mycroft 
     61        1.1   mycroft #define	ARRAY_LENGTH(array)	(sizeof(array)/sizeof(array[0]))
     62        1.1   mycroft 
     63  1.28.16.1        ad static const char * convert_from_freebsd_mount_type(int);
     64        1.3  christos 
     65       1.12  jdolecek static const char *
     66  1.28.16.2        ad convert_from_freebsd_mount_type(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.28.16.2        ad freebsd_sys_mount(struct lwp *l, const struct freebsd_sys_mount_args *uap, register_t *retval)
     98        1.1   mycroft {
     99  1.28.16.2        ad 	/* {
    100        1.1   mycroft 		syscallarg(int) type;
    101        1.1   mycroft 		syscallarg(char *) path;
    102        1.1   mycroft 		syscallarg(int) flags;
    103       1.24  christos 		syscallarg(void *) data;
    104  1.28.16.2        ad 	} */
    105       1.12  jdolecek 	const char *type;
    106       1.26       dsl 	struct vfsops *vfsops;
    107       1.26       dsl 	register_t dummy;
    108        1.1   mycroft 
    109        1.1   mycroft 	if ((type = convert_from_freebsd_mount_type(SCARG(uap, type))) == NULL)
    110        1.1   mycroft 		return ENODEV;
    111       1.26       dsl 	vfsops = vfs_getopsbyname(type);
    112       1.26       dsl 	if (vfsops == NULL)
    113       1.26       dsl 		return ENODEV;
    114       1.26       dsl 
    115       1.26       dsl 	return do_sys_mount(l, vfsops, NULL, SCARG(uap, path),
    116       1.26       dsl 	    SCARG(uap, flags), SCARG(uap, data), UIO_USERSPACE, 0, &dummy);
    117        1.1   mycroft }
    118        1.1   mycroft 
    119       1.24  christos /* XXX - UNIX domain: int freebsd_sys_bind(int s, void *name, int namelen); */
    120       1.24  christos /* XXX - UNIX domain: int freebsd_sys_connect(int s, void *name, int namelen); */
    121