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