reiserfs_xattr.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. File: linux/reiserfs_xattr.h
  3. */
  4. #ifndef _LINUX_REISERFS_XATTR_H
  5. #define _LINUX_REISERFS_XATTR_H
  6. #include <linux/types.h>
  7. /* Magic value in header */
  8. #define REISERFS_XATTR_MAGIC 0x52465841 /* "RFXA" */
  9. struct reiserfs_xattr_header {
  10. __le32 h_magic; /* magic number for identification */
  11. __le32 h_hash; /* hash of the value */
  12. };
  13. struct reiserfs_security_handle {
  14. char *name;
  15. void *value;
  16. size_t length;
  17. };
  18. #ifdef __KERNEL__
  19. #include <linux/init.h>
  20. #include <linux/list.h>
  21. #include <linux/rwsem.h>
  22. #include <linux/reiserfs_fs_i.h>
  23. #include <linux/reiserfs_fs.h>
  24. struct inode;
  25. struct dentry;
  26. struct iattr;
  27. struct super_block;
  28. struct nameidata;
  29. int reiserfs_xattr_register_handlers(void) __init;
  30. void reiserfs_xattr_unregister_handlers(void);
  31. int reiserfs_xattr_init(struct super_block *sb, int mount_flags);
  32. int reiserfs_delete_xattrs(struct inode *inode);
  33. int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs);
  34. #ifdef CONFIG_REISERFS_FS_XATTR
  35. #define has_xattr_dir(inode) (REISERFS_I(inode)->i_flags & i_has_xattr_dir)
  36. ssize_t reiserfs_getxattr(struct dentry *dentry, const char *name,
  37. void *buffer, size_t size);
  38. int reiserfs_setxattr(struct dentry *dentry, const char *name,
  39. const void *value, size_t size, int flags);
  40. ssize_t reiserfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
  41. int reiserfs_removexattr(struct dentry *dentry, const char *name);
  42. int reiserfs_permission(struct inode *inode, int mask);
  43. int reiserfs_xattr_get(struct inode *, const char *, void *, size_t);
  44. int reiserfs_xattr_set(struct inode *, const char *, const void *, size_t, int);
  45. int reiserfs_xattr_set_handle(struct reiserfs_transaction_handle *,
  46. struct inode *, const char *, const void *,
  47. size_t, int);
  48. extern struct xattr_handler reiserfs_xattr_user_handler;
  49. extern struct xattr_handler reiserfs_xattr_trusted_handler;
  50. extern struct xattr_handler reiserfs_xattr_security_handler;
  51. #ifdef CONFIG_REISERFS_FS_SECURITY
  52. int reiserfs_security_init(struct inode *dir, struct inode *inode,
  53. struct reiserfs_security_handle *sec);
  54. int reiserfs_security_write(struct reiserfs_transaction_handle *th,
  55. struct inode *inode,
  56. struct reiserfs_security_handle *sec);
  57. void reiserfs_security_free(struct reiserfs_security_handle *sec);
  58. #endif
  59. #define xattr_size(size) ((size) + sizeof(struct reiserfs_xattr_header))
  60. static inline loff_t reiserfs_xattr_nblocks(struct inode *inode, loff_t size)
  61. {
  62. loff_t ret = 0;
  63. if (reiserfs_file_data_log(inode)) {
  64. ret = _ROUND_UP(xattr_size(size), inode->i_sb->s_blocksize);
  65. ret >>= inode->i_sb->s_blocksize_bits;
  66. }
  67. return ret;
  68. }
  69. /* We may have to create up to 3 objects: xattr root, xattr dir, xattr file.
  70. * Let's try to be smart about it.
  71. * xattr root: We cache it. If it's not cached, we may need to create it.
  72. * xattr dir: If anything has been loaded for this inode, we can set a flag
  73. * saying so.
  74. * xattr file: Since we don't cache xattrs, we can't tell. We always include
  75. * blocks for it.
  76. *
  77. * However, since root and dir can be created between calls - YOU MUST SAVE
  78. * THIS VALUE.
  79. */
  80. static inline size_t reiserfs_xattr_jcreate_nblocks(struct inode *inode)
  81. {
  82. size_t nblocks = JOURNAL_BLOCKS_PER_OBJECT(inode->i_sb);
  83. if ((REISERFS_I(inode)->i_flags & i_has_xattr_dir) == 0) {
  84. nblocks += JOURNAL_BLOCKS_PER_OBJECT(inode->i_sb);
  85. if (REISERFS_SB(inode->i_sb)->xattr_root == NULL)
  86. nblocks += JOURNAL_BLOCKS_PER_OBJECT(inode->i_sb);
  87. }
  88. return nblocks;
  89. }
  90. static inline void reiserfs_init_xattr_rwsem(struct inode *inode)
  91. {
  92. init_rwsem(&REISERFS_I(inode)->i_xattr_sem);
  93. }
  94. #else
  95. #define reiserfs_getxattr NULL
  96. #define reiserfs_setxattr NULL
  97. #define reiserfs_listxattr NULL
  98. #define reiserfs_removexattr NULL
  99. #define reiserfs_permission NULL
  100. static inline void reiserfs_init_xattr_rwsem(struct inode *inode)
  101. {
  102. }
  103. #endif /* CONFIG_REISERFS_FS_XATTR */
  104. #ifndef CONFIG_REISERFS_FS_SECURITY
  105. static inline int reiserfs_security_init(struct inode *dir,
  106. struct inode *inode,
  107. struct reiserfs_security_handle *sec)
  108. {
  109. return 0;
  110. }
  111. static inline int
  112. reiserfs_security_write(struct reiserfs_transaction_handle *th,
  113. struct inode *inode,
  114. struct reiserfs_security_handle *sec)
  115. {
  116. return 0;
  117. }
  118. static inline void reiserfs_security_free(struct reiserfs_security_handle *sec)
  119. {}
  120. #endif
  121. #endif /* __KERNEL__ */
  122. #endif /* _LINUX_REISERFS_XATTR_H */