xattr.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. File: fs/ext3/xattr.h
  3. On-disk format of extended attributes for the ext3 filesystem.
  4. (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
  5. */
  6. #include <linux/xattr.h>
  7. /* Magic value in attribute blocks */
  8. #define EXT3_XATTR_MAGIC 0xEA020000
  9. /* Maximum number of references to one attribute block */
  10. #define EXT3_XATTR_REFCOUNT_MAX 1024
  11. /* Name indexes */
  12. #define EXT3_XATTR_INDEX_USER 1
  13. #define EXT3_XATTR_INDEX_POSIX_ACL_ACCESS 2
  14. #define EXT3_XATTR_INDEX_POSIX_ACL_DEFAULT 3
  15. #define EXT3_XATTR_INDEX_TRUSTED 4
  16. #define EXT3_XATTR_INDEX_LUSTRE 5
  17. #define EXT3_XATTR_INDEX_SECURITY 6
  18. struct ext3_xattr_header {
  19. __le32 h_magic; /* magic number for identification */
  20. __le32 h_refcount; /* reference count */
  21. __le32 h_blocks; /* number of disk blocks used */
  22. __le32 h_hash; /* hash value of all attributes */
  23. __u32 h_reserved[4]; /* zero right now */
  24. };
  25. struct ext3_xattr_ibody_header {
  26. __le32 h_magic; /* magic number for identification */
  27. };
  28. struct ext3_xattr_entry {
  29. __u8 e_name_len; /* length of name */
  30. __u8 e_name_index; /* attribute name index */
  31. __le16 e_value_offs; /* offset in disk block of value */
  32. __le32 e_value_block; /* disk block attribute is stored on (n/i) */
  33. __le32 e_value_size; /* size of attribute value */
  34. __le32 e_hash; /* hash value of name and value */
  35. char e_name[0]; /* attribute name */
  36. };
  37. #define EXT3_XATTR_PAD_BITS 2
  38. #define EXT3_XATTR_PAD (1<<EXT3_XATTR_PAD_BITS)
  39. #define EXT3_XATTR_ROUND (EXT3_XATTR_PAD-1)
  40. #define EXT3_XATTR_LEN(name_len) \
  41. (((name_len) + EXT3_XATTR_ROUND + \
  42. sizeof(struct ext3_xattr_entry)) & ~EXT3_XATTR_ROUND)
  43. #define EXT3_XATTR_NEXT(entry) \
  44. ( (struct ext3_xattr_entry *)( \
  45. (char *)(entry) + EXT3_XATTR_LEN((entry)->e_name_len)) )
  46. #define EXT3_XATTR_SIZE(size) \
  47. (((size) + EXT3_XATTR_ROUND) & ~EXT3_XATTR_ROUND)
  48. # ifdef CONFIG_EXT3_FS_XATTR
  49. extern const struct xattr_handler ext3_xattr_user_handler;
  50. extern const struct xattr_handler ext3_xattr_trusted_handler;
  51. extern const struct xattr_handler ext3_xattr_acl_access_handler;
  52. extern const struct xattr_handler ext3_xattr_acl_default_handler;
  53. extern const struct xattr_handler ext3_xattr_security_handler;
  54. extern ssize_t ext3_listxattr(struct dentry *, char *, size_t);
  55. extern int ext3_xattr_get(struct inode *, int, const char *, void *, size_t);
  56. extern int ext3_xattr_set(struct inode *, int, const char *, const void *, size_t, int);
  57. extern int ext3_xattr_set_handle(handle_t *, struct inode *, int, const char *, const void *, size_t, int);
  58. extern void ext3_xattr_delete_inode(handle_t *, struct inode *);
  59. extern void ext3_xattr_put_super(struct super_block *);
  60. extern int init_ext3_xattr(void);
  61. extern void exit_ext3_xattr(void);
  62. extern const struct xattr_handler *ext3_xattr_handlers[];
  63. # else /* CONFIG_EXT3_FS_XATTR */
  64. static inline int
  65. ext3_xattr_get(struct inode *inode, int name_index, const char *name,
  66. void *buffer, size_t size, int flags)
  67. {
  68. return -EOPNOTSUPP;
  69. }
  70. static inline int
  71. ext3_xattr_set(struct inode *inode, int name_index, const char *name,
  72. const void *value, size_t size, int flags)
  73. {
  74. return -EOPNOTSUPP;
  75. }
  76. static inline int
  77. ext3_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
  78. const char *name, const void *value, size_t size, int flags)
  79. {
  80. return -EOPNOTSUPP;
  81. }
  82. static inline void
  83. ext3_xattr_delete_inode(handle_t *handle, struct inode *inode)
  84. {
  85. }
  86. static inline void
  87. ext3_xattr_put_super(struct super_block *sb)
  88. {
  89. }
  90. static inline int
  91. init_ext3_xattr(void)
  92. {
  93. return 0;
  94. }
  95. static inline void
  96. exit_ext3_xattr(void)
  97. {
  98. }
  99. #define ext3_xattr_handlers NULL
  100. # endif /* CONFIG_EXT3_FS_XATTR */
  101. #ifdef CONFIG_EXT3_FS_SECURITY
  102. extern int ext3_init_security(handle_t *handle, struct inode *inode,
  103. struct inode *dir, const struct qstr *qstr);
  104. #else
  105. static inline int ext3_init_security(handle_t *handle, struct inode *inode,
  106. struct inode *dir, const struct qstr *qstr)
  107. {
  108. return 0;
  109. }
  110. #endif