xfs_attr_sf.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. /*
  27. * Entries are packed toward the top as tight as possible.
  28. */
  29. typedef struct xfs_attr_shortform {
  30. struct xfs_attr_sf_hdr { /* constant-structure header block */
  31. __be16 totsize; /* total bytes in shortform list */
  32. __u8 count; /* count of active entries */
  33. } hdr;
  34. struct xfs_attr_sf_entry {
  35. __uint8_t namelen; /* actual length of name (no NULL) */
  36. __uint8_t valuelen; /* actual length of value (no NULL) */
  37. __uint8_t flags; /* flags bits (see xfs_attr_leaf.h) */
  38. __uint8_t nameval[1]; /* name & value bytes concatenated */
  39. } list[1]; /* variable sized array */
  40. } xfs_attr_shortform_t;
  41. typedef struct xfs_attr_sf_hdr xfs_attr_sf_hdr_t;
  42. typedef struct xfs_attr_sf_entry xfs_attr_sf_entry_t;
  43. /*
  44. * We generate this then sort it, attr_list() must return things in hash-order.
  45. */
  46. typedef struct xfs_attr_sf_sort {
  47. __uint8_t entno; /* entry number in original list */
  48. __uint8_t namelen; /* length of name value (no null) */
  49. __uint8_t valuelen; /* length of value */
  50. __uint8_t flags; /* flags bits (see xfs_attr_leaf.h) */
  51. xfs_dahash_t hash; /* this entry's hash value */
  52. unsigned char *name; /* name value, pointer into buffer */
  53. } xfs_attr_sf_sort_t;
  54. #define XFS_ATTR_SF_ENTSIZE_BYNAME(nlen,vlen) /* space name/value uses */ \
  55. (((int)sizeof(xfs_attr_sf_entry_t)-1 + (nlen)+(vlen)))
  56. #define XFS_ATTR_SF_ENTSIZE_MAX /* max space for name&value */ \
  57. ((1 << (NBBY*(int)sizeof(__uint8_t))) - 1)
  58. #define XFS_ATTR_SF_ENTSIZE(sfep) /* space an entry uses */ \
  59. ((int)sizeof(xfs_attr_sf_entry_t)-1 + (sfep)->namelen+(sfep)->valuelen)
  60. #define XFS_ATTR_SF_NEXTENTRY(sfep) /* next entry in struct */ \
  61. ((xfs_attr_sf_entry_t *)((char *)(sfep) + XFS_ATTR_SF_ENTSIZE(sfep)))
  62. #define XFS_ATTR_SF_TOTSIZE(dp) /* total space in use */ \
  63. (be16_to_cpu(((xfs_attr_shortform_t *) \
  64. ((dp)->i_afp->if_u1.if_data))->hdr.totsize))
  65. #endif /* __XFS_ATTR_SF_H__ */