freebsd_file.c revision 1.27
1/* $NetBSD: freebsd_file.c,v 1.27 2007/07/13 20:48:39 dsl 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.27 2007/07/13 20:48:39 dsl Exp $"); 38 39#if defined(_KERNEL_OPT) 40#include "fs_nfs.h" 41#endif 42 43#include <sys/param.h> 44#include <sys/systm.h> 45#include <sys/namei.h> 46#include <sys/proc.h> 47#include <sys/file.h> 48#include <sys/stat.h> 49#include <sys/filedesc.h> 50#include <sys/ioctl.h> 51#include <sys/kernel.h> 52#include <sys/mount.h> 53#include <sys/malloc.h> 54 55#include <sys/syscallargs.h> 56 57#include <compat/freebsd/freebsd_syscallargs.h> 58#include <compat/common/compat_util.h> 59 60#define ARRAY_LENGTH(array) (sizeof(array)/sizeof(array[0])) 61 62static const char * convert_from_freebsd_mount_type __P((int)); 63 64static const char * 65convert_from_freebsd_mount_type(type) 66 int type; 67{ 68 static const char * const netbsd_mount_type[] = { 69 NULL, /* 0 = MOUNT_NONE */ 70 "ffs", /* 1 = "Fast" Filesystem */ 71 "nfs", /* 2 = Network Filesystem */ 72 "mfs", /* 3 = Memory Filesystem */ 73 "msdos", /* 4 = MSDOS Filesystem */ 74 "lfs", /* 5 = Log-based Filesystem */ 75 "lofs", /* 6 = Loopback filesystem */ 76 "fdesc", /* 7 = File Descriptor Filesystem */ 77 "portal", /* 8 = Portal Filesystem */ 78 "null", /* 9 = Minimal Filesystem Layer */ 79 "umap", /* 10 = User/Group Identifier Remapping Filesystem */ 80 "kernfs", /* 11 = Kernel Information Filesystem */ 81 "procfs", /* 12 = /proc Filesystem */ 82 "afs", /* 13 = Andrew Filesystem */ 83 "cd9660", /* 14 = ISO9660 (aka CDROM) Filesystem */ 84 "union", /* 15 = Union (translucent) Filesystem */ 85 NULL, /* 16 = "devfs" - existing device Filesystem */ 86#if 0 /* These filesystems don't exist in FreeBSD */ 87 "adosfs", /* ?? = AmigaDOS Filesystem */ 88#endif 89 }; 90 91 if (type < 0 || type >= ARRAY_LENGTH(netbsd_mount_type)) 92 return (NULL); 93 return (netbsd_mount_type[type]); 94} 95 96int 97freebsd_sys_mount(l, v, retval) 98 struct lwp *l; 99 void *v; 100 register_t *retval; 101{ 102 struct freebsd_sys_mount_args /* { 103 syscallarg(int) type; 104 syscallarg(char *) path; 105 syscallarg(int) flags; 106 syscallarg(void *) data; 107 } */ *uap = v; 108 const char *type; 109 struct vfsops *vfsops; 110 register_t dummy; 111 112 if ((type = convert_from_freebsd_mount_type(SCARG(uap, type))) == NULL) 113 return ENODEV; 114 vfsops = vfs_getopsbyname(type); 115 if (vfsops == NULL) 116 return ENODEV; 117 118 return do_sys_mount(l, vfsops, NULL, SCARG(uap, path), 119 SCARG(uap, flags), SCARG(uap, data), UIO_USERSPACE, 0, &dummy); 120} 121 122/* XXX - UNIX domain: int freebsd_sys_bind(int s, void *name, int namelen); */ 123/* XXX - UNIX domain: int freebsd_sys_connect(int s, void *name, int namelen); */ 124