xattr.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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_security_handler;
  52. extern ssize_t ext3_listxattr(struct dentry *, char *, size_t);
  53. extern int ext3_xattr_get(struct inode *, int, const char *, void *, size_t);
  54. extern int ext3_xattr_set(struct inode *, int, const char *, const void *, size_t, int);
  55. extern int ext3_xattr_set_handle(handle_t *, struct inode *, int, const char *, const void *, size_t, int);
  56. extern void ext3_xattr_delete_inode(handle_t *, struct inode *);
  57. extern void ext3_xattr_put_super(struct super_block *);
  58. extern int init_ext3_xattr(void);
  59. extern void exit_ext3_xattr(void);
  60. extern const struct xattr_handler *ext3_xattr_handlers[];
  61. # else /* CONFIG_EXT3_FS_XATTR */
  62. static inline int
  63. ext3_xattr_get(struct inode *inode, int name_index, const char *name,
  64. void *buffer, size_t size, int flags)
  65. {
  66. return -EOPNOTSUPP;
  67. }
  68. static inline int
  69. ext3_xattr_set(struct inode *inode, int name_index, const char *name,
  70. const void *value, size_t size, int flags)
  71. {
  72. return -EOPNOTSUPP;
  73. }
  74. static inline int
  75. ext3_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
  76. const char *name, const void *value, size_t size, int flags)
  77. {
  78. return -EOPNOTSUPP;
  79. }
  80. static inline void
  81. ext3_xattr_delete_inode(handle_t *handle, struct inode *inode)
  82. {
  83. }
  84. static inline void
  85. ext3_xattr_put_super(struct super_block *sb)
  86. {
  87. }
  88. static inline int
  89. init_ext3_xattr(void)
  90. {
  91. return 0;
  92. }
  93. static inline void
  94. exit_ext3_xattr(void)
  95. {
  96. }
  97. #define ext3_xattr_handlers NULL
  98. # endif /* CONFIG_EXT3_FS_XATTR */
  99. #ifdef CONFIG_EXT3_FS_SECURITY
  100. extern int ext3_init_security(handle_t *handle, struct inode *inode,
  101. struct inode *dir, const struct qstr *qstr);
  102. #else
  103. static inline int ext3_init_security(handle_t *handle, struct inode *inode,
  104. struct inode *dir, const struct qstr *qstr)
  105. {
  106. return 0;
  107. }
  108. #endif