xfs_attr_sf.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
  3. * All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it would be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write the Free Software Foundation,
  16. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef __XFS_ATTR_SF_H__
  19. #define __XFS_ATTR_SF_H__
  20. /*
  21. * Attribute storage when stored inside the inode.
  22. *
  23. * Small attribute lists are packed as tightly as possible so as
  24. * to fit into the literal area of the inode.
  25. */
  26. struct xfs_inode;
  27. /*
  28. * Entries are packed toward the top as tight as possible.
  29. */
  30. typedef struct xfs_attr_shortform {
  31. struct xfs_attr_sf_hdr { /* constant-structure header block */
  32. __be16 totsize; /* total bytes in shortform list */
  33. __u8 count; /* count of active entries */
  34. } hdr;
  35. struct xfs_attr_sf_entry {
  36. __uint8_t namelen; /* actual length of name (no NULL) */
  37. __uint8_t valuelen; /* actual length of value (no NULL) */
  38. __uint8_t flags; /* flags bits (see xfs_attr_leaf.h) */
  39. __uint8_t nameval[1]; /* name & value bytes concatenated */
  40. } list[1]; /* variable sized array */
  41. } xfs_attr_shortform_t;
  42. typedef struct xfs_attr_sf_hdr xfs_attr_sf_hdr_t;
  43. typedef struct xfs_attr_sf_entry xfs_attr_sf_entry_t;
  44. /*
  45. * We generate this then sort it, attr_list() must return things in hash-order.
  46. */
  47. typedef struct xfs_attr_sf_sort {
  48. __uint8_t entno; /* entry number in original list */
  49. __uint8_t namelen; /* length of name value (no null) */
  50. __uint8_t valuelen; /* length of value */
  51. __uint8_t flags; /* flags bits (see xfs_attr_leaf.h) */
  52. xfs_dahash_t hash; /* this entry's hash value */
  53. char *name; /* name value, pointer into buffer */
  54. } xfs_attr_sf_sort_t;
  55. #define XFS_ATTR_SF_ENTSIZE_BYNAME(nlen,vlen) /* space name/value uses */ \
  56. (((int)sizeof(xfs_attr_sf_entry_t)-1 + (nlen)+(vlen)))
  57. #define XFS_ATTR_SF_ENTSIZE_MAX /* max space for name&value */ \
  58. ((1 << (NBBY*(int)sizeof(__uint8_t))) - 1)
  59. #define XFS_ATTR_SF_ENTSIZE(sfep) /* space an entry uses */ \
  60. ((int)sizeof(xfs_attr_sf_entry_t)-1 + (sfep)->namelen+(sfep)->valuelen)
  61. #define XFS_ATTR_SF_NEXTENTRY(sfep) /* next entry in struct */ \
  62. ((xfs_attr_sf_entry_t *)((char *)(sfep) + XFS_ATTR_SF_ENTSIZE(sfep)))
  63. #define XFS_ATTR_SF_TOTSIZE(dp) /* total space in use */ \
  64. (be16_to_cpu(((xfs_attr_shortform_t *) \
  65. ((dp)->i_afp->if_u1.if_data))->hdr.totsize))
  66. #if defined(XFS_ATTR_TRACE)
  67. /*
  68. * Kernel tracing support for attribute lists
  69. */
  70. struct xfs_attr_list_context;
  71. struct xfs_da_intnode;
  72. struct xfs_da_node_entry;
  73. struct xfs_attr_leafblock;
  74. #define XFS_ATTR_TRACE_SIZE 4096 /* size of global trace buffer */
  75. extern ktrace_t *xfs_attr_trace_buf;
  76. /*
  77. * Trace record types.
  78. */
  79. #define XFS_ATTR_KTRACE_L_C 1 /* context */
  80. #define XFS_ATTR_KTRACE_L_CN 2 /* context, node */
  81. #define XFS_ATTR_KTRACE_L_CB 3 /* context, btree */
  82. #define XFS_ATTR_KTRACE_L_CL 4 /* context, leaf */
  83. void xfs_attr_trace_l_c(char *where, struct xfs_attr_list_context *context);
  84. void xfs_attr_trace_l_cn(char *where, struct xfs_attr_list_context *context,
  85. struct xfs_da_intnode *node);
  86. void xfs_attr_trace_l_cb(char *where, struct xfs_attr_list_context *context,
  87. struct xfs_da_node_entry *btree);
  88. void xfs_attr_trace_l_cl(char *where, struct xfs_attr_list_context *context,
  89. struct xfs_attr_leafblock *leaf);
  90. void xfs_attr_trace_enter(int type, char *where,
  91. __psunsigned_t a2, __psunsigned_t a3,
  92. __psunsigned_t a4, __psunsigned_t a5,
  93. __psunsigned_t a6, __psunsigned_t a7,
  94. __psunsigned_t a8, __psunsigned_t a9,
  95. __psunsigned_t a10, __psunsigned_t a11,
  96. __psunsigned_t a12, __psunsigned_t a13,
  97. __psunsigned_t a14, __psunsigned_t a15);
  98. #else
  99. #define xfs_attr_trace_l_c(w,c)
  100. #define xfs_attr_trace_l_cn(w,c,n)
  101. #define xfs_attr_trace_l_cb(w,c,b)
  102. #define xfs_attr_trace_l_cl(w,c,l)
  103. #endif /* XFS_ATTR_TRACE */
  104. #endif /* __XFS_ATTR_SF_H__ */