1 /* $NetBSD: freebsd_file.c,v 1.30 2007/12/08 18:35:58 dsl Exp $ */
4 * Copyright (c) 1995 Frank van der Linden
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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
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.
33 * from: linux_file.c,v 1.3 1995/04/04 04:21:30 mycroft Exp
36 #include <sys/cdefs.h>
37 __KERNEL_RCSID(0, "$NetBSD: freebsd_file.c,v 1.30 2007/12/08 18:35:58 dsl Exp $");
39 #if defined(_KERNEL_OPT)
43 #include <sys/param.h>
44 #include <sys/systm.h>
45 #include <sys/namei.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>
55 #include <sys/syscallargs.h>
57 #include <compat/freebsd/freebsd_syscallargs.h>
58 #include <compat/common/compat_util.h>
59 #include <compat/sys/mount.h>
61 #define ARRAY_LENGTH(array) (sizeof(array)/sizeof(array[0]))
63 static const char * convert_from_freebsd_mount_type(int);
66 convert_from_freebsd_mount_type(int type
)
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 */
91 if (type
< 0 || type
>= ARRAY_LENGTH(netbsd_mount_type
))
93 return (netbsd_mount_type
[type
]);
97 freebsd_sys_mount(struct lwp
*l
, const struct freebsd_sys_mount_args
*uap
, register_t
*retval
)
100 syscallarg(int) type;
101 syscallarg(char *) path;
102 syscallarg(int) flags;
103 syscallarg(void *) data;
106 struct vfsops
*vfsops
;
109 if ((type
= convert_from_freebsd_mount_type(SCARG(uap
, type
))) == NULL
)
111 vfsops
= vfs_getopsbyname(type
);
115 return do_sys_mount(l
, vfsops
, NULL
, SCARG(uap
, path
),
116 SCARG(uap
, flags
), SCARG(uap
, data
), UIO_USERSPACE
, 0, &dummy
);
119 /* XXX - UNIX domain: int freebsd_sys_bind(int s, void *name, int namelen); */
120 /* XXX - UNIX domain: int freebsd_sys_connect(int s, void *name, int namelen); */