HardenedBSD src tree
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

181 lines
5.1KB

  1. /*-
  2. * SPDX-License-Identifier: BSD-3-Clause
  3. *
  4. * Copyright (c) 1989, 1993
  5. * The Regents of the University of California. All rights reserved.
  6. *
  7. * This code is derived from software contributed to Berkeley by
  8. * Rick Macklem at The University of Guelph.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in the
  17. * documentation and/or other materials provided with the distribution.
  18. * 3. Neither the name of the University nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  23. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  28. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  29. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  31. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  32. * SUCH DAMAGE.
  33. *
  34. * @(#)nfsm_subs.h 8.2 (Berkeley) 3/30/95
  35. * $FreeBSD$
  36. */
  37. #ifndef _NFSCLIENT_NFSM_SUBS_H_
  38. #define _NFSCLIENT_NFSM_SUBS_H_
  39. #include <nfs/nfs_common.h>
  40. #define nfsv2tov_type(a) nv2tov_type[fxdr_unsigned(u_int32_t,(a))&0x7]
  41. struct ucred;
  42. struct vnode;
  43. /*
  44. * These macros do strange and peculiar things to mbuf chains for
  45. * the assistance of the nfs code. To attempt to use them for any
  46. * other purpose will be dangerous. (they make weird assumptions)
  47. */
  48. /*
  49. * First define what the actual subs. return
  50. */
  51. u_int32_t nfs_xid_gen(void);
  52. /* *********************************** */
  53. /* Request generation phase macros */
  54. int nfsm_fhtom_xx(struct vnode *v, int v3, struct mbuf **mb,
  55. caddr_t *bpos);
  56. void nfsm_v3attrbuild_xx(struct vattr *va, int full, struct mbuf **mb,
  57. caddr_t *bpos);
  58. int nfsm_strtom_xx(const char *a, int s, int m, struct mbuf **mb,
  59. caddr_t *bpos);
  60. #define nfsm_bcheck(t1, mreq) \
  61. do { \
  62. if (t1) { \
  63. error = t1; \
  64. m_freem(mreq); \
  65. goto nfsmout; \
  66. } \
  67. } while (0)
  68. #define nfsm_fhtom(v, v3) \
  69. do { \
  70. int32_t t1; \
  71. t1 = nfsm_fhtom_xx((v), (v3), &mb, &bpos); \
  72. nfsm_bcheck(t1, mreq); \
  73. } while (0)
  74. /* If full is true, set all fields, otherwise just set mode and time fields */
  75. #define nfsm_v3attrbuild(a, full) \
  76. nfsm_v3attrbuild_xx(a, full, &mb, &bpos)
  77. #define nfsm_uiotom(p, s) \
  78. do { \
  79. int t1; \
  80. t1 = nfsm_uiotombuf((p), &mb, (s), &bpos); \
  81. nfsm_bcheck(t1, mreq); \
  82. } while (0)
  83. #define nfsm_strtom(a, s, m) \
  84. do { \
  85. int t1; \
  86. t1 = nfsm_strtom_xx((a), (s), (m), &mb, &bpos); \
  87. nfsm_bcheck(t1, mreq); \
  88. } while (0)
  89. /* *********************************** */
  90. /* Send the request */
  91. #define nfsm_request(v, t, p, c) \
  92. do { \
  93. sigset_t oldset; \
  94. nfs_set_sigmask(p, &oldset); \
  95. error = nfs_request((v), mreq, (t), (p), (c), &mrep, &md, &dpos); \
  96. nfs_restore_sigmask(p, &oldset); \
  97. if (error != 0) { \
  98. if (error & NFSERR_RETERR) \
  99. error &= ~NFSERR_RETERR; \
  100. else \
  101. goto nfsmout; \
  102. } \
  103. } while (0)
  104. /* *********************************** */
  105. /* Reply interpretation phase macros */
  106. int nfsm_mtofh_xx(struct vnode *d, struct vnode **v, int v3, int *f,
  107. struct mbuf **md, caddr_t *dpos);
  108. int nfsm_getfh_xx(nfsfh_t **f, int *s, int v3, struct mbuf **md,
  109. caddr_t *dpos);
  110. int nfsm_loadattr_xx(struct vnode **v, struct vattr *va, struct mbuf **md,
  111. caddr_t *dpos);
  112. int nfsm_postop_attr_xx(struct vnode **v, int *f, struct vattr *va,
  113. struct mbuf **md, caddr_t *dpos);
  114. int nfsm_wcc_data_xx(struct vnode **v, int *f, struct mbuf **md,
  115. caddr_t *dpos);
  116. #define nfsm_mtofh(d, v, v3, f) \
  117. do { \
  118. int32_t t1; \
  119. t1 = nfsm_mtofh_xx((d), &(v), (v3), &(f), &md, &dpos); \
  120. nfsm_dcheck(t1, mrep); \
  121. } while (0)
  122. #define nfsm_getfh(f, s, v3) \
  123. do { \
  124. int32_t t1; \
  125. t1 = nfsm_getfh_xx(&(f), &(s), (v3), &md, &dpos); \
  126. nfsm_dcheck(t1, mrep); \
  127. } while (0)
  128. #define nfsm_loadattr(v, a) \
  129. do { \
  130. int32_t t1; \
  131. t1 = nfsm_loadattr_xx(&v, a, &md, &dpos); \
  132. nfsm_dcheck(t1, mrep); \
  133. } while (0)
  134. #define nfsm_postop_attr(v, f) \
  135. do { \
  136. int32_t t1; \
  137. t1 = nfsm_postop_attr_xx(&v, &f, NULL, &md, &dpos); \
  138. nfsm_dcheck(t1, mrep); \
  139. } while (0)
  140. #define nfsm_postop_attr_va(v, f, va) \
  141. do { \
  142. int32_t t1; \
  143. t1 = nfsm_postop_attr_xx(&v, &f, va, &md, &dpos); \
  144. nfsm_dcheck(t1, mrep); \
  145. } while (0)
  146. /* Used as (f) for nfsm_wcc_data() */
  147. #define NFSV3_WCCRATTR 0
  148. #define NFSV3_WCCCHK 1
  149. #define nfsm_wcc_data(v, f) \
  150. do { \
  151. int32_t t1; \
  152. t1 = nfsm_wcc_data_xx(&v, &f, &md, &dpos); \
  153. nfsm_dcheck(t1, mrep); \
  154. } while (0)
  155. #endif