xfs_attr_sf.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. * We generate this then sort it, attr_list() must return things in hash-order.
  10. */
  11. typedef struct xfs_attr_sf_sort {
  12. uint8_t entno; /* entry number in original list */
  13. uint8_t namelen; /* length of name value (no null) */
  14. uint8_t valuelen; /* length of value */
  15. uint8_t flags; /* flags bits (see xfs_attr_leaf.h) */
  16. xfs_dahash_t hash; /* this entry's hash value */
  17. unsigned char *name; /* name value, pointer into buffer */
  18. void *value;
  19. } xfs_attr_sf_sort_t;
  20. #define XFS_ATTR_SF_ENTSIZE_MAX /* max space for name&value */ \
  21. ((1 << (NBBY*(int)sizeof(uint8_t))) - 1)
  22. /* space name/value uses */
  23. static inline int xfs_attr_sf_entsize_byname(uint8_t nlen, uint8_t vlen)
  24. {
  25. return sizeof(struct xfs_attr_sf_entry) + nlen + vlen;
  26. }
  27. /* space an entry uses */
  28. static inline int xfs_attr_sf_entsize(struct xfs_attr_sf_entry *sfep)
  29. {
  30. return struct_size(sfep, nameval, sfep->namelen + sfep->valuelen);
  31. }
  32. /* first entry in the SF attr fork */
  33. static inline struct xfs_attr_sf_entry *
  34. xfs_attr_sf_firstentry(struct xfs_attr_sf_hdr *hdr)
  35. {
  36. return (struct xfs_attr_sf_entry *)(hdr + 1);
  37. }
  38. /* next entry after sfep */
  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. /* pointer to the space after the last entry, e.g. for adding a new one */
  45. static inline struct xfs_attr_sf_entry *
  46. xfs_attr_sf_endptr(struct xfs_attr_sf_hdr *sf)
  47. {
  48. return (void *)sf + be16_to_cpu(sf->totsize);
  49. }
  50. #endif /* __XFS_ATTR_SF_H__ */