xref: /original-bsd/sys/ufs/ffs/lockf.h (revision 1b11f3a3)
1 /*
2  * Copyright (c) 1991 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Scooter Morris at Genentech Inc.
7  *
8  * %sccs.include.redist.c%
9  *
10  *	@(#)lockf.h	7.2 (Berkeley) 11/01/91
11  */
12 
13 /*
14  * The lockf structure is a kernel structure which contains the information
15  * associated with a byte range lock.  The lockf structures are linked into
16  * the inode structure. Locks are sorted by the starting byte of the lock for
17  * efficiency.
18  */
19 struct lockf {
20 	short	lf_flags;	 /* Lock semantics: F_POSIX, F_FLOCK, F_WAIT */
21 	short	lf_type;	 /* Lock type: F_RDLCK, F_WRLCK */
22 	off_t	lf_start;	 /* The byte # of the start of the lock */
23 	off_t	lf_end;		 /* The byte # of the end of the lock (-1=EOF)*/
24 	caddr_t	lf_id;		 /* The id of the resource holding the lock */
25 	struct	inode *lf_inode; /* Back pointer to the inode */
26 	struct	lockf *lf_next;	 /* A pointer to the next lock on this inode */
27 	struct	lockf *lf_block; /* The list of blocked locks */
28 };
29 
30 /* Maximum length of sleep chains to traverse to try and detect deadlock. */
31 #define MAXDEPTH 50
32 
33 __BEGIN_DECLS
34 void	 lf_addblock __P((struct lockf *, struct lockf *));
35 int	 lf_clearlock __P((struct lockf *));
36 int	 lf_findoverlap __P((struct lockf *,
37 	    struct lockf *, int, struct lockf ***, struct lockf **));
38 struct lockf *
39 	 lf_getblock __P((struct lockf *));
40 int	 lf_getlock __P((struct lockf *, struct flock *));
41 int	 lf_setlock __P((struct lockf *));
42 void	 lf_split __P((struct lockf *, struct lockf *));
43 void	 lf_wakelock __P((struct lockf *));
44 __END_DECLS
45 
46 #ifdef LOCKF_DEBUG
47 extern int lockf_debug;
48 
49 __BEGIN_DECLS
50 void	lf_print __P((char *, struct lockf *));
51 void	lf_printlist __P((char *, struct lockf *));
52 __END_DECLS
53 #endif
54