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