vndvar.h revision 1.11
1/*	$NetBSD: vndvar.h,v 1.11 2003/05/17 16:11:52 thorpej 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 */
86struct 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 */
96struct 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#define	VNDIOF_FORCE	0x04		/* force close */
107
108#ifdef _KERNEL
109
110struct vnode;
111struct ucred;
112
113/*
114 * A vnode disk's state information.
115 */
116struct vnd_softc {
117	int		 sc_unit;	/* logical unit number */
118	int		 sc_flags;	/* flags */
119	size_t		 sc_size;	/* size of vnd */
120	struct vnode	*sc_vp;		/* vnode */
121	struct ucred	*sc_cred;	/* credentials */
122	int		 sc_maxactive;	/* max # of active requests */
123	struct bufq_state sc_tab;	/* transfer queue */
124	int		 sc_active;	/* number of active transfers */
125	char		 sc_xname[8];	/* XXX external name */
126	struct disk	 sc_dkdev;	/* generic disk device info */
127	struct vndgeom	 sc_geom;	/* virtual geometry */
128	struct pool	 sc_vxpool;	/* vndxfer pool */
129	struct pool	 sc_vbpool;	/* vndbuf pool */
130};
131#endif
132
133/* sc_flags */
134#define	VNF_INITED	0x001	/* unit has been initialized */
135#define	VNF_WLABEL	0x002	/* label area is writable */
136#define	VNF_LABELLING	0x004	/* unit is currently being labelled */
137#define	VNF_WANTED	0x008	/* someone is waiting to obtain a lock */
138#define	VNF_LOCKED	0x010	/* unit is locked */
139#define	VNF_BUSY	0x020	/* unit is busy */
140#define	VNF_READONLY	0x040	/* unit is read-only */
141#define	VNF_KLABEL	0x080	/* keep label on close */
142#define	VNF_VLABEL	0x100	/* label is valid */
143
144/*
145 * A simple structure for describing which vnd units are in use.
146 */
147struct vnd_user {
148	int		vnu_unit;	/* which vnd unit */
149	dev_t		vnu_dev;	/* file is on this device... */
150	ino_t		vnu_ino;	/* ...at this inode */
151};
152
153/*
154 * Before you can use a unit, it must be configured with VNDIOCSET.
155 * The configuration persists across opens and closes of the device;
156 * an VNDIOCCLR must be used to reset a configuration.  An attempt to
157 * VNDIOCSET an already active unit will return EBUSY.
158 */
159#define VNDIOCSET	_IOWR('F', 0, struct vnd_ioctl)	/* enable disk */
160#define VNDIOCCLR	_IOW('F', 1, struct vnd_ioctl)	/* disable disk */
161#define VNDIOCGET	_IOWR('F', 2, struct vnd_user)	/* get list */
162