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