xattr.h 4.0 KB

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