klm_prot.x 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. * Kernel/lock manager protocol definition
  5. * Copyright (C) 1986 Sun Microsystems, 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 Sun Microsystems, 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. const LM_MAXSTRLEN = 1024;
  39. /*
  40. * lock manager status returns
  41. */
  42. enum klm_stats {
  43. klm_granted = 0, /* lock is granted */
  44. klm_denied = 1, /* lock is denied */
  45. klm_denied_nolocks = 2, /* no lock entry available */
  46. klm_working = 3 /* lock is being processed */
  47. };
  48. /*
  49. * lock manager lock identifier
  50. */
  51. struct klm_lock {
  52. string server_name<LM_MAXSTRLEN>;
  53. netobj fh; /* a counted file handle */
  54. int pid; /* holder of the lock */
  55. unsigned l_offset; /* beginning offset of the lock */
  56. unsigned l_len; /* byte length of the lock;
  57. * zero means through end of file */
  58. };
  59. /*
  60. * lock holder identifier
  61. */
  62. struct klm_holder {
  63. bool exclusive; /* FALSE if shared lock */
  64. int svid; /* holder of the lock (pid) */
  65. unsigned l_offset; /* beginning offset of the lock */
  66. unsigned l_len; /* byte length of the lock;
  67. * zero means through end of file */
  68. };
  69. /*
  70. * reply to KLM_LOCK / KLM_UNLOCK / KLM_CANCEL
  71. */
  72. struct klm_stat {
  73. klm_stats stat;
  74. };
  75. /*
  76. * reply to a KLM_TEST call
  77. */
  78. union klm_testrply switch (klm_stats stat) {
  79. case klm_denied:
  80. struct klm_holder holder;
  81. default: /* All other cases return no arguments */
  82. void;
  83. };
  84. /*
  85. * arguments to KLM_LOCK
  86. */
  87. struct klm_lockargs {
  88. bool block;
  89. bool exclusive;
  90. struct klm_lock alock;
  91. };
  92. /*
  93. * arguments to KLM_TEST
  94. */
  95. struct klm_testargs {
  96. bool exclusive;
  97. struct klm_lock alock;
  98. };
  99. /*
  100. * arguments to KLM_UNLOCK
  101. */
  102. struct klm_unlockargs {
  103. struct klm_lock alock;
  104. };
  105. program KLM_PROG {
  106. version KLM_VERS {
  107. klm_testrply KLM_TEST (struct klm_testargs) = 1;
  108. klm_stat KLM_LOCK (struct klm_lockargs) = 2;
  109. klm_stat KLM_CANCEL (struct klm_lockargs) = 3;
  110. /* klm_granted=> the cancel request fails due to lock is already granted */
  111. /* klm_denied=> the cancel request successfully aborts
  112. lock request */
  113. klm_stat KLM_UNLOCK (struct klm_unlockargs) = 4;
  114. } = 1;
  115. } = 100020;