xfs_attr_sf.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. /*
  16. * We generate this then sort it, attr_list() must return things in hash-order.
  17. */
  18. typedef struct xfs_attr_sf_sort {
  19. uint8_t entno; /* entry number in original list */
  20. uint8_t namelen; /* length of name value (no null) */
  21. uint8_t valuelen; /* length of value */
  22. uint8_t flags; /* flags bits (see xfs_attr_leaf.h) */
  23. xfs_dahash_t hash; /* this entry's hash value */
  24. unsigned char *name; /* name value, pointer into buffer */
  25. } xfs_attr_sf_sort_t;
  26. #define XFS_ATTR_SF_ENTSIZE_MAX /* max space for name&value */ \
  27. ((1 << (NBBY*(int)sizeof(uint8_t))) - 1)
  28. /* space name/value uses */
  29. static inline int xfs_attr_sf_entsize_byname(uint8_t nlen, uint8_t vlen)
  30. {
  31. return sizeof(struct xfs_attr_sf_entry) + nlen + vlen;
  32. }
  33. /* space an entry uses */
  34. static inline int xfs_attr_sf_entsize(struct xfs_attr_sf_entry *sfep)
  35. {
  36. return struct_size(sfep, nameval, sfep->namelen + sfep->valuelen);
  37. }
  38. /* next entry in struct */
  39. static inline struct xfs_attr_sf_entry *
  40. xfs_attr_sf_nextentry(struct xfs_attr_sf_entry *sfep)
  41. {
  42. return (void *)sfep + xfs_attr_sf_entsize(sfep);
  43. }
  44. #endif /* __XFS_ATTR_SF_H__ */