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