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