freebsd_file.c revision 1.32
1/* $NetBSD: freebsd_file.c,v 1.32 2010/03/02 21:14:43 pooka Exp $ */ 2 3/* 4 * Copyright (c) 1995 Frank van der Linden 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed for the NetBSD Project 18 * by Frank van der Linden 19 * 4. The name of the author may not be used to endorse or promote products 20 * derived from this software without specific prior written permission 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * 33 * from: linux_file.c,v 1.3 1995/04/04 04:21:30 mycroft Exp 34 */ 35 36#include <sys/cdefs.h> 37__KERNEL_RCSID(0, "$NetBSD: freebsd_file.c,v 1.32 2010/03/02 21:14:43 pooka Exp $"); 38 39#include <sys/param.h> 40#include <sys/systm.h> 41#include <sys/namei.h> 42#include <sys/proc.h> 43#include <sys/file.h> 44#include <sys/stat.h> 45#include <sys/filedesc.h> 46#include <sys/ioctl.h> 47#include <sys/kernel.h> 48#include <sys/mount.h> 49#include <sys/malloc.h> 50 51#include <sys/syscallargs.h> 52 53#include <compat/freebsd/freebsd_syscallargs.h> 54#include <compat/common/compat_util.h> 55#include <compat/sys/mount.h> 56 57#define ARRAY_LENGTH(array) (sizeof(array)/sizeof(array[0])) 58 59static const char * convert_from_freebsd_mount_type(int); 60 61static const char * 62convert_from_freebsd_mount_type(int type) 63{ 64 static const char * const netbsd_mount_type[] = { 65 NULL, /* 0 = MOUNT_NONE */ 66 "ffs", /* 1 = "Fast" Filesystem */ 67 "nfs", /* 2 = Network Filesystem */ 68 "mfs", /* 3 = Memory Filesystem */ 69 "msdos", /* 4 = MSDOS Filesystem */ 70 "lfs", /* 5 = Log-based Filesystem */ 71 "lofs", /* 6 = Loopback filesystem */ 72 "fdesc", /* 7 = File Descriptor Filesystem */ 73 "portal", /* 8 = Portal Filesystem */ 74 "null", /* 9 = Minimal Filesystem Layer */ 75 "umap", /* 10 = User/Group Identifier Remapping Filesystem */ 76 "kernfs", /* 11 = Kernel Information Filesystem */ 77 "procfs", /* 12 = /proc Filesystem */ 78 "afs", /* 13 = Andrew Filesystem */ 79 "cd9660", /* 14 = ISO9660 (aka CDROM) Filesystem */ 80 "union", /* 15 = Union (translucent) Filesystem */ 81 NULL, /* 16 = "devfs" - existing device Filesystem */ 82#if 0 /* These filesystems don't exist in FreeBSD */ 83 "adosfs", /* ?? = AmigaDOS Filesystem */ 84#endif 85 }; 86 87 if (type < 0 || type >= ARRAY_LENGTH(netbsd_mount_type)) 88 return (NULL); 89 return (netbsd_mount_type[type]); 90} 91 92int 93freebsd_sys_mount(struct lwp *l, const struct freebsd_sys_mount_args *uap, register_t *retval) 94{ 95 /* { 96 syscallarg(int) type; 97 syscallarg(char *) path; 98 syscallarg(int) flags; 99 syscallarg(void *) data; 100 } */ 101 const char *type; 102 struct vfsops *vfsops; 103 register_t dummy; 104 105 if ((type = convert_from_freebsd_mount_type(SCARG(uap, type))) == NULL) 106 return ENODEV; 107 vfsops = vfs_getopsbyname(type); 108 if (vfsops == NULL) 109 return ENODEV; 110 111 return do_sys_mount(l, vfsops, NULL, SCARG(uap, path), 112 SCARG(uap, flags), SCARG(uap, data), UIO_USERSPACE, 0, &dummy); 113} 114 115/* XXX - UNIX domain: int freebsd_sys_bind(int s, void *name, int namelen); */ 116/* XXX - UNIX domain: int freebsd_sys_connect(int s, void *name, int namelen); */ 117