xfs_attr_sf.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
  4. * All Rights Reserved.
  5. */
  6. #ifndef __XFS_ATTR_SF_H__
  7. #define __XFS_ATTR_SF_H__
  8. /*
  9. * Attribute storage when stored inside the inode.
  10. *
  11. * Small attribute lists are packed as tightly as possible so as
  12. * to fit into the literal area of the inode.
  13. */
  14. typedef struct xfs_attr_sf_hdr xfs_attr_sf_hdr_t;
  15. typedef struct xfs_attr_sf_entry xfs_attr_sf_entry_t;
  16. /*
  17. * We generate this then sort it, attr_list() must return things in hash-order.
  18. */
  19. typedef struct xfs_attr_sf_sort {
  20. uint8_t entno; /* entry number in original list */
  21. uint8_t namelen; /* length of name value (no null) */
  22. uint8_t valuelen; /* length of value */
  23. uint8_t flags; /* flags bits (see xfs_attr_leaf.h) */
  24. xfs_dahash_t hash; /* this entry's hash value */
  25. unsigned char *name; /* name value, pointer into buffer */
  26. } xfs_attr_sf_sort_t;
  27. #define XFS_ATTR_SF_ENTSIZE_BYNAME(nlen,vlen) /* space name/value uses */ \
  28. (((int)sizeof(xfs_attr_sf_entry_t)-1 + (nlen)+(vlen)))
  29. #define XFS_ATTR_SF_ENTSIZE_MAX /* max space for name&value */ \
  30. ((1 << (NBBY*(int)sizeof(uint8_t))) - 1)
  31. #define XFS_ATTR_SF_ENTSIZE(sfep) /* space an entry uses */ \
  32. ((int)sizeof(xfs_attr_sf_entry_t)-1 + (sfep)->namelen+(sfep)->valuelen)
  33. #define XFS_ATTR_SF_NEXTENTRY(sfep) /* next entry in struct */ \
  34. ((xfs_attr_sf_entry_t *)((char *)(sfep) + XFS_ATTR_SF_ENTSIZE(sfep)))
  35. #define XFS_ATTR_SF_TOTSIZE(dp) /* total space in use */ \
  36. (be16_to_cpu(((xfs_attr_shortform_t *) \
  37. ((dp)->i_afp->if_u1.if_data))->hdr.totsize))
  38. #endif /* __XFS_ATTR_SF_H__ */