xref: /csrg-svn/sys/ufs/ffs/lockf.h (revision 63376)
146203Smckusick /*
2*63376Sbostic  * Copyright (c) 1991, 1993
3*63376Sbostic  *	The Regents of the University of California.  All rights reserved.
446203Smckusick  *
546203Smckusick  * This code is derived from software contributed to Berkeley by
646203Smckusick  * Scooter Morris at Genentech Inc.
746203Smckusick  *
846203Smckusick  * %sccs.include.redist.c%
946203Smckusick  *
10*63376Sbostic  *	@(#)lockf.h	8.1 (Berkeley) 06/11/93
1146203Smckusick  */
1246203Smckusick 
1346203Smckusick /*
1451506Sbostic  * The lockf structure is a kernel structure which contains the information
1551506Sbostic  * associated with a byte range lock.  The lockf structures are linked into
1651506Sbostic  * the inode structure. Locks are sorted by the starting byte of the lock for
1751506Sbostic  * efficiency.
1846203Smckusick  */
1946203Smckusick struct lockf {
2046203Smckusick 	short	lf_flags;	 /* Lock semantics: F_POSIX, F_FLOCK, F_WAIT */
2146203Smckusick 	short	lf_type;	 /* Lock type: F_RDLCK, F_WRLCK */
2246203Smckusick 	off_t	lf_start;	 /* The byte # of the start of the lock */
2346203Smckusick 	off_t	lf_end;		 /* The byte # of the end of the lock (-1=EOF)*/
2446203Smckusick 	caddr_t	lf_id;		 /* The id of the resource holding the lock */
2546203Smckusick 	struct	inode *lf_inode; /* Back pointer to the inode */
2646203Smckusick 	struct	lockf *lf_next;	 /* A pointer to the next lock on this inode */
2746203Smckusick 	struct	lockf *lf_block; /* The list of blocked locks */
2846203Smckusick };
2946203Smckusick 
3051506Sbostic /* Maximum length of sleep chains to traverse to try and detect deadlock. */
3146203Smckusick #define MAXDEPTH 50
3246203Smckusick 
3351506Sbostic __BEGIN_DECLS
3451506Sbostic void	 lf_addblock __P((struct lockf *, struct lockf *));
3551506Sbostic int	 lf_clearlock __P((struct lockf *));
3651506Sbostic int	 lf_findoverlap __P((struct lockf *,
3751506Sbostic 	    struct lockf *, int, struct lockf ***, struct lockf **));
3851506Sbostic struct lockf *
3951506Sbostic 	 lf_getblock __P((struct lockf *));
4051506Sbostic int	 lf_getlock __P((struct lockf *, struct flock *));
4151506Sbostic int	 lf_setlock __P((struct lockf *));
4251506Sbostic void	 lf_split __P((struct lockf *, struct lockf *));
4351506Sbostic void	 lf_wakelock __P((struct lockf *));
4451506Sbostic __END_DECLS
4546203Smckusick 
4651506Sbostic #ifdef LOCKF_DEBUG
4746203Smckusick extern int lockf_debug;
4851506Sbostic 
4951506Sbostic __BEGIN_DECLS
5051506Sbostic void	lf_print __P((char *, struct lockf *));
5151506Sbostic void	lf_printlist __P((char *, struct lockf *));
5251506Sbostic __END_DECLS
5351506Sbostic #endif
54