klm_prot.x 3.7 KB

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