xattr.h 4.0 KB

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