1 1.39 gutterid /* $NetBSD: vndvar.h,v 1.39 2025/02/13 01:33:21 gutteridge Exp $ */ 2 1.1 thorpej 3 1.13 perry /*- 4 1.4 thorpej * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. 5 1.1 thorpej * All rights reserved. 6 1.1 thorpej * 7 1.1 thorpej * This code is derived from software contributed to The NetBSD Foundation 8 1.1 thorpej * by Jason R. Thorpe. 9 1.1 thorpej * 10 1.1 thorpej * Redistribution and use in source and binary forms, with or without 11 1.1 thorpej * modification, are permitted provided that the following conditions 12 1.1 thorpej * are met: 13 1.1 thorpej * 1. Redistributions of source code must retain the above copyright 14 1.1 thorpej * notice, this list of conditions and the following disclaimer. 15 1.1 thorpej * 2. Redistributions in binary form must reproduce the above copyright 16 1.1 thorpej * notice, this list of conditions and the following disclaimer in the 17 1.1 thorpej * documentation and/or other materials provided with the distribution. 18 1.13 perry * 19 1.1 thorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 1.1 thorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 1.1 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 1.2 jtc * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 1.2 jtc * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 1.1 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 1.1 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 1.1 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 1.1 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 1.1 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 1.1 thorpej * POSSIBILITY OF SUCH DAMAGE. 30 1.1 thorpej */ 31 1.1 thorpej 32 1.1 thorpej /* 33 1.30 rmind * Copyright (c) 1988 University of Utah. 34 1.1 thorpej * Copyright (c) 1990, 1993 35 1.1 thorpej * The Regents of the University of California. All rights reserved. 36 1.12 agc * 37 1.12 agc * This code is derived from software contributed to Berkeley by 38 1.12 agc * the Systems Programming Group of the University of Utah Computer 39 1.12 agc * Science Department. 40 1.12 agc * 41 1.12 agc * Redistribution and use in source and binary forms, with or without 42 1.12 agc * modification, are permitted provided that the following conditions 43 1.12 agc * are met: 44 1.12 agc * 1. Redistributions of source code must retain the above copyright 45 1.12 agc * notice, this list of conditions and the following disclaimer. 46 1.12 agc * 2. Redistributions in binary form must reproduce the above copyright 47 1.12 agc * notice, this list of conditions and the following disclaimer in the 48 1.12 agc * documentation and/or other materials provided with the distribution. 49 1.12 agc * 3. Neither the name of the University nor the names of its contributors 50 1.12 agc * may be used to endorse or promote products derived from this software 51 1.12 agc * without specific prior written permission. 52 1.12 agc * 53 1.12 agc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 54 1.12 agc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 55 1.12 agc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 56 1.12 agc * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 57 1.12 agc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 58 1.12 agc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 59 1.12 agc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 60 1.12 agc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 61 1.12 agc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 62 1.12 agc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 63 1.12 agc * SUCH DAMAGE. 64 1.12 agc * 65 1.12 agc * from: Utah $Hdr: fdioctl.h 1.1 90/07/09$ 66 1.12 agc * 67 1.12 agc * @(#)vnioctl.h 8.1 (Berkeley) 6/10/93 68 1.12 agc */ 69 1.12 agc 70 1.26 uebayasi #ifndef _SYS_DEV_VNDVAR_H_ 71 1.26 uebayasi #define _SYS_DEV_VNDVAR_H_ 72 1.26 uebayasi 73 1.35 dholland #include <sys/ioccom.h> 74 1.4 thorpej #include <sys/pool.h> 75 1.4 thorpej 76 1.1 thorpej /* 77 1.1 thorpej * Vnode disk pseudo-geometry information. 78 1.1 thorpej */ 79 1.1 thorpej struct vndgeom { 80 1.1 thorpej u_int32_t vng_secsize; /* # bytes per sector */ 81 1.1 thorpej u_int32_t vng_nsectors; /* # data sectors per track */ 82 1.1 thorpej u_int32_t vng_ntracks; /* # tracks per cylinder */ 83 1.1 thorpej u_int32_t vng_ncylinders; /* # cylinders per unit */ 84 1.1 thorpej }; 85 1.1 thorpej 86 1.1 thorpej /* 87 1.1 thorpej * Ioctl definitions for file (vnode) disk pseudo-device. 88 1.1 thorpej */ 89 1.1 thorpej struct vnd_ioctl { 90 1.1 thorpej char *vnd_file; /* pathname of file to mount */ 91 1.1 thorpej int vnd_flags; /* flags; see below */ 92 1.1 thorpej struct vndgeom vnd_geom; /* geometry to emulate */ 93 1.25 dsl unsigned int vnd_osize; /* (returned) size of disk */ 94 1.25 dsl uint64_t vnd_size; /* (returned) size of disk */ 95 1.1 thorpej }; 96 1.1 thorpej 97 1.1 thorpej /* vnd_flags */ 98 1.1 thorpej #define VNDIOF_HASGEOM 0x01 /* use specified geometry */ 99 1.9 yamt #define VNDIOF_READONLY 0x02 /* as read-only device */ 100 1.10 drochner #define VNDIOF_FORCE 0x04 /* force close */ 101 1.38 mlelstv #define VNDIOF_FILEIO 0x08 /* have to use read/write */ 102 1.38 mlelstv #define VNDIOF_COMP 0x0400 /* must stay the same as VNF_COMP */ 103 1.1 thorpej 104 1.6 jdolecek #ifdef _KERNEL 105 1.6 jdolecek 106 1.1 thorpej struct vnode; 107 1.1 thorpej 108 1.1 thorpej /* 109 1.1 thorpej * A vnode disk's state information. 110 1.1 thorpej */ 111 1.1 thorpej struct vnd_softc { 112 1.34 prlw1 device_t sc_dev; 113 1.1 thorpej int sc_flags; /* flags */ 114 1.33 christos uint64_t sc_size; /* size of vnd */ 115 1.1 thorpej struct vnode *sc_vp; /* vnode */ 116 1.37 mlelstv u_int sc_iosize; /* smallest I/O size for backend */ 117 1.20 elad kauth_cred_t sc_cred; /* credentials */ 118 1.1 thorpej int sc_maxactive; /* max # of active requests */ 119 1.17 yamt struct bufq_state *sc_tab; /* transfer queue */ 120 1.32 hannken int sc_pending; /* number of pending transfers */ 121 1.5 thorpej int sc_active; /* number of active transfers */ 122 1.1 thorpej struct disk sc_dkdev; /* generic disk device info */ 123 1.1 thorpej struct vndgeom sc_geom; /* virtual geometry */ 124 1.4 thorpej struct pool sc_vxpool; /* vndxfer pool */ 125 1.4 thorpej struct pool sc_vbpool; /* vndbuf pool */ 126 1.21 ad struct lwp *sc_kthread; /* kernel thread */ 127 1.15 hubertf u_int32_t sc_comp_blksz; /* precompressed block size */ 128 1.15 hubertf u_int32_t sc_comp_numoffs;/* count of compressed block offsets */ 129 1.15 hubertf u_int64_t *sc_comp_offsets;/* file idx's to compressed blocks */ 130 1.15 hubertf unsigned char *sc_comp_buff; /* compressed data buffer */ 131 1.15 hubertf unsigned char *sc_comp_decombuf;/* decompressed data buffer */ 132 1.15 hubertf int32_t sc_comp_buffblk;/*current decompressed block */ 133 1.15 hubertf z_stream sc_comp_stream;/* decompress descriptor */ 134 1.1 thorpej }; 135 1.6 jdolecek #endif 136 1.1 thorpej 137 1.1 thorpej /* sc_flags */ 138 1.11 thorpej #define VNF_INITED 0x001 /* unit has been initialized */ 139 1.11 thorpej #define VNF_WLABEL 0x002 /* label area is writable */ 140 1.11 thorpej #define VNF_LABELLING 0x004 /* unit is currently being labelled */ 141 1.11 thorpej #define VNF_WANTED 0x008 /* someone is waiting to obtain a lock */ 142 1.11 thorpej #define VNF_LOCKED 0x010 /* unit is locked */ 143 1.14 bouyer #define VNF_READONLY 0x020 /* unit is read-only */ 144 1.14 bouyer #define VNF_KLABEL 0x040 /* keep label on close */ 145 1.14 bouyer #define VNF_VLABEL 0x080 /* label is valid */ 146 1.14 bouyer #define VNF_KTHREAD 0x100 /* thread is running */ 147 1.14 bouyer #define VNF_VUNCONF 0x200 /* device is unconfiguring */ 148 1.15 hubertf #define VNF_COMP 0x400 /* file is compressed */ 149 1.24 dyoung #define VNF_CLEARING 0x800 /* unit is being torn down */ 150 1.31 hannken #define VNF_USE_VN_RDWR 0x1000 /* have to use vn_rdwr() */ 151 1.15 hubertf 152 1.15 hubertf /* structure of header in a compressed file */ 153 1.36 riastrad struct vnd_comp_header { 154 1.15 hubertf char preamble[128]; 155 1.15 hubertf u_int32_t block_size; 156 1.15 hubertf u_int32_t num_blocks; 157 1.15 hubertf }; 158 1.1 thorpej 159 1.1 thorpej /* 160 1.7 atatat * A simple structure for describing which vnd units are in use. 161 1.7 atatat */ 162 1.16 christos 163 1.7 atatat struct vnd_user { 164 1.7 atatat int vnu_unit; /* which vnd unit */ 165 1.7 atatat dev_t vnu_dev; /* file is on this device... */ 166 1.7 atatat ino_t vnu_ino; /* ...at this inode */ 167 1.7 atatat }; 168 1.7 atatat 169 1.7 atatat /* 170 1.1 thorpej * Before you can use a unit, it must be configured with VNDIOCSET. 171 1.1 thorpej * The configuration persists across opens and closes of the device; 172 1.39 gutterid * a VNDIOCCLR must be used to reset a configuration. An attempt to 173 1.1 thorpej * VNDIOCSET an already active unit will return EBUSY. 174 1.1 thorpej */ 175 1.1 thorpej #define VNDIOCSET _IOWR('F', 0, struct vnd_ioctl) /* enable disk */ 176 1.1 thorpej #define VNDIOCCLR _IOW('F', 1, struct vnd_ioctl) /* disable disk */ 177 1.16 christos #define VNDIOCGET _IOWR('F', 3, struct vnd_user) /* get list */ 178 1.25 dsl 179 1.29 mrg #ifdef _KERNEL 180 1.29 mrg /* 181 1.29 mrg * Everything else is kernel-private, mostly exported for compat/netbsd32. 182 1.29 mrg * 183 1.29 mrg * NetBSD 3.0 had a 32-bit value for vnu_ino. 184 1.29 mrg * 185 1.29 mrg * NetBSD 5.0 had a 32-bit value for vnu_dev, and vnd_size. 186 1.29 mrg */ 187 1.29 mrg struct vnd_user30 { 188 1.29 mrg int vnu_unit; /* which vnd unit */ 189 1.29 mrg uint32_t vnu_dev; /* file is on this device... */ 190 1.29 mrg uint32_t vnu_ino; /* ...at this inode */ 191 1.29 mrg }; 192 1.29 mrg #define VNDIOCGET30 _IOWR('F', 2, struct vnd_user30) /* get list */ 193 1.29 mrg 194 1.29 mrg struct vnd_user50 { 195 1.29 mrg int vnu_unit; /* which vnd unit */ 196 1.29 mrg uint32_t vnu_dev; /* file is on this device... */ 197 1.29 mrg ino_t vnu_ino; /* ...at this inode */ 198 1.29 mrg }; 199 1.29 mrg #define VNDIOCGET50 _IOWR('F', 3, struct vnd_user50) /* get list */ 200 1.29 mrg 201 1.29 mrg struct vnd_ioctl50 { 202 1.29 mrg char *vnd_file; /* pathname of file to mount */ 203 1.29 mrg int vnd_flags; /* flags; see below */ 204 1.29 mrg struct vndgeom vnd_geom; /* geometry to emulate */ 205 1.29 mrg unsigned int vnd_size; /* (returned) size of disk */ 206 1.29 mrg }; 207 1.29 mrg #define VNDIOCSET50 _IOWR('F', 0, struct vnd_ioctl50) 208 1.29 mrg #define VNDIOCCLR50 _IOW('F', 1, struct vnd_ioctl50) 209 1.29 mrg 210 1.29 mrg #endif /* _KERNEL */ 211 1.29 mrg 212 1.26 uebayasi #endif /* _SYS_DEV_VNDVAR_H_ */ 213