xfs_attr_sf.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * Copyright (c) 2000, 2002 Silicon Graphics, Inc. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of version 2 of the GNU General Public License as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it would be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. *
  12. * Further, this software is distributed without any warranty that it is
  13. * free of the rightful claim of any third person regarding infringement
  14. * or the like. Any license provided herein, whether implied or
  15. * otherwise, applies only to this software file. Patent licenses, if
  16. * any, provided herein do not apply to combinations of this program with
  17. * other software, or any other product whatsoever.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write the Free Software Foundation, Inc., 59
  21. * Temple Place - Suite 330, Boston MA 02111-1307, USA.
  22. *
  23. * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
  24. * Mountain View, CA 94043, or:
  25. *
  26. * http://www.sgi.com
  27. *
  28. * For further information regarding this notice, see:
  29. *
  30. * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
  31. */
  32. #ifndef __XFS_ATTR_SF_H__
  33. #define __XFS_ATTR_SF_H__
  34. /*
  35. * Attribute storage when stored inside the inode.
  36. *
  37. * Small attribute lists are packed as tightly as possible so as
  38. * to fit into the literal area of the inode.
  39. */
  40. struct xfs_inode;
  41. /*
  42. * Entries are packed toward the top as tight as possible.
  43. */
  44. typedef struct xfs_attr_shortform {
  45. struct xfs_attr_sf_hdr { /* constant-structure header block */
  46. __uint16_t totsize; /* total bytes in shortform list */
  47. __uint8_t count; /* count of active entries */
  48. } hdr;
  49. struct xfs_attr_sf_entry {
  50. __uint8_t namelen; /* actual length of name (no NULL) */
  51. __uint8_t valuelen; /* actual length of value (no NULL) */
  52. __uint8_t flags; /* flags bits (see xfs_attr_leaf.h) */
  53. __uint8_t nameval[1]; /* name & value bytes concatenated */
  54. } list[1]; /* variable sized array */
  55. } xfs_attr_shortform_t;
  56. typedef struct xfs_attr_sf_hdr xfs_attr_sf_hdr_t;
  57. typedef struct xfs_attr_sf_entry xfs_attr_sf_entry_t;
  58. /*
  59. * We generate this then sort it, attr_list() must return things in hash-order.
  60. */
  61. typedef struct xfs_attr_sf_sort {
  62. __uint8_t entno; /* entry number in original list */
  63. __uint8_t namelen; /* length of name value (no null) */
  64. __uint8_t valuelen; /* length of value */
  65. __uint8_t flags; /* flags bits (see xfs_attr_leaf.h) */
  66. xfs_dahash_t hash; /* this entry's hash value */
  67. char *name; /* name value, pointer into buffer */
  68. } xfs_attr_sf_sort_t;
  69. #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_SF_ENTSIZE_BYNAME)
  70. int xfs_attr_sf_entsize_byname(int nlen, int vlen);
  71. #define XFS_ATTR_SF_ENTSIZE_BYNAME(nlen,vlen) \
  72. xfs_attr_sf_entsize_byname(nlen,vlen)
  73. #else
  74. #define XFS_ATTR_SF_ENTSIZE_BYNAME(nlen,vlen) /* space name/value uses */ \
  75. ((int)sizeof(xfs_attr_sf_entry_t)-1 + (nlen)+(vlen))
  76. #endif
  77. #define XFS_ATTR_SF_ENTSIZE_MAX /* max space for name&value */ \
  78. ((1 << (NBBY*(int)sizeof(__uint8_t))) - 1)
  79. #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_SF_ENTSIZE)
  80. int xfs_attr_sf_entsize(xfs_attr_sf_entry_t *sfep);
  81. #define XFS_ATTR_SF_ENTSIZE(sfep) xfs_attr_sf_entsize(sfep)
  82. #else
  83. #define XFS_ATTR_SF_ENTSIZE(sfep) /* space an entry uses */ \
  84. ((int)sizeof(xfs_attr_sf_entry_t)-1 + (sfep)->namelen+(sfep)->valuelen)
  85. #endif
  86. #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_SF_NEXTENTRY)
  87. xfs_attr_sf_entry_t *xfs_attr_sf_nextentry(xfs_attr_sf_entry_t *sfep);
  88. #define XFS_ATTR_SF_NEXTENTRY(sfep) xfs_attr_sf_nextentry(sfep)
  89. #else
  90. #define XFS_ATTR_SF_NEXTENTRY(sfep) /* next entry in struct */ \
  91. ((xfs_attr_sf_entry_t *) \
  92. ((char *)(sfep) + XFS_ATTR_SF_ENTSIZE(sfep)))
  93. #endif
  94. #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_ATTR_SF_TOTSIZE)
  95. int xfs_attr_sf_totsize(struct xfs_inode *dp);
  96. #define XFS_ATTR_SF_TOTSIZE(dp) xfs_attr_sf_totsize(dp)
  97. #else
  98. #define XFS_ATTR_SF_TOTSIZE(dp) /* total space in use */ \
  99. (INT_GET(((xfs_attr_shortform_t *)((dp)->i_afp->if_u1.if_data))->hdr.totsize, ARCH_CONVERT))
  100. #endif
  101. #if defined(XFS_ATTR_TRACE)
  102. /*
  103. * Kernel tracing support for attribute lists
  104. */
  105. struct xfs_attr_list_context;
  106. struct xfs_da_intnode;
  107. struct xfs_da_node_entry;
  108. struct xfs_attr_leafblock;
  109. #define XFS_ATTR_TRACE_SIZE 4096 /* size of global trace buffer */
  110. extern ktrace_t *xfs_attr_trace_buf;
  111. /*
  112. * Trace record types.
  113. */
  114. #define XFS_ATTR_KTRACE_L_C 1 /* context */
  115. #define XFS_ATTR_KTRACE_L_CN 2 /* context, node */
  116. #define XFS_ATTR_KTRACE_L_CB 3 /* context, btree */
  117. #define XFS_ATTR_KTRACE_L_CL 4 /* context, leaf */
  118. void xfs_attr_trace_l_c(char *where, struct xfs_attr_list_context *context);
  119. void xfs_attr_trace_l_cn(char *where, struct xfs_attr_list_context *context,
  120. struct xfs_da_intnode *node);
  121. void xfs_attr_trace_l_cb(char *where, struct xfs_attr_list_context *context,
  122. struct xfs_da_node_entry *btree);
  123. void xfs_attr_trace_l_cl(char *where, struct xfs_attr_list_context *context,
  124. struct xfs_attr_leafblock *leaf);
  125. void xfs_attr_trace_enter(int type, char *where,
  126. __psunsigned_t a2, __psunsigned_t a3,
  127. __psunsigned_t a4, __psunsigned_t a5,
  128. __psunsigned_t a6, __psunsigned_t a7,
  129. __psunsigned_t a8, __psunsigned_t a9,
  130. __psunsigned_t a10, __psunsigned_t a11,
  131. __psunsigned_t a12, __psunsigned_t a13,
  132. __psunsigned_t a14, __psunsigned_t a15);
  133. #else
  134. #define xfs_attr_trace_l_c(w,c)
  135. #define xfs_attr_trace_l_cn(w,c,n)
  136. #define xfs_attr_trace_l_cb(w,c,b)
  137. #define xfs_attr_trace_l_cl(w,c,l)
  138. #endif /* XFS_ATTR_TRACE */
  139. #endif /* __XFS_ATTR_SF_H__ */