1272850Shrs/*-
2272850Shrs * Copyright (c) 2010, Oracle America, Inc.
3272850Shrs *
4272850Shrs * Redistribution and use in source and binary forms, with or without
5272850Shrs * modification, are permitted provided that the following conditions are
6272850Shrs * met:
7272850Shrs *
8272850Shrs *     * Redistributions of source code must retain the above copyright
9272850Shrs *       notice, this list of conditions and the following disclaimer.
10272850Shrs *     * Redistributions in binary form must reproduce the above
11272850Shrs *       copyright notice, this list of conditions and the following
12272850Shrs *       disclaimer in the documentation and/or other materials
13272850Shrs *       provided with the distribution.
14272850Shrs *     * Neither the name of the "Oracle America, Inc." nor the names of its
15272850Shrs *       contributors may be used to endorse or promote products derived
16272850Shrs *       from this software without specific prior written permission.
17272850Shrs *
18272850Shrs *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19272850Shrs *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20272850Shrs *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21272850Shrs *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22272850Shrs *   COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23272850Shrs *   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24272850Shrs *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
25272850Shrs *   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26272850Shrs *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27272850Shrs *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28272850Shrs *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29272850Shrs *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
301832Swollman */
311832Swollman
321832Swollman/*
331832Swollman * Kernel/lock manager protocol definition
341832Swollman * Copyright (C) 1986 Sun Microsystems, Inc.
351832Swollman *
361832Swollman * protocol used between the UNIX kernel (the "client") and the
371832Swollman * local lock manager.  The local lock manager is a deamon running
381832Swollman * above the kernel.
391832Swollman */
401832Swollman
411832Swollman#ifndef RPC_HDR
421832Swollman%#ifndef lint
431832Swollman%/*static char sccsid[] = "from: @(#)klm_prot.x 1.7 87/07/08 Copyr 1987 Sun Micro";*/
441832Swollman%/*static char sccsid[] = "from: @(#)klm_prot.x	2.1 88/08/01 4.0 RPCSRC";*/
451832Swollman%#endif /* not lint */
46114629Sobrien%#include <sys/cdefs.h>
47114629Sobrien%__FBSDID("$FreeBSD: releng/10.2/include/rpcsvc/klm_prot.x 272850 2014-10-09 23:05:32Z hrs $");
481832Swollman#endif
491832Swollman
501832Swollmanconst	LM_MAXSTRLEN = 1024;
511832Swollman
521832Swollman/*
531832Swollman * lock manager status returns
541832Swollman */
551832Swollmanenum klm_stats {
561832Swollman	klm_granted = 0,	/* lock is granted */
571832Swollman	klm_denied = 1,		/* lock is denied */
581832Swollman	klm_denied_nolocks = 2, /* no lock entry available */
591832Swollman	klm_working = 3 	/* lock is being processed */
601832Swollman};
611832Swollman
621832Swollman/*
631832Swollman * lock manager lock identifier
641832Swollman */
651832Swollmanstruct klm_lock {
661832Swollman	string server_name<LM_MAXSTRLEN>;
671832Swollman	netobj fh;		/* a counted file handle */
681832Swollman	int pid;		/* holder of the lock */
691832Swollman	unsigned l_offset;	/* beginning offset of the lock */
701832Swollman	unsigned l_len;		/* byte length of the lock;
711832Swollman				 * zero means through end of file */
721832Swollman};
731832Swollman
741832Swollman/*
751832Swollman * lock holder identifier
761832Swollman */
771832Swollmanstruct klm_holder {
781832Swollman	bool exclusive;		/* FALSE if shared lock */
791832Swollman	int svid;		/* holder of the lock (pid) */
801832Swollman	unsigned l_offset;	/* beginning offset of the lock */
811832Swollman	unsigned l_len;		/* byte length of the lock;
821832Swollman				 * zero means through end of file */
831832Swollman};
841832Swollman
851832Swollman/*
861832Swollman * reply to KLM_LOCK / KLM_UNLOCK / KLM_CANCEL
871832Swollman */
881832Swollmanstruct klm_stat {
891832Swollman	klm_stats stat;
901832Swollman};
911832Swollman
921832Swollman/*
931832Swollman * reply to a KLM_TEST call
941832Swollman */
951832Swollmanunion klm_testrply switch (klm_stats stat) {
961832Swollman	case klm_denied:
971832Swollman		struct klm_holder holder;
981832Swollman	default: /* All other cases return no arguments */
991832Swollman		void;
1001832Swollman};
1011832Swollman
1021832Swollman
1031832Swollman/*
1041832Swollman * arguments to KLM_LOCK
1051832Swollman */
1061832Swollmanstruct klm_lockargs {
1071832Swollman	bool block;
1081832Swollman	bool exclusive;
1091832Swollman	struct klm_lock alock;
1101832Swollman};
1111832Swollman
1121832Swollman/*
1131832Swollman * arguments to KLM_TEST
1141832Swollman */
1151832Swollmanstruct klm_testargs {
1161832Swollman	bool exclusive;
1171832Swollman	struct klm_lock alock;
1181832Swollman};
1191832Swollman
1201832Swollman/*
1211832Swollman * arguments to KLM_UNLOCK
1221832Swollman */
1231832Swollmanstruct klm_unlockargs {
1241832Swollman	struct klm_lock alock;
1251832Swollman};
1261832Swollman
1271832Swollmanprogram KLM_PROG {
1281832Swollman	version KLM_VERS {
1291832Swollman
1301832Swollman		klm_testrply	KLM_TEST (struct klm_testargs) =	1;
1311832Swollman
1321832Swollman		klm_stat	KLM_LOCK (struct klm_lockargs) =	2;
1331832Swollman
1341832Swollman		klm_stat	KLM_CANCEL (struct klm_lockargs) =	3;
1351832Swollman		/* klm_granted=> the cancel request fails due to lock is already granted */
1361832Swollman		/* klm_denied=> the cancel request successfully aborts
1371832Swollmanlock request  */
1381832Swollman
1391832Swollman		klm_stat	KLM_UNLOCK (struct klm_unlockargs) =	4;
1401832Swollman	} = 1;
1411832Swollman} = 100020;
142