root/sys/lockf.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


    1 /*      $OpenBSD: lockf.h,v 1.7 2005/03/10 17:26:10 tedu Exp $  */
    2 /*      $NetBSD: lockf.h,v 1.5 1994/06/29 06:44:33 cgd Exp $    */
    3 
    4 /*
    5  * Copyright (c) 1991, 1993
    6  *      The Regents of the University of California.  All rights reserved.
    7  *
    8  * This code is derived from software contributed to Berkeley by
    9  * Scooter Morris at Genentech Inc.
   10  *
   11  * Redistribution and use in source and binary forms, with or without
   12  * modification, are permitted provided that the following conditions
   13  * are met:
   14  * 1. Redistributions of source code must retain the above copyright
   15  *    notice, this list of conditions and the following disclaimer.
   16  * 2. Redistributions in binary form must reproduce the above copyright
   17  *    notice, this list of conditions and the following disclaimer in the
   18  *    documentation and/or other materials provided with the distribution.
   19  * 3. Neither the name of the University nor the names of its contributors
   20  *    may be used to endorse or promote products derived from this software
   21  *    without specific prior written permission.
   22  *
   23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   33  * SUCH DAMAGE.
   34  *
   35  *      @(#)lockf.h     8.1 (Berkeley) 6/11/93
   36  */
   37 
   38 /*
   39  * The lockf structure is a kernel structure which contains the information
   40  * associated with a byte range lock.  The lockf structures are linked into
   41  * the inode structure. Locks are sorted by the starting byte of the lock for
   42  * efficiency.
   43  */
   44 TAILQ_HEAD(locklist, lockf);
   45 
   46 struct lockf {
   47         short   lf_flags;        /* Lock semantics: F_POSIX, F_FLOCK, F_WAIT */
   48         short   lf_type;         /* Lock type: F_RDLCK, F_WRLCK */
   49         off_t   lf_start;        /* The byte # of the start of the lock */
   50         off_t   lf_end;          /* The byte # of the end of the lock (-1=EOF)*/
   51         caddr_t lf_id;           /* The id of the resource holding the lock */
   52         struct  lockf **lf_head; /* Back pointer to the head of lockf list */
   53         struct  lockf *lf_next;  /* A pointer to the next lock on this inode */
   54         struct  locklist lf_blkhd;      /* The list of blocked locks */
   55         TAILQ_ENTRY(lockf) lf_block; /* A request waiting for a lock */
   56         uid_t   lf_uid;         /* User ID responsible */
   57 };
   58 
   59 /* Maximum length of sleep chains to traverse to try and detect deadlock. */
   60 #define MAXDEPTH 50
   61 
   62 __BEGIN_DECLS
   63 void     lf_init(void);
   64 int      lf_advlock(struct lockf **,
   65             off_t, caddr_t, int, struct flock *, int);
   66 int      lf_clearlock(struct lockf *);
   67 int      lf_findoverlap(struct lockf *,
   68             struct lockf *, int, struct lockf ***, struct lockf **);
   69 struct lockf *
   70          lf_getblock(struct lockf *);
   71 int      lf_getlock(struct lockf *, struct flock *);
   72 int      lf_setlock(struct lockf *);
   73 void     lf_split(struct lockf *, struct lockf *);
   74 void     lf_wakelock(struct lockf *);
   75 __END_DECLS
   76 
   77 #ifdef LOCKF_DEBUG
   78 extern int lockf_debug;
   79 
   80 __BEGIN_DECLS
   81 void    lf_print(char *, struct lockf *);
   82 void    lf_printlist(char *, struct lockf *);
   83 __END_DECLS
   84 #endif

/* [<][>][^][v][top][bottom][index][help] */