reiserfs_xattr.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. #ifdef __KERNEL__
  14. #include <linux/init.h>
  15. #include <linux/list.h>
  16. #include <linux/rwsem.h>
  17. #include <linux/reiserfs_fs_i.h>
  18. #include <linux/reiserfs_fs.h>
  19. struct inode;
  20. struct dentry;
  21. struct iattr;
  22. struct super_block;
  23. struct nameidata;
  24. struct reiserfs_xattr_handler {
  25. char *prefix;
  26. int (*init) (void);
  27. void (*exit) (void);
  28. int (*get) (struct inode * inode, const char *name, void *buffer,
  29. size_t size);
  30. int (*set) (struct inode * inode, const char *name, const void *buffer,
  31. size_t size, int flags);
  32. int (*del) (struct inode * inode, const char *name);
  33. int (*list) (struct inode * inode, const char *name, int namelen,
  34. char *out);
  35. struct list_head handlers;
  36. };
  37. #ifdef CONFIG_REISERFS_FS_XATTR
  38. #define is_reiserfs_priv_object(inode) IS_PRIVATE(inode)
  39. #define has_xattr_dir(inode) (REISERFS_I(inode)->i_flags & i_has_xattr_dir)
  40. ssize_t reiserfs_getxattr(struct dentry *dentry, const char *name,
  41. void *buffer, size_t size);
  42. int reiserfs_setxattr(struct dentry *dentry, const char *name,
  43. const void *value, size_t size, int flags);
  44. ssize_t reiserfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
  45. int reiserfs_removexattr(struct dentry *dentry, const char *name);
  46. int reiserfs_delete_xattrs(struct inode *inode);
  47. int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs);
  48. int reiserfs_xattr_init(struct super_block *sb, int mount_flags);
  49. int reiserfs_permission(struct inode *inode, int mask, struct nameidata *nd);
  50. int reiserfs_xattr_del(struct inode *, const char *);
  51. int reiserfs_xattr_get(const struct inode *, const char *, void *, size_t);
  52. int reiserfs_xattr_set(struct inode *, const char *, const void *, size_t, int);
  53. extern struct reiserfs_xattr_handler user_handler;
  54. extern struct reiserfs_xattr_handler trusted_handler;
  55. extern struct reiserfs_xattr_handler security_handler;
  56. int reiserfs_xattr_register_handlers(void) __init;
  57. void reiserfs_xattr_unregister_handlers(void);
  58. static inline void reiserfs_write_lock_xattrs(struct super_block *sb)
  59. {
  60. down_write(&REISERFS_XATTR_DIR_SEM(sb));
  61. }
  62. static inline void reiserfs_write_unlock_xattrs(struct super_block *sb)
  63. {
  64. up_write(&REISERFS_XATTR_DIR_SEM(sb));
  65. }
  66. static inline void reiserfs_read_lock_xattrs(struct super_block *sb)
  67. {
  68. down_read(&REISERFS_XATTR_DIR_SEM(sb));
  69. }
  70. static inline void reiserfs_read_unlock_xattrs(struct super_block *sb)
  71. {
  72. up_read(&REISERFS_XATTR_DIR_SEM(sb));
  73. }
  74. static inline void reiserfs_write_lock_xattr_i(struct inode *inode)
  75. {
  76. down_write(&REISERFS_I(inode)->xattr_sem);
  77. }
  78. static inline void reiserfs_write_unlock_xattr_i(struct inode *inode)
  79. {
  80. up_write(&REISERFS_I(inode)->xattr_sem);
  81. }
  82. static inline void reiserfs_read_lock_xattr_i(struct inode *inode)
  83. {
  84. down_read(&REISERFS_I(inode)->xattr_sem);
  85. }
  86. static inline void reiserfs_read_unlock_xattr_i(struct inode *inode)
  87. {
  88. up_read(&REISERFS_I(inode)->xattr_sem);
  89. }
  90. static inline void reiserfs_mark_inode_private(struct inode *inode)
  91. {
  92. inode->i_flags |= S_PRIVATE;
  93. }
  94. static inline void reiserfs_init_xattr_rwsem(struct inode *inode)
  95. {
  96. init_rwsem(&REISERFS_I(inode)->xattr_sem);
  97. }
  98. #else
  99. #define is_reiserfs_priv_object(inode) 0
  100. #define reiserfs_mark_inode_private(inode) do {;} while(0)
  101. #define reiserfs_getxattr NULL
  102. #define reiserfs_setxattr NULL
  103. #define reiserfs_listxattr NULL
  104. #define reiserfs_removexattr NULL
  105. #define reiserfs_write_lock_xattrs(sb) do {;} while(0)
  106. #define reiserfs_write_unlock_xattrs(sb) do {;} while(0)
  107. #define reiserfs_read_lock_xattrs(sb)
  108. #define reiserfs_read_unlock_xattrs(sb)
  109. #define reiserfs_permission NULL
  110. #define reiserfs_xattr_register_handlers() 0
  111. #define reiserfs_xattr_unregister_handlers()
  112. static inline int reiserfs_delete_xattrs(struct inode *inode)
  113. {
  114. return 0;
  115. };
  116. static inline int reiserfs_chown_xattrs(struct inode *inode,
  117. struct iattr *attrs)
  118. {
  119. return 0;
  120. };
  121. static inline int reiserfs_xattr_init(struct super_block *sb, int mount_flags)
  122. {
  123. sb->s_flags = (sb->s_flags & ~MS_POSIXACL); /* to be sure */
  124. return 0;
  125. };
  126. static inline void reiserfs_init_xattr_rwsem(struct inode *inode)
  127. {
  128. }
  129. #endif /* CONFIG_REISERFS_FS_XATTR */
  130. #endif /* __KERNEL__ */
  131. #endif /* _LINUX_REISERFS_XATTR_H */