xref: /titanic_44/usr/src/uts/common/sys/open.h (revision 8eea8e29cc4374d1ee24c25a07f45af132db3499)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
23 /*	  All Rights Reserved  	*/
24 
25 
26 #ifndef _SYS_OPEN_H
27 #define	_SYS_OPEN_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* from SVR4 11.4 */
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 /*
36  * Some drivers need to be able to keep accurate records of open/close
37  * calls to determine whether a device is still in use.  To allow this
38  * open/close calls have been typed and the type is passed as a third
39  * argument in open/close calls, as in:
40  *	(*cdevsw[getmajor(dev)].d_open)(getminor(dev), flag, OTYP_CHR);
41  * or
42  *	(*cdevsw[getmajor(dev)].d_close)(getminor(dev), flag, OTYP_CHR);
43  * Five types of open/close calls have been defined:
44  * OTYP_BLK:	open/close of a block special file
45  * OTYP_MNT:	open/close for mounting/unmounting a file system
46  * OTYP_CHR:	open/close of a character special file
47  * OTYP_SWP:	open/close of a swapping device.
48  * OTYP_LYR:	open/close calls from a driver to another driver,
49  *		without a file being open for the dev of the lower driver.
50  *
51  * The first four types of open/close calls obey the protocol rule
52  * that many more opens may occur for a given minor(dev) for that type of open,
53  * but a close call happens only on the last close of that dev.
54  * This protocol allows a flag to be used (set by opens, cleared by closes)
55  * to keep track of the state for a given minor device value.
56  *
57  * Calls of the fifth type (OTYP_LYR) must obey the protocol rule
58  * that open and close call calls are always paired.  This protocol
59  * permits several drivers to be layers above the same device driver.
60  * A counter can be used for this protocol.
61  *
62  * The value OTYPCNT is defined for the purpose of declaring arrays
63  * in drivers and for performing range checks (0 <= otyp < OTYPCNT)
64  * on values passed.
65  */
66 
67 #define	OTYPCNT		5
68 #define	OTYP_BLK	0
69 #define	OTYP_MNT	1
70 #define	OTYP_CHR	2
71 #define	OTYP_SWP	3
72 #define	OTYP_LYR	4
73 
74 #ifdef	__cplusplus
75 }
76 #endif
77 
78 #endif	/* _SYS_OPEN_H */
79