1*6ca35587Sdholland /* $NetBSD: nfs_lock.h,v 1.1.1.1 2013/09/30 07:19:33 dholland Exp $ */ 2*6ca35587Sdholland /*- 3*6ca35587Sdholland * Copyright (c) 1998 Berkeley Software Design, Inc. All rights reserved. 4*6ca35587Sdholland * Redistribution and use in source and binary forms, with or without 5*6ca35587Sdholland * modification, are permitted provided that the following conditions 6*6ca35587Sdholland * are met: 7*6ca35587Sdholland * 1. Redistributions of source code must retain the above copyright 8*6ca35587Sdholland * notice, this list of conditions and the following disclaimer. 9*6ca35587Sdholland * 2. Redistributions in binary form must reproduce the above copyright 10*6ca35587Sdholland * notice, this list of conditions and the following disclaimer in the 11*6ca35587Sdholland * documentation and/or other materials provided with the distribution. 12*6ca35587Sdholland * 3. Berkeley Software Design Inc's name may not be used to endorse or 13*6ca35587Sdholland * promote products derived from this software without specific prior 14*6ca35587Sdholland * written permission. 15*6ca35587Sdholland * 16*6ca35587Sdholland * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``AS IS'' AND 17*6ca35587Sdholland * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18*6ca35587Sdholland * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19*6ca35587Sdholland * ARE DISCLAIMED. IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN INC BE LIABLE 20*6ca35587Sdholland * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21*6ca35587Sdholland * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22*6ca35587Sdholland * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23*6ca35587Sdholland * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24*6ca35587Sdholland * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25*6ca35587Sdholland * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26*6ca35587Sdholland * SUCH DAMAGE. 27*6ca35587Sdholland * 28*6ca35587Sdholland * from nfs_lock.h,v 2.2 1998/04/28 19:38:41 don Exp 29*6ca35587Sdholland * FreeBSD: head/sys/nfs/nfs_lock.h 214048 2010-10-19 00:20:00Z rmacklem 30*6ca35587Sdholland * $NetBSD: nfs_lock.h,v 1.1.1.1 2013/09/30 07:19:33 dholland Exp $ 31*6ca35587Sdholland */ 32*6ca35587Sdholland 33*6ca35587Sdholland /* 34*6ca35587Sdholland * lockd uses the nfssvc system call to get the unique kernel services it needs. 35*6ca35587Sdholland * It passes in a request structure with a version number at the start. 36*6ca35587Sdholland * This prevents libc from needing to change if the information passed 37*6ca35587Sdholland * between lockd and the kernel needs to change. 38*6ca35587Sdholland * 39*6ca35587Sdholland * If a structure changes, you must bump the version number. 40*6ca35587Sdholland */ 41*6ca35587Sdholland 42*6ca35587Sdholland /* 43*6ca35587Sdholland * The fifo where the kernel writes requests for locks on remote NFS files, 44*6ca35587Sdholland * and where lockd reads these requests. 45*6ca35587Sdholland * 46*6ca35587Sdholland */ 47*6ca35587Sdholland #define _PATH_NFSLCKDEV "nfslock" 48*6ca35587Sdholland 49*6ca35587Sdholland /* 50*6ca35587Sdholland * This structure is used to uniquely identify the process which originated 51*6ca35587Sdholland * a particular message to lockd. A sequence number is used to differentiate 52*6ca35587Sdholland * multiple messages from the same process. A process start time is used to 53*6ca35587Sdholland * detect the unlikely, but possible, event of the recycling of a pid. 54*6ca35587Sdholland */ 55*6ca35587Sdholland struct lockd_msg_ident { 56*6ca35587Sdholland pid_t pid; /* The process ID. */ 57*6ca35587Sdholland struct timeval pid_start; /* Start time of process id */ 58*6ca35587Sdholland int msg_seq; /* Sequence number of message */ 59*6ca35587Sdholland }; 60*6ca35587Sdholland 61*6ca35587Sdholland #define LOCKD_MSG_VERSION 3 62*6ca35587Sdholland 63*6ca35587Sdholland /* 64*6ca35587Sdholland * The structure that the kernel hands us for each lock request. 65*6ca35587Sdholland */ 66*6ca35587Sdholland typedef struct __lock_msg { 67*6ca35587Sdholland TAILQ_ENTRY(__lock_msg) lm_link; /* internal linkage */ 68*6ca35587Sdholland int lm_version; /* which version is this */ 69*6ca35587Sdholland struct lockd_msg_ident lm_msg_ident; /* originator of the message */ 70*6ca35587Sdholland struct flock lm_fl; /* The lock request. */ 71*6ca35587Sdholland int lm_wait; /* The F_WAIT flag. */ 72*6ca35587Sdholland int lm_getlk; /* is this a F_GETLK request */ 73*6ca35587Sdholland struct sockaddr_storage lm_addr; /* The address. */ 74*6ca35587Sdholland int lm_nfsv3; /* If NFS version 3. */ 75*6ca35587Sdholland size_t lm_fh_len; /* The file handle length. */ 76*6ca35587Sdholland struct xucred lm_cred; /* user cred for lock req */ 77*6ca35587Sdholland u_int8_t lm_fh[NFSX_V3FHMAX];/* The file handle. */ 78*6ca35587Sdholland } LOCKD_MSG; 79*6ca35587Sdholland 80*6ca35587Sdholland #define LOCKD_ANS_VERSION 1 81*6ca35587Sdholland 82*6ca35587Sdholland struct lockd_ans { 83*6ca35587Sdholland int la_vers; 84*6ca35587Sdholland struct lockd_msg_ident la_msg_ident; /* originator of the message */ 85*6ca35587Sdholland int la_errno; 86*6ca35587Sdholland int la_set_getlk_pid; /* use returned pid */ 87*6ca35587Sdholland int la_getlk_pid; /* returned pid for F_GETLK */ 88*6ca35587Sdholland }; 89*6ca35587Sdholland 90*6ca35587Sdholland #ifdef _KERNEL 91*6ca35587Sdholland int nfs_dolock(struct vop_advlock_args *ap); 92*6ca35587Sdholland extern vop_advlock_t *nfs_advlock_p; 93*6ca35587Sdholland extern vop_reclaim_t *nfs_reclaim_p; 94*6ca35587Sdholland #endif 95