vnd_50.c revision 1.4.4.2 1 1.4.4.2 christos /* $NetBSD: vnd_50.c,v 1.4.4.2 2019/06/10 22:06:58 christos Exp $ */
2 1.4.4.2 christos
3 1.4.4.2 christos /*-
4 1.4.4.2 christos * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc.
5 1.4.4.2 christos * All rights reserved.
6 1.4.4.2 christos *
7 1.4.4.2 christos * This code is derived from software contributed to The NetBSD Foundation
8 1.4.4.2 christos * by Jason R. Thorpe.
9 1.4.4.2 christos *
10 1.4.4.2 christos * Redistribution and use in source and binary forms, with or without
11 1.4.4.2 christos * modification, are permitted provided that the following conditions
12 1.4.4.2 christos * are met:
13 1.4.4.2 christos * 1. Redistributions of source code must retain the above copyright
14 1.4.4.2 christos * notice, this list of conditions and the following disclaimer.
15 1.4.4.2 christos * 2. Redistributions in binary form must reproduce the above copyright
16 1.4.4.2 christos * notice, this list of conditions and the following disclaimer in the
17 1.4.4.2 christos * documentation and/or other materials provided with the distribution.
18 1.4.4.2 christos *
19 1.4.4.2 christos * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.4.4.2 christos * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.4.4.2 christos * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.4.4.2 christos * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.4.4.2 christos * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.4.4.2 christos * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.4.4.2 christos * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.4.4.2 christos * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.4.4.2 christos * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.4.4.2 christos * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.4.4.2 christos * POSSIBILITY OF SUCH DAMAGE.
30 1.4.4.2 christos */
31 1.4.4.2 christos
32 1.4.4.2 christos /*
33 1.4.4.2 christos * Copyright (c) 1988 University of Utah.
34 1.4.4.2 christos * Copyright (c) 1990, 1993
35 1.4.4.2 christos * The Regents of the University of California. All rights reserved.
36 1.4.4.2 christos *
37 1.4.4.2 christos * This code is derived from software contributed to Berkeley by
38 1.4.4.2 christos * the Systems Programming Group of the University of Utah Computer
39 1.4.4.2 christos * Science Department.
40 1.4.4.2 christos *
41 1.4.4.2 christos * Redistribution and use in source and binary forms, with or without
42 1.4.4.2 christos * modification, are permitted provided that the following conditions
43 1.4.4.2 christos * are met:
44 1.4.4.2 christos * 1. Redistributions of source code must retain the above copyright
45 1.4.4.2 christos * notice, this list of conditions and the following disclaimer.
46 1.4.4.2 christos * 2. Redistributions in binary form must reproduce the above copyright
47 1.4.4.2 christos * notice, this list of conditions and the following disclaimer in the
48 1.4.4.2 christos * documentation and/or other materials provided with the distribution.
49 1.4.4.2 christos * 3. Neither the name of the University nor the names of its contributors
50 1.4.4.2 christos * may be used to endorse or promote products derived from this software
51 1.4.4.2 christos * without specific prior written permission.
52 1.4.4.2 christos *
53 1.4.4.2 christos * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
54 1.4.4.2 christos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55 1.4.4.2 christos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
56 1.4.4.2 christos * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
57 1.4.4.2 christos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58 1.4.4.2 christos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59 1.4.4.2 christos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60 1.4.4.2 christos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61 1.4.4.2 christos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62 1.4.4.2 christos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63 1.4.4.2 christos * SUCH DAMAGE.
64 1.4.4.2 christos *
65 1.4.4.2 christos * from: Utah $Hdr: vn.c 1.13 94/04/02$
66 1.4.4.2 christos *
67 1.4.4.2 christos * @(#)vn.c 8.9 (Berkeley) 5/14/95
68 1.4.4.2 christos */
69 1.4.4.2 christos
70 1.4.4.2 christos #include <sys/cdefs.h>
71 1.4.4.2 christos __KERNEL_RCSID(0, "$NetBSD: vnd_50.c,v 1.4.4.2 2019/06/10 22:06:58 christos Exp $");
72 1.4.4.2 christos
73 1.4.4.2 christos #if defined(_KERNEL_OPT)
74 1.4.4.2 christos #include "opt_compat_netbsd.h"
75 1.4.4.2 christos #endif
76 1.4.4.2 christos
77 1.4.4.2 christos #include <sys/param.h>
78 1.4.4.2 christos #include <sys/systm.h>
79 1.4.4.2 christos #include <sys/proc.h>
80 1.4.4.2 christos #include <sys/errno.h>
81 1.4.4.2 christos #include <sys/malloc.h>
82 1.4.4.2 christos #include <sys/ioctl.h>
83 1.4.4.2 christos #include <sys/device.h>
84 1.4.4.2 christos #include <sys/disk.h>
85 1.4.4.2 christos #include <sys/stat.h>
86 1.4.4.2 christos #include <sys/vnode.h>
87 1.4.4.2 christos #include <sys/file.h>
88 1.4.4.2 christos #include <sys/uio.h>
89 1.4.4.2 christos #include <sys/conf.h>
90 1.4.4.2 christos #include <sys/compat_stub.h>
91 1.4.4.2 christos
92 1.4.4.2 christos #include <net/zlib.h>
93 1.4.4.2 christos
94 1.4.4.2 christos #include <dev/vndvar.h>
95 1.4.4.2 christos
96 1.4.4.2 christos #include <compat/common/compat_mod.h>
97 1.4.4.2 christos
98 1.4.4.2 christos static int compat_50_vndioctl(u_long, struct lwp *, void *, int, struct vattr *,
99 1.4.4.2 christos int (*)(struct lwp *, void *, int, struct vattr *));
100 1.4.4.2 christos
101 1.4.4.2 christos static int
102 1.4.4.2 christos compat_50_vndioctl(u_long cmd, struct lwp *l, void *data, int unit,
103 1.4.4.2 christos struct vattr *vattr_p,
104 1.4.4.2 christos int (*get)(struct lwp *, void *, int, struct vattr *))
105 1.4.4.2 christos {
106 1.4.4.2 christos struct vnd_user50 *vnu = data;
107 1.4.4.2 christos int error;
108 1.4.4.2 christos
109 1.4.4.2 christos if (cmd != VNDIOCGET50)
110 1.4.4.2 christos return EPASSTHROUGH;
111 1.4.4.2 christos
112 1.4.4.2 christos error = (*get)(l, data, unit, vattr_p);
113 1.4.4.2 christos if (error != 0)
114 1.4.4.2 christos return error;
115 1.4.4.2 christos
116 1.4.4.2 christos vnu->vnu_dev = vattr_p->va_fsid;
117 1.4.4.2 christos vnu->vnu_ino = vattr_p->va_fileid;
118 1.4.4.2 christos return 0;
119 1.4.4.2 christos }
120 1.4.4.2 christos
121 1.4.4.2 christos void
122 1.4.4.2 christos vnd_50_init(void)
123 1.4.4.2 christos {
124 1.4.4.2 christos
125 1.4.4.2 christos MODULE_HOOK_SET(compat_vndioctl_50_hook, "vnd_50", compat_50_vndioctl);
126 1.4.4.2 christos }
127 1.4.4.2 christos
128 1.4.4.2 christos void
129 1.4.4.2 christos vnd_50_fini(void)
130 1.4.4.2 christos {
131 1.4.4.2 christos
132 1.4.4.2 christos MODULE_HOOK_UNSET(compat_vndioctl_50_hook);
133 1.4.4.2 christos }
134