3
0

ext2_ext_attr.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. File: linux/ext2_ext_attr.h
  4. On-disk format of extended attributes for the ext2 filesystem.
  5. (C) 2000 Andreas Gruenbacher, <a.gruenbacher@computer.org>
  6. */
  7. /* Magic value in attribute blocks */
  8. #define EXT2_EXT_ATTR_MAGIC_v1 0xEA010000
  9. #define EXT2_EXT_ATTR_MAGIC 0xEA020000
  10. /* Maximum number of references to one attribute block */
  11. #define EXT2_EXT_ATTR_REFCOUNT_MAX 1024
  12. struct ext2_ext_attr_header {
  13. __u32 h_magic; /* magic number for identification */
  14. __u32 h_refcount; /* reference count */
  15. __u32 h_blocks; /* number of disk blocks used */
  16. __u32 h_hash; /* hash value of all attributes */
  17. __u32 h_reserved[4]; /* zero right now */
  18. };
  19. struct ext2_ext_attr_entry {
  20. __u8 e_name_len; /* length of name */
  21. __u8 e_name_index; /* attribute name index */
  22. __u16 e_value_offs; /* offset in disk block of value */
  23. __u32 e_value_block; /* disk block attribute is stored on (n/i) */
  24. __u32 e_value_size; /* size of attribute value */
  25. __u32 e_hash; /* hash value of name and value */
  26. };
  27. #define EXT2_EXT_ATTR_PAD_BITS 2
  28. #define EXT2_EXT_ATTR_PAD (1<<EXT2_EXT_ATTR_PAD_BITS)
  29. #define EXT2_EXT_ATTR_ROUND (EXT2_EXT_ATTR_PAD-1)
  30. #define EXT2_EXT_ATTR_LEN(name_len) \
  31. (((name_len) + EXT2_EXT_ATTR_ROUND + \
  32. sizeof(struct ext2_ext_attr_entry)) & ~EXT2_EXT_ATTR_ROUND)
  33. #define EXT2_EXT_ATTR_NEXT(entry) \
  34. ( (struct ext2_ext_attr_entry *)( \
  35. (char *)(entry) + EXT2_EXT_ATTR_LEN((entry)->e_name_len)) )
  36. #define EXT2_EXT_ATTR_SIZE(size) \
  37. (((size) + EXT2_EXT_ATTR_ROUND) & ~EXT2_EXT_ATTR_ROUND)
  38. #define EXT2_EXT_IS_LAST_ENTRY(entry) (*((__u32 *)(entry)) == 0UL)
  39. #define EXT2_EXT_ATTR_NAME(entry) \
  40. (((char *) (entry)) + sizeof(struct ext2_ext_attr_entry))
  41. #define EXT2_XATTR_LEN(name_len) \
  42. (((name_len) + EXT2_EXT_ATTR_ROUND + \
  43. sizeof(struct ext2_xattr_entry)) & ~EXT2_EXT_ATTR_ROUND)
  44. #define EXT2_XATTR_SIZE(size) \
  45. (((size) + EXT2_EXT_ATTR_ROUND) & ~EXT2_EXT_ATTR_ROUND)