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