Home | History | Annotate | Line # | Download | only in dev
vndvar.h revision 1.9
      1 /*	$NetBSD: vndvar.h,v 1.9 2003/03/27 15:34:36 yamt 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) 1988 University of Utah.
     41  * Copyright (c) 1990, 1993
     42  *	The Regents of the University of California.  All rights reserved.
     43  *
     44  * This code is derived from software contributed to Berkeley by
     45  * the Systems Programming Group of the University of Utah Computer
     46  * Science Department.
     47  *
     48  * Redistribution and use in source and binary forms, with or without
     49  * modification, are permitted provided that the following conditions
     50  * are met:
     51  * 1. Redistributions of source code must retain the above copyright
     52  *    notice, this list of conditions and the following disclaimer.
     53  * 2. Redistributions in binary form must reproduce the above copyright
     54  *    notice, this list of conditions and the following disclaimer in the
     55  *    documentation and/or other materials provided with the distribution.
     56  * 3. All advertising materials mentioning features or use of this software
     57  *    must display the following acknowledgement:
     58  *	This product includes software developed by the University of
     59  *	California, Berkeley and its contributors.
     60  * 4. Neither the name of the University nor the names of its contributors
     61  *    may be used to endorse or promote products derived from this software
     62  *    without specific prior written permission.
     63  *
     64  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     65  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     66  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     67  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     68  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     69  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     70  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     71  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     72  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     73  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     74  * SUCH DAMAGE.
     75  *
     76  * from: Utah $Hdr: fdioctl.h 1.1 90/07/09$
     77  *
     78  *	@(#)vnioctl.h	8.1 (Berkeley) 6/10/93
     79  */
     80 
     81 #include <sys/pool.h>
     82 
     83 /*
     84  * Vnode disk pseudo-geometry information.
     85  */
     86 struct vndgeom {
     87 	u_int32_t	vng_secsize;	/* # bytes per sector */
     88 	u_int32_t	vng_nsectors;	/* # data sectors per track */
     89 	u_int32_t	vng_ntracks;	/* # tracks per cylinder */
     90 	u_int32_t	vng_ncylinders;	/* # cylinders per unit */
     91 };
     92 
     93 /*
     94  * Ioctl definitions for file (vnode) disk pseudo-device.
     95  */
     96 struct vnd_ioctl {
     97 	char		*vnd_file;	/* pathname of file to mount */
     98 	int		vnd_flags;	/* flags; see below */
     99 	struct vndgeom	vnd_geom;	/* geometry to emulate */
    100 	int		vnd_size;	/* (returned) size of disk */
    101 };
    102 
    103 /* vnd_flags */
    104 #define	VNDIOF_HASGEOM	0x01		/* use specified geometry */
    105 #define	VNDIOF_READONLY	0x02		/* as read-only device */
    106 
    107 #ifdef _KERNEL
    108 
    109 struct vnode;
    110 struct ucred;
    111 
    112 /*
    113  * A vnode disk's state information.
    114  */
    115 struct vnd_softc {
    116 	int		 sc_unit;	/* logical unit number */
    117 	int		 sc_flags;	/* flags */
    118 	size_t		 sc_size;	/* size of vnd */
    119 	struct vnode	*sc_vp;		/* vnode */
    120 	struct ucred	*sc_cred;	/* credentials */
    121 	int		 sc_maxactive;	/* max # of active requests */
    122 	struct bufq_state sc_tab;	/* transfer queue */
    123 	int		 sc_active;	/* number of active transfers */
    124 	char		 sc_xname[8];	/* XXX external name */
    125 	struct disk	 sc_dkdev;	/* generic disk device info */
    126 	struct vndgeom	 sc_geom;	/* virtual geometry */
    127 	struct pool	 sc_vxpool;	/* vndxfer pool */
    128 	struct pool	 sc_vbpool;	/* vndbuf pool */
    129 };
    130 #endif
    131 
    132 /* sc_flags */
    133 #define	VNF_INITED	0x01	/* unit has been initialized */
    134 #define	VNF_WLABEL	0x02	/* label area is writable */
    135 #define	VNF_LABELLING	0x04	/* unit is currently being labelled */
    136 #define	VNF_WANTED	0x08	/* someone is waiting to obtain a lock */
    137 #define	VNF_LOCKED	0x10	/* unit is locked */
    138 #define	VNF_BUSY	0x20	/* unit is busy */
    139 #define	VNF_READONLY	0x40	/* unit is read-only */
    140 
    141 /*
    142  * A simple structure for describing which vnd units are in use.
    143  */
    144 struct vnd_user {
    145 	int		vnu_unit;	/* which vnd unit */
    146 	dev_t		vnu_dev;	/* file is on this device... */
    147 	ino_t		vnu_ino;	/* ...at this inode */
    148 };
    149 
    150 /*
    151  * Before you can use a unit, it must be configured with VNDIOCSET.
    152  * The configuration persists across opens and closes of the device;
    153  * an VNDIOCCLR must be used to reset a configuration.  An attempt to
    154  * VNDIOCSET an already active unit will return EBUSY.
    155  */
    156 #define VNDIOCSET	_IOWR('F', 0, struct vnd_ioctl)	/* enable disk */
    157 #define VNDIOCCLR	_IOW('F', 1, struct vnd_ioctl)	/* disable disk */
    158 #define VNDIOCGET	_IOWR('F', 2, struct vnd_user)	/* get list */
    159