xref: /freebsd/include/rpcsvc/klm_prot.x (revision aa0a1e58)
1 /*
2  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
3  * unrestricted use provided that this legend is included on all tape
4  * media and as a part of the software program in whole or part.  Users
5  * may copy or modify Sun RPC without charge, but are not authorized
6  * to license or distribute it to anyone else except as part of a product or
7  * program developed by the user.
8  *
9  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
10  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
11  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
12  *
13  * Sun RPC is provided with no support and without any obligation on the
14  * part of Sun Microsystems, Inc. to assist in its use, correction,
15  * modification or enhancement.
16  *
17  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
18  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
19  * OR ANY PART THEREOF.
20  *
21  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
22  * or profits or other special, indirect and consequential damages, even if
23  * Sun has been advised of the possibility of such damages.
24  *
25  * Sun Microsystems, Inc.
26  * 2550 Garcia Avenue
27  * Mountain View, California  94043
28  */
29 
30 /*
31  * Kernel/lock manager protocol definition
32  * Copyright (C) 1986 Sun Microsystems, Inc.
33  *
34  * protocol used between the UNIX kernel (the "client") and the
35  * local lock manager.  The local lock manager is a deamon running
36  * above the kernel.
37  */
38 
39 #ifndef RPC_HDR
40 %#ifndef lint
41 %/*static char sccsid[] = "from: @(#)klm_prot.x 1.7 87/07/08 Copyr 1987 Sun Micro";*/
42 %/*static char sccsid[] = "from: @(#)klm_prot.x	2.1 88/08/01 4.0 RPCSRC";*/
43 %#endif /* not lint */
44 %#include <sys/cdefs.h>
45 %__FBSDID("$FreeBSD$");
46 #endif
47 
48 const	LM_MAXSTRLEN = 1024;
49 
50 /*
51  * lock manager status returns
52  */
53 enum klm_stats {
54 	klm_granted = 0,	/* lock is granted */
55 	klm_denied = 1,		/* lock is denied */
56 	klm_denied_nolocks = 2, /* no lock entry available */
57 	klm_working = 3 	/* lock is being processed */
58 };
59 
60 /*
61  * lock manager lock identifier
62  */
63 struct klm_lock {
64 	string server_name<LM_MAXSTRLEN>;
65 	netobj fh;		/* a counted file handle */
66 	int pid;		/* holder of the lock */
67 	unsigned l_offset;	/* beginning offset of the lock */
68 	unsigned l_len;		/* byte length of the lock;
69 				 * zero means through end of file */
70 };
71 
72 /*
73  * lock holder identifier
74  */
75 struct klm_holder {
76 	bool exclusive;		/* FALSE if shared lock */
77 	int svid;		/* holder of the lock (pid) */
78 	unsigned l_offset;	/* beginning offset of the lock */
79 	unsigned l_len;		/* byte length of the lock;
80 				 * zero means through end of file */
81 };
82 
83 /*
84  * reply to KLM_LOCK / KLM_UNLOCK / KLM_CANCEL
85  */
86 struct klm_stat {
87 	klm_stats stat;
88 };
89 
90 /*
91  * reply to a KLM_TEST call
92  */
93 union klm_testrply switch (klm_stats stat) {
94 	case klm_denied:
95 		struct klm_holder holder;
96 	default: /* All other cases return no arguments */
97 		void;
98 };
99 
100 
101 /*
102  * arguments to KLM_LOCK
103  */
104 struct klm_lockargs {
105 	bool block;
106 	bool exclusive;
107 	struct klm_lock alock;
108 };
109 
110 /*
111  * arguments to KLM_TEST
112  */
113 struct klm_testargs {
114 	bool exclusive;
115 	struct klm_lock alock;
116 };
117 
118 /*
119  * arguments to KLM_UNLOCK
120  */
121 struct klm_unlockargs {
122 	struct klm_lock alock;
123 };
124 
125 program KLM_PROG {
126 	version KLM_VERS {
127 
128 		klm_testrply	KLM_TEST (struct klm_testargs) =	1;
129 
130 		klm_stat	KLM_LOCK (struct klm_lockargs) =	2;
131 
132 		klm_stat	KLM_CANCEL (struct klm_lockargs) =	3;
133 		/* klm_granted=> the cancel request fails due to lock is already granted */
134 		/* klm_denied=> the cancel request successfully aborts
135 lock request  */
136 
137 		klm_stat	KLM_UNLOCK (struct klm_unlockargs) =	4;
138 	} = 1;
139 } = 100020;
140