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