freebsd_file.c revision 1.28 1 1.28 christos /* $NetBSD: freebsd_file.c,v 1.28 2007/07/17 20:33:17 christos 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 christos __KERNEL_RCSID(0, "$NetBSD: freebsd_file.c,v 1.28 2007/07/17 20:33:17 christos 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.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.24 christos syscallarg(void *) data;
108 1.1 mycroft } */ *uap = v;
109 1.12 jdolecek const char *type;
110 1.26 dsl struct vfsops *vfsops;
111 1.26 dsl register_t dummy;
112 1.1 mycroft
113 1.1 mycroft if ((type = convert_from_freebsd_mount_type(SCARG(uap, type))) == NULL)
114 1.1 mycroft return ENODEV;
115 1.26 dsl vfsops = vfs_getopsbyname(type);
116 1.26 dsl if (vfsops == NULL)
117 1.26 dsl return ENODEV;
118 1.26 dsl
119 1.26 dsl return do_sys_mount(l, vfsops, NULL, SCARG(uap, path),
120 1.26 dsl SCARG(uap, flags), SCARG(uap, data), UIO_USERSPACE, 0, &dummy);
121 1.1 mycroft }
122 1.1 mycroft
123 1.24 christos /* XXX - UNIX domain: int freebsd_sys_bind(int s, void *name, int namelen); */
124 1.24 christos /* XXX - UNIX domain: int freebsd_sys_connect(int s, void *name, int namelen); */
125