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