Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | File: linux/reiserfs_xattr.h |
| 3 | */ |
| 4 | |
| 5 | #include <linux/config.h> |
| 6 | #include <linux/init.h> |
| 7 | #include <linux/xattr.h> |
| 8 | |
| 9 | /* Magic value in header */ |
| 10 | #define REISERFS_XATTR_MAGIC 0x52465841 /* "RFXA" */ |
| 11 | |
| 12 | struct reiserfs_xattr_header { |
Al Viro | 3e8962b | 2005-05-01 08:59:18 -0700 | [diff] [blame] | 13 | __le32 h_magic; /* magic number for identification */ |
| 14 | __le32 h_hash; /* hash of the value */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | }; |
| 16 | |
| 17 | #ifdef __KERNEL__ |
| 18 | |
| 19 | struct reiserfs_xattr_handler { |
| 20 | char *prefix; |
| 21 | int (*init)(void); |
| 22 | void (*exit)(void); |
| 23 | int (*get)(struct inode *inode, const char *name, void *buffer, |
| 24 | size_t size); |
| 25 | int (*set)(struct inode *inode, const char *name, const void *buffer, |
| 26 | size_t size, int flags); |
| 27 | int (*del)(struct inode *inode, const char *name); |
| 28 | int (*list)(struct inode *inode, const char *name, int namelen, char *out); |
| 29 | struct list_head handlers; |
| 30 | }; |
| 31 | |
| 32 | |
| 33 | #ifdef CONFIG_REISERFS_FS_XATTR |
| 34 | #define is_reiserfs_priv_object(inode) IS_PRIVATE(inode) |
| 35 | #define has_xattr_dir(inode) (REISERFS_I(inode)->i_flags & i_has_xattr_dir) |
| 36 | ssize_t reiserfs_getxattr (struct dentry *dentry, const char *name, |
| 37 | void *buffer, size_t size); |
| 38 | int reiserfs_setxattr (struct dentry *dentry, const char *name, |
| 39 | const void *value, size_t size, int flags); |
| 40 | ssize_t reiserfs_listxattr (struct dentry *dentry, char *buffer, size_t size); |
| 41 | int reiserfs_removexattr (struct dentry *dentry, const char *name); |
| 42 | int reiserfs_delete_xattrs (struct inode *inode); |
| 43 | int reiserfs_chown_xattrs (struct inode *inode, struct iattr *attrs); |
| 44 | int reiserfs_xattr_init (struct super_block *sb, int mount_flags); |
| 45 | int reiserfs_permission (struct inode *inode, int mask, struct nameidata *nd); |
| 46 | int reiserfs_permission_locked (struct inode *inode, int mask, struct nameidata *nd); |
| 47 | |
| 48 | int reiserfs_xattr_del (struct inode *, const char *); |
| 49 | int reiserfs_xattr_get (const struct inode *, const char *, void *, size_t); |
| 50 | int reiserfs_xattr_set (struct inode *, const char *, const void *, |
| 51 | size_t, int); |
| 52 | |
| 53 | extern struct reiserfs_xattr_handler user_handler; |
| 54 | extern struct reiserfs_xattr_handler trusted_handler; |
| 55 | #ifdef CONFIG_REISERFS_FS_SECURITY |
| 56 | extern struct reiserfs_xattr_handler security_handler; |
| 57 | #endif |
| 58 | |
| 59 | int reiserfs_xattr_register_handlers (void) __init; |
| 60 | void reiserfs_xattr_unregister_handlers (void); |
| 61 | |
| 62 | static inline void |
| 63 | reiserfs_write_lock_xattrs(struct super_block *sb) |
| 64 | { |
| 65 | down_write (&REISERFS_XATTR_DIR_SEM(sb)); |
| 66 | } |
| 67 | static inline void |
| 68 | reiserfs_write_unlock_xattrs(struct super_block *sb) |
| 69 | { |
| 70 | up_write (&REISERFS_XATTR_DIR_SEM(sb)); |
| 71 | } |
| 72 | static inline void |
| 73 | reiserfs_read_lock_xattrs(struct super_block *sb) |
| 74 | { |
| 75 | down_read (&REISERFS_XATTR_DIR_SEM(sb)); |
| 76 | } |
| 77 | |
| 78 | static inline void |
| 79 | reiserfs_read_unlock_xattrs(struct super_block *sb) |
| 80 | { |
| 81 | up_read (&REISERFS_XATTR_DIR_SEM(sb)); |
| 82 | } |
| 83 | |
| 84 | static inline void |
| 85 | reiserfs_write_lock_xattr_i(struct inode *inode) |
| 86 | { |
| 87 | down_write (&REISERFS_I(inode)->xattr_sem); |
| 88 | } |
| 89 | static inline void |
| 90 | reiserfs_write_unlock_xattr_i(struct inode *inode) |
| 91 | { |
| 92 | up_write (&REISERFS_I(inode)->xattr_sem); |
| 93 | } |
| 94 | static inline void |
| 95 | reiserfs_read_lock_xattr_i(struct inode *inode) |
| 96 | { |
| 97 | down_read (&REISERFS_I(inode)->xattr_sem); |
| 98 | } |
| 99 | |
| 100 | static inline void |
| 101 | reiserfs_read_unlock_xattr_i(struct inode *inode) |
| 102 | { |
| 103 | up_read (&REISERFS_I(inode)->xattr_sem); |
| 104 | } |
| 105 | |
| 106 | static inline void |
| 107 | reiserfs_mark_inode_private(struct inode *inode) |
| 108 | { |
| 109 | inode->i_flags |= S_PRIVATE; |
| 110 | } |
| 111 | |
| 112 | #else |
| 113 | |
| 114 | #define is_reiserfs_priv_object(inode) 0 |
| 115 | #define reiserfs_mark_inode_private(inode) |
| 116 | #define reiserfs_getxattr NULL |
| 117 | #define reiserfs_setxattr NULL |
| 118 | #define reiserfs_listxattr NULL |
| 119 | #define reiserfs_removexattr NULL |
| 120 | #define reiserfs_write_lock_xattrs(sb) |
| 121 | #define reiserfs_write_unlock_xattrs(sb) |
| 122 | #define reiserfs_read_lock_xattrs(sb) |
| 123 | #define reiserfs_read_unlock_xattrs(sb) |
| 124 | |
| 125 | #define reiserfs_permission NULL |
| 126 | |
| 127 | #define reiserfs_xattr_register_handlers() 0 |
| 128 | #define reiserfs_xattr_unregister_handlers() |
| 129 | |
| 130 | static inline int reiserfs_delete_xattrs (struct inode *inode) { return 0; }; |
| 131 | static inline int reiserfs_chown_xattrs (struct inode *inode, struct iattr *attrs) { return 0; }; |
| 132 | static inline int reiserfs_xattr_init (struct super_block *sb, int mount_flags) |
| 133 | { |
| 134 | sb->s_flags = (sb->s_flags & ~MS_POSIXACL); /* to be sure */ |
| 135 | return 0; |
| 136 | }; |
| 137 | #endif |
| 138 | |
| 139 | #endif /* __KERNEL__ */ |