xref: /titanic_41/usr/src/uts/common/sys/lockfs.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
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 /*
23  * Copyright 1998 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_LOCKFS_H
28 #define	_SYS_LOCKFS_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #ifdef _SYSCALL32
37 /*
38  * ILP32 version of lockfs, used in ufs_ioctl() to support 32-bit app in
39  * LP64 kernel
40  */
41 struct lockfs32 {
42 	uint32_t	lf_lock;	/* desired lock */
43 	uint32_t	lf_flags;	/* misc flags */
44 	uint32_t	lf_key;		/* lock key */
45 	uint32_t	lf_comlen;	/* length of comment */
46 	uint32_t	lf_comment;	/* address of comment */
47 };
48 #endif /* _SYSCALL32 */
49 
50 struct lockfs {
51 	ulong_t		lf_lock;	/* desired lock */
52 	ulong_t		lf_flags;	/* misc flags */
53 	ulong_t		lf_key;		/* lock key */
54 	ulong_t		lf_comlen;	/* length of comment */
55 	caddr_t		lf_comment;	/* address of comment */
56 };
57 
58 /*
59  * lf_lock and lf_locking
60  */
61 #define	LOCKFS_ULOCK	0	/* unlock */
62 #define	LOCKFS_WLOCK	1	/* write  lock */
63 #define	LOCKFS_NLOCK	2	/* name   lock */
64 #define	LOCKFS_DLOCK	3	/* delete lock */
65 #define	LOCKFS_HLOCK	4	/* hard   lock */
66 #define	LOCKFS_ELOCK	5	/* error  lock */
67 #define	LOCKFS_ROELOCK	6	/* error  lock (read-only) - unimplemented */
68 #define	LOCKFS_MAXLOCK	6	/* maximum lock number */
69 
70 /*
71  * lf_flags
72  */
73 #define	LOCKFS_BUSY	0x00000001	/* lock is being set */
74 #define	LOCKFS_MOD	0x00000002	/* file system modified */
75 
76 #define	LOCKFS_MAXCOMMENTLEN	1024	/* maximum comment length */
77 
78 /*
79  * some nice checking macros
80  */
81 
82 #define	LOCKFS_IS_BUSY(LF)	((LF)->lf_flags & LOCKFS_BUSY)
83 #define	LOCKFS_IS_MOD(LF)	((LF)->lf_flags & LOCKFS_MOD)
84 
85 #define	LOCKFS_CLR_BUSY(LF)	((LF)->lf_flags &= ~LOCKFS_BUSY)
86 #define	LOCKFS_CLR_MOD(LF)	((LF)->lf_flags &= ~LOCKFS_MOD)
87 
88 #define	LOCKFS_SET_MOD(LF)	((LF)->lf_flags |= LOCKFS_MOD)
89 #define	LOCKFS_SET_BUSY(LF)	((LF)->lf_flags |= LOCKFS_BUSY)
90 
91 #define	LOCKFS_IS_WLOCK(LF)	((LF)->lf_lock == LOCKFS_WLOCK)
92 #define	LOCKFS_IS_HLOCK(LF)	((LF)->lf_lock == LOCKFS_HLOCK)
93 #define	LOCKFS_IS_ROELOCK(LF)	((LF)->lf_lock == LOCKFS_ROELOCK)
94 #define	LOCKFS_IS_ELOCK(LF)	((LF)->lf_lock == LOCKFS_ELOCK)
95 #define	LOCKFS_IS_ULOCK(LF)	((LF)->lf_lock == LOCKFS_ULOCK)
96 #define	LOCKFS_IS_NLOCK(LF)	((LF)->lf_lock == LOCKFS_NLOCK)
97 #define	LOCKFS_IS_DLOCK(LF)	((LF)->lf_lock == LOCKFS_DLOCK)
98 
99 #ifdef	__cplusplus
100 }
101 #endif
102 
103 #endif	/* _SYS_LOCKFS_H */
104