3
0

ext2_ext_attr.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. File: linux/ext2_ext_attr.h
  3. On-disk format of extended attributes for the ext2 filesystem.
  4. (C) 2000 Andreas Gruenbacher, <a.gruenbacher@computer.org>
  5. */
  6. /* Magic value in attribute blocks */
  7. #define EXT2_EXT_ATTR_MAGIC_v1 0xEA010000
  8. #define EXT2_EXT_ATTR_MAGIC 0xEA020000
  9. /* Maximum number of references to one attribute block */
  10. #define EXT2_EXT_ATTR_REFCOUNT_MAX 1024
  11. struct ext2_ext_attr_header {
  12. __u32 h_magic; /* magic number for identification */
  13. __u32 h_refcount; /* reference count */
  14. __u32 h_blocks; /* number of disk blocks used */
  15. __u32 h_hash; /* hash value of all attributes */
  16. __u32 h_reserved[4]; /* zero right now */
  17. };
  18. struct ext2_ext_attr_entry {
  19. __u8 e_name_len; /* length of name */
  20. __u8 e_name_index; /* attribute name index */
  21. __u16 e_value_offs; /* offset in disk block of value */
  22. __u32 e_value_block; /* disk block attribute is stored on (n/i) */
  23. __u32 e_value_size; /* size of attribute value */
  24. __u32 e_hash; /* hash value of name and value */
  25. #if 0
  26. char e_name[0]; /* attribute name */
  27. #endif
  28. };
  29. #define EXT2_EXT_ATTR_PAD_BITS 2
  30. #define EXT2_EXT_ATTR_PAD (1<<EXT2_EXT_ATTR_PAD_BITS)
  31. #define EXT2_EXT_ATTR_ROUND (EXT2_EXT_ATTR_PAD-1)
  32. #define EXT2_EXT_ATTR_LEN(name_len) \
  33. (((name_len) + EXT2_EXT_ATTR_ROUND + \
  34. sizeof(struct ext2_ext_attr_entry)) & ~EXT2_EXT_ATTR_ROUND)
  35. #define EXT2_EXT_ATTR_NEXT(entry) \
  36. ( (struct ext2_ext_attr_entry *)( \
  37. (char *)(entry) + EXT2_EXT_ATTR_LEN((entry)->e_name_len)) )
  38. #define EXT2_EXT_ATTR_SIZE(size) \
  39. (((size) + EXT2_EXT_ATTR_ROUND) & ~EXT2_EXT_ATTR_ROUND)
  40. #define EXT2_EXT_IS_LAST_ENTRY(entry) (*((__u32 *)(entry)) == 0UL)
  41. #define EXT2_EXT_ATTR_NAME(entry) \
  42. (((char *) (entry)) + sizeof(struct ext2_ext_attr_entry))
  43. #define EXT2_XATTR_LEN(name_len) \
  44. (((name_len) + EXT2_EXT_ATTR_ROUND + \
  45. sizeof(struct ext2_xattr_entry)) & ~EXT2_EXT_ATTR_ROUND)
  46. #define EXT2_XATTR_SIZE(size) \
  47. (((size) + EXT2_EXT_ATTR_ROUND) & ~EXT2_EXT_ATTR_ROUND)
  48. #ifdef __KERNEL__
  49. # ifdef CONFIG_EXT2_FS_EXT_ATTR
  50. extern int ext2_get_ext_attr(struct inode *, const char *, char *, size_t, int);
  51. extern int ext2_set_ext_attr(struct inode *, const char *, char *, size_t, int);
  52. extern void ext2_ext_attr_free_inode(struct inode *inode);
  53. extern void ext2_ext_attr_put_super(struct super_block *sb);
  54. extern int ext2_ext_attr_init(void);
  55. extern void ext2_ext_attr_done(void);
  56. # else
  57. # define ext2_get_ext_attr NULL
  58. # define ext2_set_ext_attr NULL
  59. # endif
  60. #endif /* __KERNEL__ */