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