xattr.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. File: linux/ext2_xattr.h
  3. On-disk format of extended attributes for the ext2 filesystem.
  4. (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
  5. */
  6. #include <linux/init.h>
  7. #include <linux/xattr.h>
  8. /* Magic value in attribute blocks */
  9. #define EXT2_XATTR_MAGIC 0xEA020000
  10. /* Maximum number of references to one attribute block */
  11. #define EXT2_XATTR_REFCOUNT_MAX 1024
  12. /* Name indexes */
  13. #define EXT2_XATTR_INDEX_USER 1
  14. #define EXT2_XATTR_INDEX_POSIX_ACL_ACCESS 2
  15. #define EXT2_XATTR_INDEX_POSIX_ACL_DEFAULT 3
  16. #define EXT2_XATTR_INDEX_TRUSTED 4
  17. #define EXT2_XATTR_INDEX_LUSTRE 5
  18. #define EXT2_XATTR_INDEX_SECURITY 6
  19. struct ext2_xattr_header {
  20. __le32 h_magic; /* magic number for identification */
  21. __le32 h_refcount; /* reference count */
  22. __le32 h_blocks; /* number of disk blocks used */
  23. __le32 h_hash; /* hash value of all attributes */
  24. __u32 h_reserved[4]; /* zero right now */
  25. };
  26. struct ext2_xattr_entry {
  27. __u8 e_name_len; /* length of name */
  28. __u8 e_name_index; /* attribute name index */
  29. __le16 e_value_offs; /* offset in disk block of value */
  30. __le32 e_value_block; /* disk block attribute is stored on (n/i) */
  31. __le32 e_value_size; /* size of attribute value */
  32. __le32 e_hash; /* hash value of name and value */
  33. char e_name[0]; /* attribute name */
  34. };
  35. #define EXT2_XATTR_PAD_BITS 2
  36. #define EXT2_XATTR_PAD (1<<EXT2_XATTR_PAD_BITS)
  37. #define EXT2_XATTR_ROUND (EXT2_XATTR_PAD-1)
  38. #define EXT2_XATTR_LEN(name_len) \
  39. (((name_len) + EXT2_XATTR_ROUND + \
  40. sizeof(struct ext2_xattr_entry)) & ~EXT2_XATTR_ROUND)
  41. #define EXT2_XATTR_NEXT(entry) \
  42. ( (struct ext2_xattr_entry *)( \
  43. (char *)(entry) + EXT2_XATTR_LEN((entry)->e_name_len)) )
  44. #define EXT2_XATTR_SIZE(size) \
  45. (((size) + EXT2_XATTR_ROUND) & ~EXT2_XATTR_ROUND)
  46. # ifdef CONFIG_EXT2_FS_XATTR
  47. extern struct xattr_handler ext2_xattr_user_handler;
  48. extern struct xattr_handler ext2_xattr_trusted_handler;
  49. extern struct xattr_handler ext2_xattr_acl_access_handler;
  50. extern struct xattr_handler ext2_xattr_acl_default_handler;
  51. extern struct xattr_handler ext2_xattr_security_handler;
  52. extern ssize_t ext2_listxattr(struct dentry *, char *, size_t);
  53. extern int ext2_xattr_get(struct inode *, int, const char *, void *, size_t);
  54. extern int ext2_xattr_set(struct inode *, int, const char *, const void *, size_t, int);
  55. extern void ext2_xattr_delete_inode(struct inode *);
  56. extern void ext2_xattr_put_super(struct super_block *);
  57. extern int init_ext2_xattr(void);
  58. extern void exit_ext2_xattr(void);
  59. extern struct xattr_handler *ext2_xattr_handlers[];
  60. # else /* CONFIG_EXT2_FS_XATTR */
  61. static inline int
  62. ext2_xattr_get(struct inode *inode, int name_index,
  63. const char *name, void *buffer, size_t size)
  64. {
  65. return -EOPNOTSUPP;
  66. }
  67. static inline int
  68. ext2_xattr_set(struct inode *inode, int name_index, const char *name,
  69. const void *value, size_t size, int flags)
  70. {
  71. return -EOPNOTSUPP;
  72. }
  73. static inline void
  74. ext2_xattr_delete_inode(struct inode *inode)
  75. {
  76. }
  77. static inline void
  78. ext2_xattr_put_super(struct super_block *sb)
  79. {
  80. }
  81. static inline int
  82. init_ext2_xattr(void)
  83. {
  84. return 0;
  85. }
  86. static inline void
  87. exit_ext2_xattr(void)
  88. {
  89. }
  90. #define ext2_xattr_handlers NULL
  91. # endif /* CONFIG_EXT2_FS_XATTR */
  92. #ifdef CONFIG_EXT2_FS_SECURITY
  93. extern int ext2_init_security(struct inode *inode, struct inode *dir);
  94. #else
  95. static inline int ext2_init_security(struct inode *inode, struct inode *dir)
  96. {
  97. return 0;
  98. }
  99. #endif