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