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