cpp-d1064d
[cross.git] / i686-linux-gnu-4.7 / usr / include / rpcsvc / klm_prot.x
1 /* @(#)klm_prot.x       2.1 88/08/01 4.0 RPCSRC */
2
3 /*
4  * Kernel/lock manager protocol definition
5  * Copyright (c) 2010, Oracle America, Inc.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are
9  * met:
10  *
11  *     * Redistributions of source code must retain the above copyright
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above
14  *       copyright notice, this list of conditions and the following
15  *       disclaimer in the documentation and/or other materials
16  *       provided with the distribution.
17  *     * Neither the name of the "Oracle America, Inc." nor the names of its
18  *       contributors may be used to endorse or promote products derived
19  *       from this software without specific prior written permission.
20  *
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  *   COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
26  *   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
28  *   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29  *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30  *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31  *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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 const   LM_MAXSTRLEN = 1024;
40
41 /*
42  * lock manager status returns
43  */
44 enum klm_stats {
45         klm_granted = 0,        /* lock is granted */
46         klm_denied = 1,         /* lock is denied */
47         klm_denied_nolocks = 2, /* no lock entry available */
48         klm_working = 3         /* lock is being processed */
49 };
50
51 /*
52  * lock manager lock identifier
53  */
54 struct klm_lock {
55         string server_name<LM_MAXSTRLEN>;
56         netobj fh;              /* a counted file handle */
57         int pid;                /* holder of the lock */
58         unsigned l_offset;      /* beginning offset of the lock */
59         unsigned l_len;         /* byte length of the lock;
60                                  * zero means through end of file */
61 };
62
63 /*
64  * lock holder identifier
65  */
66 struct klm_holder {
67         bool exclusive;         /* FALSE if shared lock */
68         int svid;               /* holder of the lock (pid) */
69         unsigned l_offset;      /* beginning offset of the lock */
70         unsigned l_len;         /* byte length of the lock;
71                                  * zero means through end of file */
72 };
73
74 /*
75  * reply to KLM_LOCK / KLM_UNLOCK / KLM_CANCEL
76  */
77 struct klm_stat {
78         klm_stats stat;
79 };
80
81 /*
82  * reply to a KLM_TEST call
83  */
84 union klm_testrply switch (klm_stats stat) {
85         case klm_denied:
86                 struct klm_holder holder;
87         default: /* All other cases return no arguments */
88                 void;
89 };
90
91
92 /*
93  * arguments to KLM_LOCK
94  */
95 struct klm_lockargs {
96         bool block;
97         bool exclusive;
98         struct klm_lock alock;
99 };
100
101 /*
102  * arguments to KLM_TEST
103  */
104 struct klm_testargs {
105         bool exclusive;
106         struct klm_lock alock;
107 };
108
109 /*
110  * arguments to KLM_UNLOCK
111  */
112 struct klm_unlockargs {
113         struct klm_lock alock;
114 };
115
116 program KLM_PROG {
117         version KLM_VERS {
118
119                 klm_testrply    KLM_TEST (struct klm_testargs) =        1;
120
121                 klm_stat        KLM_LOCK (struct klm_lockargs) =        2;
122
123                 klm_stat        KLM_CANCEL (struct klm_lockargs) =      3;
124                 /* klm_granted=> the cancel request fails due to lock is already granted */
125                 /* klm_denied=> the cancel request successfully aborts
126 lock request  */
127
128                 klm_stat        KLM_UNLOCK (struct klm_unlockargs) =    4;
129         } = 1;
130 } = 100020;