1 /* 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. 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 8.2 (Berkeley) 10/26/94 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 TAILQ_HEAD(locklist, lockf); 20 21 struct lockf { 22 short lf_flags; /* Semantics: F_POSIX, F_FLOCK, F_WAIT */ 23 short lf_type; /* Lock type: F_RDLCK, F_WRLCK */ 24 off_t lf_start; /* Byte # of the start of the lock */ 25 off_t lf_end; /* Byte # of the end of the lock (-1=EOF) */ 26 caddr_t lf_id; /* Id of the resource holding the lock */ 27 struct inode *lf_inode; /* Back pointer to the inode */ 28 struct lockf *lf_next; /* Pointer to the next lock on this inode */ 29 struct locklist lf_blkhd; /* List of requests blocked on this lock */ 30 TAILQ_ENTRY(lockf) lf_block;/* A request waiting for a lock */ 31 }; 32 33 /* Maximum length of sleep chains to traverse to try and detect deadlock. */ 34 #define MAXDEPTH 50 35 36 __BEGIN_DECLS 37 void lf_addblock __P((struct lockf *, struct lockf *)); 38 int lf_clearlock __P((struct lockf *)); 39 int lf_findoverlap __P((struct lockf *, 40 struct lockf *, int, struct lockf ***, struct lockf **)); 41 struct lockf * 42 lf_getblock __P((struct lockf *)); 43 int lf_getlock __P((struct lockf *, struct flock *)); 44 int lf_setlock __P((struct lockf *)); 45 void lf_split __P((struct lockf *, struct lockf *)); 46 void lf_wakelock __P((struct lockf *)); 47 __END_DECLS 48 49 #ifdef LOCKF_DEBUG 50 extern int lockf_debug; 51 52 __BEGIN_DECLS 53 void lf_print __P((char *, struct lockf *)); 54 void lf_printlist __P((char *, struct lockf *)); 55 __END_DECLS 56 #endif 57