Home | History | Annotate | Line # | Download | only in dev
vndvar.h revision 1.20
      1 /*	$NetBSD: vndvar.h,v 1.20 2006/05/14 21:42:26 elad 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  */
    121 struct 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  */
    131 struct 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 
    145 struct vnode;
    146 
    147 /*
    148  * A vnode disk's state information.
    149  */
    150 struct vnd_softc {
    151 	struct device    sc_dev;
    152 	int		 sc_flags;	/* flags */
    153 	size_t		 sc_size;	/* size of vnd */
    154 	struct vnode	*sc_vp;		/* vnode */
    155 	kauth_cred_t	 sc_cred;	/* credentials */
    156 	int		 sc_maxactive;	/* max # of active requests */
    157 	struct bufq_state *sc_tab;	/* transfer queue */
    158 	int		 sc_active;	/* number of active transfers */
    159 	struct disk	 sc_dkdev;	/* generic disk device info */
    160 	struct vndgeom	 sc_geom;	/* virtual geometry */
    161 	struct pool	 sc_vxpool;	/* vndxfer pool */
    162 	struct pool	 sc_vbpool;	/* vndbuf pool */
    163 	struct proc 	*sc_kthread;	/* kernel thread */
    164 	u_int32_t	 sc_comp_blksz;	/* precompressed block size */
    165 	u_int32_t	 sc_comp_numoffs;/* count of compressed block offsets */
    166 	u_int64_t	*sc_comp_offsets;/* file idx's to compressed blocks */
    167 	unsigned char	*sc_comp_buff;	/* compressed data buffer */
    168 	unsigned char	*sc_comp_decombuf;/* decompressed data buffer */
    169 	int32_t		 sc_comp_buffblk;/*current decompressed block */
    170 	z_stream	 sc_comp_stream;/* decompress descriptor */
    171 };
    172 #endif
    173 
    174 /* sc_flags */
    175 #define	VNF_INITED	0x001	/* unit has been initialized */
    176 #define	VNF_WLABEL	0x002	/* label area is writable */
    177 #define	VNF_LABELLING	0x004	/* unit is currently being labelled */
    178 #define	VNF_WANTED	0x008	/* someone is waiting to obtain a lock */
    179 #define	VNF_LOCKED	0x010	/* unit is locked */
    180 #define	VNF_READONLY	0x020	/* unit is read-only */
    181 #define	VNF_KLABEL	0x040	/* keep label on close */
    182 #define	VNF_VLABEL	0x080	/* label is valid */
    183 #define	VNF_KTHREAD	0x100	/* thread is running */
    184 #define	VNF_VUNCONF	0x200	/* device is unconfiguring */
    185 #define VNF_COMP	0x400	/* file is compressed */
    186 
    187 /* structure of header in a compressed file */
    188 struct vnd_comp_header
    189 {
    190 	char preamble[128];
    191 	u_int32_t block_size;
    192 	u_int32_t num_blocks;
    193 };
    194 
    195 /*
    196  * A simple structure for describing which vnd units are in use.
    197  */
    198 #ifdef COMPAT_30
    199 struct vnd_ouser {
    200 	int		vnu_unit;	/* which vnd unit */
    201 	dev_t		vnu_dev;	/* file is on this device... */
    202 	uint32_t	vnu_ino;	/* ...at this inode */
    203 };
    204 #define VNDIOOCGET	_IOWR('F', 2, struct vnd_ouser)	/* get list */
    205 #endif
    206 
    207 struct vnd_user {
    208 	int		vnu_unit;	/* which vnd unit */
    209 	dev_t		vnu_dev;	/* file is on this device... */
    210 	ino_t		vnu_ino;	/* ...at this inode */
    211 };
    212 
    213 /*
    214  * Before you can use a unit, it must be configured with VNDIOCSET.
    215  * The configuration persists across opens and closes of the device;
    216  * an VNDIOCCLR must be used to reset a configuration.  An attempt to
    217  * VNDIOCSET an already active unit will return EBUSY.
    218  */
    219 #define VNDIOCSET	_IOWR('F', 0, struct vnd_ioctl)	/* enable disk */
    220 #define VNDIOCCLR	_IOW('F', 1, struct vnd_ioctl)	/* disable disk */
    221 #define VNDIOCGET	_IOWR('F', 3, struct vnd_user)	/* get list */
    222