1219019Sgabor/*- 2219019Sgabor * Copyright (c) 1998 Berkeley Software Design, Inc. All rights reserved. 3219019Sgabor * Redistribution and use in source and binary forms, with or without 4219019Sgabor * modification, are permitted provided that the following conditions 5219019Sgabor * are met: 6219019Sgabor * 1. Redistributions of source code must retain the above copyright 7219019Sgabor * notice, this list of conditions and the following disclaimer. 8219019Sgabor * 2. Redistributions in binary form must reproduce the above copyright 9219019Sgabor * notice, this list of conditions and the following disclaimer in the 10219019Sgabor * documentation and/or other materials provided with the distribution. 11219019Sgabor * 3. Berkeley Software Design Inc's name may not be used to endorse or 12219019Sgabor * promote products derived from this software without specific prior 13219019Sgabor * written permission. 14219019Sgabor * 15219019Sgabor * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``AS IS'' AND 16219019Sgabor * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17219019Sgabor * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18219019Sgabor * ARE DISCLAIMED. IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN INC BE LIABLE 19219019Sgabor * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20219019Sgabor * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21219019Sgabor * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22219019Sgabor * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23219019Sgabor * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24219019Sgabor * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25219019Sgabor * SUCH DAMAGE. 26219019Sgabor * 27219019Sgabor * from nfs_lock.h,v 2.2 1998/04/28 19:38:41 don Exp 28219019Sgabor * $FreeBSD$ 29219019Sgabor */ 30219019Sgabor 31219019Sgabor/* 32219019Sgabor * lockd uses the nfssvc system call to get the unique kernel services it needs. 33219019Sgabor * It passes in a request structure with a version number at the start. 34219019Sgabor * This prevents libc from needing to change if the information passed 35219019Sgabor * between lockd and the kernel needs to change. 36219019Sgabor * 37219019Sgabor * If a structure changes, you must bump the version number. 38219019Sgabor */ 39219019Sgabor 40219019Sgabor/* 41219019Sgabor * The fifo where the kernel writes requests for locks on remote NFS files, 42219019Sgabor * and where lockd reads these requests. 43219019Sgabor * 44219019Sgabor */ 45219019Sgabor#define _PATH_NFSLCKDEV "nfslock" 46219019Sgabor 47219019Sgabor/* 48219019Sgabor * This structure is used to uniquely identify the process which originated 49219019Sgabor * a particular message to lockd. A sequence number is used to differentiate 50219019Sgabor * multiple messages from the same process. A process start time is used to 51219019Sgabor * detect the unlikely, but possible, event of the recycling of a pid. 52219019Sgabor */ 53219019Sgaborstruct lockd_msg_ident { 54219019Sgabor pid_t pid; /* The process ID. */ 55219019Sgabor struct timeval pid_start; /* Start time of process id */ 56219019Sgabor int msg_seq; /* Sequence number of message */ 57219019Sgabor}; 58219019Sgabor 59219019Sgabor#define LOCKD_MSG_VERSION 3 60219019Sgabor 61219019Sgabor/* 62219019Sgabor * The structure that the kernel hands us for each lock request. 63219019Sgabor */ 64219019Sgabortypedef struct __lock_msg { 65219019Sgabor TAILQ_ENTRY(__lock_msg) lm_link; /* internal linkage */ 66219019Sgabor int lm_version; /* which version is this */ 67219019Sgabor struct lockd_msg_ident lm_msg_ident; /* originator of the message */ 68219019Sgabor struct flock lm_fl; /* The lock request. */ 69219019Sgabor int lm_wait; /* The F_WAIT flag. */ 70219019Sgabor int lm_getlk; /* is this a F_GETLK request */ 71219019Sgabor struct sockaddr_storage lm_addr; /* The address. */ 72219019Sgabor int lm_nfsv3; /* If NFS version 3. */ 73219019Sgabor size_t lm_fh_len; /* The file handle length. */ 74219019Sgabor struct xucred lm_cred; /* user cred for lock req */ 75219019Sgabor u_int8_t lm_fh[NFSX_V3FHMAX];/* The file handle. */ 76219019Sgabor} LOCKD_MSG; 77219019Sgabor 78219019Sgabor#define LOCKD_ANS_VERSION 1 79219019Sgabor 80219019Sgaborstruct lockd_ans { 81219019Sgabor int la_vers; 82219019Sgabor struct lockd_msg_ident la_msg_ident; /* originator of the message */ 83219019Sgabor int la_errno; 84219019Sgabor int la_set_getlk_pid; /* use returned pid */ 85219019Sgabor int la_getlk_pid; /* returned pid for F_GETLK */ 86219019Sgabor}; 87219019Sgabor 88219019Sgabor#ifdef _KERNEL 89219019Sgaborint nfs_dolock(struct vop_advlock_args *ap); 90219019Sgaborextern vop_advlock_t *nfs_advlock_p; 91219019Sgaborextern vop_reclaim_t *nfs_reclaim_p; 92219019Sgabor#endif 93219019Sgabor