xref: /dragonfly/sys/sys/vnioctl.h (revision e98bdfd3)
1 /*
2  * Copyright (c) 1988 University of Utah.
3  * Copyright (c) 1990, 1993
4  *	The Regents of the University of California.  All rights reserved.
5  *
6  * This code is derived from software contributed to Berkeley by
7  * the Systems Programming Group of the University of Utah Computer
8  * Science Department.
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. Neither the name of the University nor the names of its contributors
19  *    may be used to endorse or promote products derived from this software
20  *    without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  *
34  * from: Utah $Hdr: fdioctl.h 1.1 90/07/09$
35  *
36  *	@(#)vnioctl.h	8.1 (Berkeley) 6/10/93
37  *
38  * $FreeBSD: src/sys/sys/vnioctl.h,v 1.4 1999/09/17 05:33:58 dillon Exp $
39  */
40 
41 #ifndef _SYS_VNIOCTL_H_
42 #define _SYS_VNIOCTL_H_
43 
44 #ifndef _SYS_IOCCOM_H_
45 #include <sys/ioccom.h>
46 #endif
47 #ifndef _SYS_PARAM_H_
48 #include <sys/param.h>		/* PATH_MAX */
49 #endif
50 
51 /*
52  * Ioctl definitions for file (vnode) disk pseudo-device.
53  */
54 
55 #define _PATH_VNTAB	"/etc/vntab"	/* default config file */
56 
57 struct vn_ioctl {
58 	char	*vn_file;	/* pathname of file to mount */
59 	int64_t	vn_size;	/* (returned) size of disk */
60 };
61 
62 /*
63  * Structure used by userland to query vn devices.
64  *
65  * In file-backed configurations, vnu_file will contain the full path to
66  * the backing file, with vnu_dev and vnu_ino pointing to the appropriate
67  * filesystem entries for that file.
68  *
69  * In swap-backed configurations, vnu_file will contain the token "swap",
70  * with vnu_size and vnu_secsize indicating the portion of virtual memory
71  * in use by the vnode disk.
72  *
73  * Todo: verify vnu_file within a jail - path disclosure problem ?
74  */
75 
76 
77 struct vn_user {
78         int     	vnu_unit;		/* vn unit */
79         char    	vnu_file[PATH_MAX];	/* vn description */
80 #define _VN_USER_SWAP	"swap"			/* indicates swap-backed vn */
81 	union {
82 	        dev_t   	dev;		/* vn device */
83 		u_int64_t	size;		/* size per vnu_secsize */
84 	} data1;
85 	union {
86         	ino_t   	ino;		/* vn inode */
87 		int		secsize;	/* sector size */
88 	} data2;
89 };
90 #define vnu_dev		data1.dev
91 #define vnu_size	data1.size
92 #define vnu_ino		data2.ino
93 #define vnu_secsize	data2.secsize
94 
95 /*
96  * Before you can use a unit, it must be configured with VNIOCSET.
97  * The configuration persists across opens and closes of the device;
98  * an VNIOCCLR must be used to reset a configuration.  An attempt to
99  * VNIOCSET an already active unit will return EBUSY.
100  */
101 #define VNIOCATTACH	_IOWR('F', 0, struct vn_ioctl)	/* attach file */
102 #define VNIOCDETACH	_IOWR('F', 1, struct vn_ioctl)	/* detach disk */
103 #define VNIOCGSET	_IOWR('F', 2, u_long )		/* set global option */
104 #define VNIOCGCLEAR	_IOWR('F', 3, u_long )		/* reset --//-- */
105 #define VNIOCUSET	_IOWR('F', 4, u_long )		/* set unit option */
106 #define VNIOCUCLEAR	_IOWR('F', 5, u_long )		/* reset --//-- */
107 #define VNIOCGET	_IOWR('F', 6, struct vn_user)	/* get disk info */
108 
109 #define VN_FOLLOW	0x2	/* Debug flow in vn driver */
110 #define VN_DEBUG	0x4	/* Debug data in vn driver */
111 #define VN_IO		0x8	/* Debug I/O in vn driver */
112 #define VN_DONTCLUSTER	0x10	/* Don't cluster */
113 #define VN_RESERVE	0x20	/* Pre-reserve swap */
114 
115 #endif	/* _SYS_VNIOCTL_H_*/
116