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