reiserfs_xattr.h 4.5 KB

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