klm_prot.x revision 1.3 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.3 lukem %#include <sys/cdefs.h>
41 1.1 jtc %#ifndef lint
42 1.1 jtc %/*static char sccsid[] = "from: @(#)klm_prot.x 1.7 87/07/08 Copyr 1987 Sun Micro";*/
43 1.1 jtc %/*static char sccsid[] = "from: @(#)klm_prot.x 2.1 88/08/01 4.0 RPCSRC";*/
44 1.3 lukem %__RCSID("$NetBSD: klm_prot.x,v 1.3 1997/10/09 14:21:20 lukem Exp $");
45 1.1 jtc %#endif /* not lint */
46 1.1 jtc #endif
47 1.1 jtc
48 1.1 jtc const LM_MAXSTRLEN = 1024;
49 1.1 jtc
50 1.1 jtc /*
51 1.1 jtc * lock manager status returns
52 1.1 jtc */
53 1.1 jtc enum klm_stats {
54 1.1 jtc klm_granted = 0, /* lock is granted */
55 1.1 jtc klm_denied = 1, /* lock is denied */
56 1.1 jtc klm_denied_nolocks = 2, /* no lock entry available */
57 1.1 jtc klm_working = 3 /* lock is being processed */
58 1.1 jtc };
59 1.1 jtc
60 1.1 jtc /*
61 1.1 jtc * lock manager lock identifier
62 1.1 jtc */
63 1.1 jtc struct klm_lock {
64 1.1 jtc string server_name<LM_MAXSTRLEN>;
65 1.1 jtc netobj fh; /* a counted file handle */
66 1.1 jtc int pid; /* holder of the lock */
67 1.1 jtc unsigned l_offset; /* beginning offset of the lock */
68 1.1 jtc unsigned l_len; /* byte length of the lock;
69 1.1 jtc * zero means through end of file */
70 1.1 jtc };
71 1.1 jtc
72 1.1 jtc /*
73 1.1 jtc * lock holder identifier
74 1.1 jtc */
75 1.1 jtc struct klm_holder {
76 1.1 jtc bool exclusive; /* FALSE if shared lock */
77 1.1 jtc int svid; /* holder of the lock (pid) */
78 1.1 jtc unsigned l_offset; /* beginning offset of the lock */
79 1.1 jtc unsigned l_len; /* byte length of the lock;
80 1.1 jtc * zero means through end of file */
81 1.1 jtc };
82 1.1 jtc
83 1.1 jtc /*
84 1.1 jtc * reply to KLM_LOCK / KLM_UNLOCK / KLM_CANCEL
85 1.1 jtc */
86 1.1 jtc struct klm_stat {
87 1.1 jtc klm_stats stat;
88 1.1 jtc };
89 1.1 jtc
90 1.1 jtc /*
91 1.1 jtc * reply to a KLM_TEST call
92 1.1 jtc */
93 1.1 jtc union klm_testrply switch (klm_stats stat) {
94 1.1 jtc case klm_denied:
95 1.1 jtc struct klm_holder holder;
96 1.1 jtc default: /* All other cases return no arguments */
97 1.1 jtc void;
98 1.1 jtc };
99 1.1 jtc
100 1.1 jtc
101 1.1 jtc /*
102 1.1 jtc * arguments to KLM_LOCK
103 1.1 jtc */
104 1.1 jtc struct klm_lockargs {
105 1.1 jtc bool block;
106 1.1 jtc bool exclusive;
107 1.1 jtc struct klm_lock alock;
108 1.1 jtc };
109 1.1 jtc
110 1.1 jtc /*
111 1.1 jtc * arguments to KLM_TEST
112 1.1 jtc */
113 1.1 jtc struct klm_testargs {
114 1.1 jtc bool exclusive;
115 1.1 jtc struct klm_lock alock;
116 1.1 jtc };
117 1.1 jtc
118 1.1 jtc /*
119 1.1 jtc * arguments to KLM_UNLOCK
120 1.1 jtc */
121 1.1 jtc struct klm_unlockargs {
122 1.1 jtc struct klm_lock alock;
123 1.1 jtc };
124 1.1 jtc
125 1.1 jtc program KLM_PROG {
126 1.1 jtc version KLM_VERS {
127 1.1 jtc
128 1.1 jtc klm_testrply KLM_TEST (struct klm_testargs) = 1;
129 1.1 jtc
130 1.1 jtc klm_stat KLM_LOCK (struct klm_lockargs) = 2;
131 1.1 jtc
132 1.1 jtc klm_stat KLM_CANCEL (struct klm_lockargs) = 3;
133 1.1 jtc /* klm_granted=> the cancel request fails due to lock is already granted */
134 1.1 jtc /* klm_denied=> the cancel request successfully aborts
135 1.1 jtc lock request */
136 1.1 jtc
137 1.1 jtc klm_stat KLM_UNLOCK (struct klm_unlockargs) = 4;
138 1.1 jtc } = 1;
139 1.1 jtc } = 100020;
140