reiserfs_xattr.h 4.1 KB

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