1 0 stevel /* 2 0 stevel * CDDL HEADER START 3 0 stevel * 4 0 stevel * The contents of this file are subject to the terms of the 5 0 stevel * Common Development and Distribution License, Version 1.0 only 6 0 stevel * (the "License"). You may not use this file except in compliance 7 0 stevel * with the License. 8 0 stevel * 9 0 stevel * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 0 stevel * or http://www.opensolaris.org/os/licensing. 11 0 stevel * See the License for the specific language governing permissions 12 0 stevel * and limitations under the License. 13 0 stevel * 14 0 stevel * When distributing Covered Code, include this CDDL HEADER in each 15 0 stevel * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 0 stevel * If applicable, add the following below this CDDL HEADER, with the 17 0 stevel * fields enclosed by brackets "[]" replaced with your own identifying 18 0 stevel * information: Portions Copyright [yyyy] [name of copyright owner] 19 0 stevel * 20 0 stevel * CDDL HEADER END 21 0 stevel */ 22 0 stevel /* 23 0 stevel * Network lock manager protocol definition 24 0 stevel * Copyright (C) 1986, 1992, 1993, 1997, 1999 by Sun Microsystems, Inc. 25 0 stevel * All rights reserved. 26 0 stevel * 27 0 stevel * Protocol used between local lock manager and remote lock manager. 28 0 stevel * 29 0 stevel * There are currently 3 versions of the protocol in use. Versions 1 30 0 stevel * and 3 are used with NFS version 2. Version 4 is used with NFS 31 0 stevel * version 3. 32 0 stevel * 33 0 stevel * (Note: there is also a version 2, but it defines an orthogonal set of 34 0 stevel * procedures that the status monitor uses to notify the lock manager of 35 0 stevel * changes in monitored systems.) 36 0 stevel */ 37 0 stevel 38 0 stevel %#pragma ident "%Z%%M% %I% %E% SMI" 39 0 stevel 40 0 stevel #if RPC_HDR 41 0 stevel % 42 0 stevel %#include <rpc/rpc_sztypes.h> 43 0 stevel % 44 0 stevel #endif 45 0 stevel 46 0 stevel #ifdef RPC_HDR 47 0 stevel %#define LM_MAXSTRLEN 1024 48 0 stevel %#define LM_MAXNAMELEN (LM_MAXSTRLEN + 1) 49 0 stevel #endif 50 0 stevel 51 0 stevel /* 52 0 stevel * Types for versions 1 and 3. 53 0 stevel */ 54 0 stevel 55 0 stevel /* 56 0 stevel * Status of a call to the lock manager. The lower case enums violate the 57 0 stevel * current style guide, but we're stuck with 'em. 58 0 stevel */ 59 0 stevel 60 0 stevel enum nlm_stats { 61 0 stevel nlm_granted = 0, 62 0 stevel nlm_denied = 1, 63 0 stevel nlm_denied_nolocks = 2, 64 0 stevel nlm_blocked = 3, 65 0 stevel nlm_denied_grace_period = 4, 66 0 stevel nlm_deadlck = 5 67 0 stevel }; 68 0 stevel 69 0 stevel /* 70 0 stevel * The holder of a conflicting lock. 71 0 stevel */ 72 0 stevel 73 0 stevel struct nlm_holder { 74 0 stevel bool exclusive; 75 0 stevel int svid; 76 0 stevel netobj oh; 77 0 stevel unsigned l_offset; 78 0 stevel unsigned l_len; 79 0 stevel }; 80 0 stevel 81 0 stevel union nlm_testrply switch (nlm_stats stat) { 82 0 stevel case nlm_denied: 83 0 stevel struct nlm_holder holder; 84 0 stevel default: 85 0 stevel void; 86 0 stevel }; 87 0 stevel 88 0 stevel struct nlm_stat { 89 0 stevel nlm_stats stat; 90 0 stevel }; 91 0 stevel 92 0 stevel struct nlm_res { 93 0 stevel netobj cookie; 94 0 stevel nlm_stat stat; 95 0 stevel }; 96 0 stevel 97 0 stevel struct nlm_testres { 98 0 stevel netobj cookie; 99 0 stevel nlm_testrply stat; 100 0 stevel }; 101 0 stevel 102 0 stevel struct nlm_lock { 103 0 stevel string caller_name<LM_MAXSTRLEN>; 104 0 stevel netobj fh; /* identify a file */ 105 0 stevel netobj oh; /* identify owner of a lock */ 106 0 stevel int svid; /* generated from pid for svid */ 107 0 stevel unsigned l_offset; 108 0 stevel unsigned l_len; 109 0 stevel }; 110 0 stevel 111 0 stevel struct nlm_lockargs { 112 0 stevel netobj cookie; 113 0 stevel bool block; 114 0 stevel bool exclusive; 115 0 stevel struct nlm_lock alock; 116 0 stevel bool reclaim; /* used for recovering locks */ 117 0 stevel int state; /* specify local status monitor state */ 118 0 stevel }; 119 0 stevel 120 0 stevel struct nlm_cancargs { 121 0 stevel netobj cookie; 122 0 stevel bool block; 123 0 stevel bool exclusive; 124 0 stevel struct nlm_lock alock; 125 0 stevel }; 126 0 stevel 127 0 stevel struct nlm_testargs { 128 0 stevel netobj cookie; 129 0 stevel bool exclusive; 130 0 stevel struct nlm_lock alock; 131 0 stevel }; 132 0 stevel 133 0 stevel struct nlm_unlockargs { 134 0 stevel netobj cookie; 135 0 stevel struct nlm_lock alock; 136 0 stevel }; 137 0 stevel 138 0 stevel #ifdef RPC_HDR 139 0 stevel %/* 140 0 stevel % * The following enums are actually bit encoded for efficient 141 0 stevel % * boolean algebra.... DON'T change them..... 142 0 stevel % * The mixed-case enums violate the present style guide, but we're 143 0 stevel % * stuck with 'em. 144 0 stevel % */ 145 0 stevel #endif 146 0 stevel 147 0 stevel enum fsh_mode { 148 0 stevel fsm_DN = 0, /* deny none */ 149 0 stevel fsm_DR = 1, /* deny read */ 150 0 stevel fsm_DW = 2, /* deny write */ 151 0 stevel fsm_DRW = 3 /* deny read/write */ 152 0 stevel }; 153 0 stevel 154 0 stevel enum fsh_access { 155 0 stevel fsa_NONE = 0, /* for completeness */ 156 0 stevel fsa_R = 1, /* read only */ 157 0 stevel fsa_W = 2, /* write only */ 158 0 stevel fsa_RW = 3 /* read/write */ 159 0 stevel }; 160 0 stevel 161 0 stevel struct nlm_share { 162 0 stevel string caller_name<LM_MAXSTRLEN>; 163 0 stevel netobj fh; 164 0 stevel netobj oh; 165 0 stevel fsh_mode mode; 166 0 stevel fsh_access access; 167 0 stevel }; 168 0 stevel 169 0 stevel struct nlm_shareargs { 170 0 stevel netobj cookie; 171 0 stevel nlm_share share; 172 0 stevel bool reclaim; 173 0 stevel }; 174 0 stevel 175 0 stevel struct nlm_shareres { 176 0 stevel netobj cookie; 177 0 stevel nlm_stats stat; 178 0 stevel int sequence; 179 0 stevel }; 180 0 stevel 181 0 stevel struct nlm_notify { 182 0 stevel string name<LM_MAXNAMELEN>; 183 0 stevel int state; 184 0 stevel }; 185 0 stevel 186 0 stevel /* 187 0 stevel * Types for version 4. 188 0 stevel * 189 0 stevel * This revision is designed to work with NFS V3. The main changes from 190 0 stevel * NFS V2 to V3 that affect the NLM protocol are that all file offsets 191 0 stevel * and sizes are now unsigned 64-bit ints, and file handles are now 192 0 stevel * variable length. In NLM V1 and V3, the fixed-length V2 file handle 193 0 stevel * was encoded as a 'netobj', which is a count followed by the data 194 0 stevel * bytes. For NLM 4, the file handle is already a count followed by 195 0 stevel * data bytes, so the handle is copied directly into the netobj, rather 196 0 stevel * than being encoded with an additional byte count. 197 0 stevel */ 198 0 stevel 199 0 stevel /* 200 0 stevel * Status of a call to the lock manager. 201 0 stevel */ 202 0 stevel 203 0 stevel enum nlm4_stats { 204 0 stevel NLM4_GRANTED = 0, /* lock was granted */ 205 0 stevel NLM4_DENIED = 1, /* lock was not granted, usually */ 206 0 stevel /* due to conflicting lock */ 207 0 stevel NLM4_DENIED_NOLOCKS = 2, /* not granted: out of resources */ 208 0 stevel NLM4_BLOCKED = 3, /* not granted: expect callback */ 209 0 stevel /* when granted */ 210 0 stevel NLM4_DENIED_GRACE_PERIOD = 4, /* not granted: server is */ 211 0 stevel /* reestablishing old locks */ 212 0 stevel NLM4_DEADLCK = 5, /* not granted: deadlock detected */ 213 0 stevel NLM4_ROFS = 6, /* not granted: read-only filesystem */ 214 0 stevel NLM4_STALE_FH = 7, /* not granted: stale file handle */ 215 0 stevel NLM4_FBIG = 8, /* not granted: offset or length */ 216 0 stevel /* too big */ 217 0 stevel NLM4_FAILED = 9 /* not granted: some other error */ 218 0 stevel }; 219 0 stevel 220 0 stevel /* 221 0 stevel * The holder of a conflicting lock. 222 0 stevel */ 223 0 stevel 224 0 stevel struct nlm4_holder { 225 0 stevel bool exclusive; 226 0 stevel int32 svid; 227 0 stevel netobj oh; 228 0 stevel uint64 l_offset; 229 0 stevel uint64 l_len; 230 0 stevel }; 231 0 stevel 232 0 stevel union nlm4_testrply switch (nlm4_stats stat) { 233 0 stevel case NLM4_DENIED: 234 0 stevel struct nlm4_holder holder; 235 0 stevel default: 236 0 stevel void; 237 0 stevel }; 238 0 stevel 239 0 stevel struct nlm4_stat { 240 0 stevel nlm4_stats stat; 241 0 stevel }; 242 0 stevel 243 0 stevel struct nlm4_res { 244 0 stevel netobj cookie; 245 0 stevel nlm4_stat stat; 246 0 stevel }; 247 0 stevel 248 0 stevel struct nlm4_testres { 249 0 stevel netobj cookie; 250 0 stevel nlm4_testrply stat; 251 0 stevel }; 252 0 stevel 253 0 stevel struct nlm4_lock { 254 0 stevel string caller_name<LM_MAXSTRLEN>; 255 0 stevel netobj fh; /* identify a file */ 256 0 stevel netobj oh; /* identify owner of a lock */ 257 0 stevel int32 svid; /* generated from pid for svid */ 258 0 stevel uint64 l_offset; 259 0 stevel uint64 l_len; 260 0 stevel }; 261 0 stevel 262 0 stevel struct nlm4_lockargs { 263 0 stevel netobj cookie; 264 0 stevel bool block; 265 0 stevel bool exclusive; 266 0 stevel struct nlm4_lock alock; 267 0 stevel bool reclaim; /* used for recovering locks */ 268 0 stevel int32 state; /* specify local status monitor state */ 269 0 stevel }; 270 0 stevel 271 0 stevel struct nlm4_cancargs { 272 0 stevel netobj cookie; 273 0 stevel bool block; 274 0 stevel bool exclusive; 275 0 stevel struct nlm4_lock alock; 276 0 stevel }; 277 0 stevel 278 0 stevel struct nlm4_testargs { 279 0 stevel netobj cookie; 280 0 stevel bool exclusive; 281 0 stevel struct nlm4_lock alock; 282 0 stevel }; 283 0 stevel 284 0 stevel struct nlm4_unlockargs { 285 0 stevel netobj cookie; 286 0 stevel struct nlm4_lock alock; 287 0 stevel }; 288 0 stevel 289 0 stevel #ifdef RPC_HDR 290 0 stevel %/* 291 0 stevel % * The following enums are actually bit encoded for efficient 292 0 stevel % * boolean algebra.... DON'T change them..... 293 0 stevel % */ 294 0 stevel #endif 295 0 stevel 296 0 stevel enum fsh4_mode { 297 0 stevel FSM_DN = 0, /* deny none */ 298 0 stevel FSM_DR = 1, /* deny read */ 299 0 stevel FSM_DW = 2, /* deny write */ 300 0 stevel FSM_DRW = 3 /* deny read/write */ 301 0 stevel }; 302 0 stevel 303 0 stevel enum fsh4_access { 304 0 stevel FSA_NONE = 0, /* for completeness */ 305 0 stevel FSA_R = 1, /* read only */ 306 0 stevel FSA_W = 2, /* write only */ 307 0 stevel FSA_RW = 3 /* read/write */ 308 0 stevel }; 309 0 stevel 310 0 stevel struct nlm4_share { 311 0 stevel string caller_name<LM_MAXSTRLEN>; 312 0 stevel netobj fh; 313 0 stevel netobj oh; 314 0 stevel fsh4_mode mode; 315 0 stevel fsh4_access access; 316 0 stevel }; 317 0 stevel 318 0 stevel struct nlm4_shareargs { 319 0 stevel netobj cookie; 320 0 stevel nlm4_share share; 321 0 stevel bool reclaim; 322 0 stevel }; 323 0 stevel 324 0 stevel struct nlm4_shareres { 325 0 stevel netobj cookie; 326 0 stevel nlm4_stats stat; 327 0 stevel int32 sequence; 328 0 stevel }; 329 0 stevel 330 0 stevel struct nlm4_notify { 331 0 stevel string name<LM_MAXNAMELEN>; 332 0 stevel int32 state; 333 0 stevel }; 334 0 stevel 335 0 stevel /* 336 0 stevel * Over-the-wire protocol used between the network lock managers 337 0 stevel */ 338 0 stevel 339 0 stevel program NLM_PROG { 340 0 stevel version NLM_VERS { 341 0 stevel 342 0 stevel nlm_testres 343 0 stevel NLM_TEST(nlm_testargs) = 1; 344 0 stevel 345 0 stevel nlm_res 346 0 stevel NLM_LOCK(nlm_lockargs) = 2; 347 0 stevel 348 0 stevel nlm_res 349 0 stevel NLM_CANCEL(nlm_cancargs) = 3; 350 0 stevel 351 0 stevel nlm_res 352 0 stevel NLM_UNLOCK(nlm_unlockargs) = 4; 353 0 stevel /* 354 0 stevel * remote lock manager call-back to grant lock 355 0 stevel */ 356 0 stevel nlm_res 357 0 stevel NLM_GRANTED(nlm_testargs) = 5; 358 0 stevel 359 0 stevel /* 360 0 stevel * message passing style of requesting lock 361 0 stevel */ 362 0 stevel 363 0 stevel void 364 0 stevel NLM_TEST_MSG(nlm_testargs) = 6; 365 0 stevel void 366 0 stevel NLM_LOCK_MSG(nlm_lockargs) = 7; 367 0 stevel void 368 0 stevel NLM_CANCEL_MSG(nlm_cancargs) = 8; 369 0 stevel void 370 0 stevel NLM_UNLOCK_MSG(nlm_unlockargs) = 9; 371 0 stevel void 372 0 stevel NLM_GRANTED_MSG(nlm_testargs) = 10; 373 0 stevel void 374 0 stevel NLM_TEST_RES(nlm_testres) = 11; 375 0 stevel void 376 0 stevel NLM_LOCK_RES(nlm_res) = 12; 377 0 stevel void 378 0 stevel NLM_CANCEL_RES(nlm_res) = 13; 379 0 stevel void 380 0 stevel NLM_UNLOCK_RES(nlm_res) = 14; 381 0 stevel void 382 0 stevel NLM_GRANTED_RES(nlm_res) = 15; 383 0 stevel } = 1; 384 0 stevel 385 0 stevel version NLM_VERSX { 386 0 stevel nlm_shareres 387 0 stevel NLM_SHARE(nlm_shareargs) = 20; 388 0 stevel nlm_shareres 389 0 stevel NLM_UNSHARE(nlm_shareargs) = 21; 390 0 stevel nlm_res 391 0 stevel NLM_NM_LOCK(nlm_lockargs) = 22; 392 0 stevel void 393 0 stevel NLM_FREE_ALL(nlm_notify) = 23; 394 0 stevel } = 3; 395 0 stevel 396 0 stevel version NLM4_VERS { 397 0 stevel void 398 0 stevel NLMPROC4_NULL(void) = 0; 399 0 stevel nlm4_testres 400 0 stevel NLMPROC4_TEST(nlm4_testargs) = 1; 401 0 stevel nlm4_res 402 0 stevel NLMPROC4_LOCK(nlm4_lockargs) = 2; 403 0 stevel nlm4_res 404 0 stevel NLMPROC4_CANCEL(nlm4_cancargs) = 3; 405 0 stevel nlm4_res 406 0 stevel NLMPROC4_UNLOCK(nlm4_unlockargs) = 4; 407 0 stevel /* 408 0 stevel * remote lock manager call-back to grant lock 409 0 stevel */ 410 0 stevel nlm4_res 411 0 stevel NLMPROC4_GRANTED(nlm4_testargs) = 5; 412 0 stevel 413 0 stevel /* 414 0 stevel * message passing style of requesting lock 415 0 stevel */ 416 0 stevel 417 0 stevel void 418 0 stevel NLMPROC4_TEST_MSG(nlm4_testargs) = 6; 419 0 stevel void 420 0 stevel NLMPROC4_LOCK_MSG(nlm4_lockargs) = 7; 421 0 stevel void 422 0 stevel NLMPROC4_CANCEL_MSG(nlm4_cancargs) = 8; 423 0 stevel void 424 0 stevel NLMPROC4_UNLOCK_MSG(nlm4_unlockargs) = 9; 425 0 stevel void 426 0 stevel NLMPROC4_GRANTED_MSG(nlm4_testargs) = 10; 427 0 stevel void 428 0 stevel NLMPROC4_TEST_RES(nlm4_testres) = 11; 429 0 stevel void 430 0 stevel NLMPROC4_LOCK_RES(nlm4_res) = 12; 431 0 stevel void 432 0 stevel NLMPROC4_CANCEL_RES(nlm4_res) = 13; 433 0 stevel void 434 0 stevel NLMPROC4_UNLOCK_RES(nlm4_res) = 14; 435 0 stevel void 436 0 stevel NLMPROC4_GRANTED_RES(nlm4_res) = 15; 437 0 stevel 438 0 stevel /* 439 0 stevel * DOS-style file sharing 440 0 stevel */ 441 0 stevel 442 0 stevel nlm4_shareres 443 0 stevel NLMPROC4_SHARE(nlm4_shareargs) = 20; 444 0 stevel nlm4_shareres 445 0 stevel NLMPROC4_UNSHARE(nlm4_shareargs) = 21; 446 0 stevel nlm4_res 447 0 stevel NLMPROC4_NM_LOCK(nlm4_lockargs) = 22; 448 0 stevel void 449 0 stevel NLMPROC4_FREE_ALL(nlm4_notify) = 23; 450 0 stevel } = 4; 451 0 stevel 452 0 stevel } = 100021; 453