xattr.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. struct mb_cache;
  47. # ifdef CONFIG_EXT2_FS_XATTR
  48. extern const struct xattr_handler ext2_xattr_user_handler;
  49. extern const struct xattr_handler ext2_xattr_trusted_handler;
  50. extern const struct xattr_handler ext2_xattr_security_handler;
  51. extern ssize_t ext2_listxattr(struct dentry *, char *, size_t);
  52. extern int ext2_xattr_get(struct inode *, int, const char *, void *, size_t);
  53. extern int ext2_xattr_set(struct inode *, int, const char *, const void *, size_t, int);
  54. extern void ext2_xattr_delete_inode(struct inode *);
  55. extern struct mb_cache *ext2_xattr_create_cache(void);
  56. extern void ext2_xattr_destroy_cache(struct mb_cache *cache);
  57. extern const struct xattr_handler *ext2_xattr_handlers[];
  58. # else /* CONFIG_EXT2_FS_XATTR */
  59. static inline int
  60. ext2_xattr_get(struct inode *inode, int name_index,
  61. const char *name, void *buffer, size_t size)
  62. {
  63. return -EOPNOTSUPP;
  64. }
  65. static inline int
  66. ext2_xattr_set(struct inode *inode, int name_index, const char *name,
  67. const void *value, size_t size, int flags)
  68. {
  69. return -EOPNOTSUPP;
  70. }
  71. static inline void
  72. ext2_xattr_delete_inode(struct inode *inode)
  73. {
  74. }
  75. static inline void ext2_xattr_destroy_cache(struct mb_cache *cache)
  76. {
  77. }
  78. #define ext2_xattr_handlers NULL
  79. # endif /* CONFIG_EXT2_FS_XATTR */
  80. #ifdef CONFIG_EXT2_FS_SECURITY
  81. extern int ext2_init_security(struct inode *inode, struct inode *dir,
  82. const struct qstr *qstr);
  83. #else
  84. static inline int ext2_init_security(struct inode *inode, struct inode *dir,
  85. const struct qstr *qstr)
  86. {
  87. return 0;
  88. }
  89. #endif