reiserfs_xattr.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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_lookup_privroot(struct super_block *sb);
  33. int reiserfs_delete_xattrs(struct inode *inode);
  34. int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs);
  35. #ifdef CONFIG_REISERFS_FS_XATTR
  36. #define has_xattr_dir(inode) (REISERFS_I(inode)->i_flags & i_has_xattr_dir)
  37. ssize_t reiserfs_getxattr(struct dentry *dentry, const char *name,
  38. void *buffer, size_t size);
  39. int reiserfs_setxattr(struct dentry *dentry, const char *name,
  40. const void *value, size_t size, int flags);
  41. ssize_t reiserfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
  42. int reiserfs_removexattr(struct dentry *dentry, const char *name);
  43. int reiserfs_permission(struct inode *inode, int mask);
  44. int reiserfs_xattr_get(struct inode *, const char *, void *, size_t);
  45. int reiserfs_xattr_set(struct inode *, const char *, const void *, size_t, int);
  46. int reiserfs_xattr_set_handle(struct reiserfs_transaction_handle *,
  47. struct inode *, const char *, const void *,
  48. size_t, int);
  49. extern struct xattr_handler reiserfs_xattr_user_handler;
  50. extern struct xattr_handler reiserfs_xattr_trusted_handler;
  51. extern struct xattr_handler reiserfs_xattr_security_handler;
  52. #ifdef CONFIG_REISERFS_FS_SECURITY
  53. int reiserfs_security_init(struct inode *dir, struct inode *inode,
  54. struct reiserfs_security_handle *sec);
  55. int reiserfs_security_write(struct reiserfs_transaction_handle *th,
  56. struct inode *inode,
  57. struct reiserfs_security_handle *sec);
  58. void reiserfs_security_free(struct reiserfs_security_handle *sec);
  59. #endif
  60. #define xattr_size(size) ((size) + sizeof(struct reiserfs_xattr_header))
  61. static inline loff_t reiserfs_xattr_nblocks(struct inode *inode, loff_t size)
  62. {
  63. loff_t ret = 0;
  64. if (reiserfs_file_data_log(inode)) {
  65. ret = _ROUND_UP(xattr_size(size), inode->i_sb->s_blocksize);
  66. ret >>= inode->i_sb->s_blocksize_bits;
  67. }
  68. return ret;
  69. }
  70. /* We may have to create up to 3 objects: xattr root, xattr dir, xattr file.
  71. * Let's try to be smart about it.
  72. * xattr root: We cache it. If it's not cached, we may need to create it.
  73. * xattr dir: If anything has been loaded for this inode, we can set a flag
  74. * saying so.
  75. * xattr file: Since we don't cache xattrs, we can't tell. We always include
  76. * blocks for it.
  77. *
  78. * However, since root and dir can be created between calls - YOU MUST SAVE
  79. * THIS VALUE.
  80. */
  81. static inline size_t reiserfs_xattr_jcreate_nblocks(struct inode *inode)
  82. {
  83. size_t nblocks = JOURNAL_BLOCKS_PER_OBJECT(inode->i_sb);
  84. if ((REISERFS_I(inode)->i_flags & i_has_xattr_dir) == 0) {
  85. nblocks += JOURNAL_BLOCKS_PER_OBJECT(inode->i_sb);
  86. if (!REISERFS_SB(inode->i_sb)->xattr_root->d_inode)
  87. nblocks += JOURNAL_BLOCKS_PER_OBJECT(inode->i_sb);
  88. }
  89. return nblocks;
  90. }
  91. static inline void reiserfs_init_xattr_rwsem(struct inode *inode)
  92. {
  93. init_rwsem(&REISERFS_I(inode)->i_xattr_sem);
  94. }
  95. #else
  96. #define reiserfs_getxattr NULL
  97. #define reiserfs_setxattr NULL
  98. #define reiserfs_listxattr NULL
  99. #define reiserfs_removexattr NULL
  100. #define reiserfs_permission NULL
  101. static inline void reiserfs_init_xattr_rwsem(struct inode *inode)
  102. {
  103. }
  104. #endif /* CONFIG_REISERFS_FS_XATTR */
  105. #ifndef CONFIG_REISERFS_FS_SECURITY
  106. static inline int reiserfs_security_init(struct inode *dir,
  107. struct inode *inode,
  108. struct reiserfs_security_handle *sec)
  109. {
  110. return 0;
  111. }
  112. static inline int
  113. reiserfs_security_write(struct reiserfs_transaction_handle *th,
  114. struct inode *inode,
  115. struct reiserfs_security_handle *sec)
  116. {
  117. return 0;
  118. }
  119. static inline void reiserfs_security_free(struct reiserfs_security_handle *sec)
  120. {}
  121. #endif
  122. #endif /* __KERNEL__ */
  123. #endif /* _LINUX_REISERFS_XATTR_H */