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