blob: 966c35851b2e784a445bac96e1458554ab8784de [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 File: linux/reiserfs_xattr.h
3*/
4
Linus Torvalds1da177e2005-04-16 15:20:36 -07005#include <linux/xattr.h>
6
7/* Magic value in header */
Linus Torvaldsbd4c6252005-07-12 20:21:28 -07008#define REISERFS_XATTR_MAGIC 0x52465841 /* "RFXA" */
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
10struct reiserfs_xattr_header {
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070011 __le32 h_magic; /* magic number for identification */
12 __le32 h_hash; /* hash of the value */
Linus Torvalds1da177e2005-04-16 15:20:36 -070013};
14
15#ifdef __KERNEL__
David Woodhouse98ca79d2006-04-25 14:52:51 +010016#include <linux/init.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
18struct reiserfs_xattr_handler {
19 char *prefix;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070020 int (*init) (void);
21 void (*exit) (void);
22 int (*get) (struct inode * inode, const char *name, void *buffer,
23 size_t size);
24 int (*set) (struct inode * inode, const char *name, const void *buffer,
25 size_t size, int flags);
26 int (*del) (struct inode * inode, const char *name);
27 int (*list) (struct inode * inode, const char *name, int namelen,
28 char *out);
29 struct list_head handlers;
Linus Torvalds1da177e2005-04-16 15:20:36 -070030};
31
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#ifdef CONFIG_REISERFS_FS_XATTR
33#define is_reiserfs_priv_object(inode) IS_PRIVATE(inode)
34#define has_xattr_dir(inode) (REISERFS_I(inode)->i_flags & i_has_xattr_dir)
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070035ssize_t reiserfs_getxattr(struct dentry *dentry, const char *name,
36 void *buffer, size_t size);
37int reiserfs_setxattr(struct dentry *dentry, const char *name,
38 const void *value, size_t size, int flags);
39ssize_t reiserfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
40int reiserfs_removexattr(struct dentry *dentry, const char *name);
41int reiserfs_delete_xattrs(struct inode *inode);
42int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs);
43int reiserfs_xattr_init(struct super_block *sb, int mount_flags);
44int reiserfs_permission(struct inode *inode, int mask, struct nameidata *nd);
Linus Torvalds1da177e2005-04-16 15:20:36 -070045
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070046int reiserfs_xattr_del(struct inode *, const char *);
47int reiserfs_xattr_get(const struct inode *, const char *, void *, size_t);
48int reiserfs_xattr_set(struct inode *, const char *, const void *, size_t, int);
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50extern struct reiserfs_xattr_handler user_handler;
51extern struct reiserfs_xattr_handler trusted_handler;
52#ifdef CONFIG_REISERFS_FS_SECURITY
53extern struct reiserfs_xattr_handler security_handler;
54#endif
55
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070056int reiserfs_xattr_register_handlers(void) __init;
57void reiserfs_xattr_unregister_handlers(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070059static inline void reiserfs_write_lock_xattrs(struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -070060{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070061 down_write(&REISERFS_XATTR_DIR_SEM(sb));
Linus Torvalds1da177e2005-04-16 15:20:36 -070062}
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070063static inline void reiserfs_write_unlock_xattrs(struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -070064{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070065 up_write(&REISERFS_XATTR_DIR_SEM(sb));
Linus Torvalds1da177e2005-04-16 15:20:36 -070066}
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070067static inline void reiserfs_read_lock_xattrs(struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -070068{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070069 down_read(&REISERFS_XATTR_DIR_SEM(sb));
Linus Torvalds1da177e2005-04-16 15:20:36 -070070}
71
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070072static inline void reiserfs_read_unlock_xattrs(struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -070073{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070074 up_read(&REISERFS_XATTR_DIR_SEM(sb));
Linus Torvalds1da177e2005-04-16 15:20:36 -070075}
76
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070077static inline void reiserfs_write_lock_xattr_i(struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -070078{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070079 down_write(&REISERFS_I(inode)->xattr_sem);
Linus Torvalds1da177e2005-04-16 15:20:36 -070080}
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070081static inline void reiserfs_write_unlock_xattr_i(struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -070082{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070083 up_write(&REISERFS_I(inode)->xattr_sem);
Linus Torvalds1da177e2005-04-16 15:20:36 -070084}
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070085static inline void reiserfs_read_lock_xattr_i(struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -070086{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070087 down_read(&REISERFS_I(inode)->xattr_sem);
Linus Torvalds1da177e2005-04-16 15:20:36 -070088}
89
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070090static inline void reiserfs_read_unlock_xattr_i(struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -070091{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070092 up_read(&REISERFS_I(inode)->xattr_sem);
Linus Torvalds1da177e2005-04-16 15:20:36 -070093}
94
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070095static inline void reiserfs_mark_inode_private(struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -070096{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070097 inode->i_flags |= S_PRIVATE;
Linus Torvalds1da177e2005-04-16 15:20:36 -070098}
99
Alexey Dobriyan068fbb32006-09-29 01:59:58 -0700100static inline void reiserfs_init_xattr_rwsem(struct inode *inode)
101{
102 init_rwsem(&REISERFS_I(inode)->xattr_sem);
103}
104
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105#else
106
107#define is_reiserfs_priv_object(inode) 0
Vladimir V. Savelievcd02b962006-03-25 03:07:15 -0800108#define reiserfs_mark_inode_private(inode) do {;} while(0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109#define reiserfs_getxattr NULL
110#define reiserfs_setxattr NULL
111#define reiserfs_listxattr NULL
112#define reiserfs_removexattr NULL
Vladimir V. Savelievcd02b962006-03-25 03:07:15 -0800113#define reiserfs_write_lock_xattrs(sb) do {;} while(0)
114#define reiserfs_write_unlock_xattrs(sb) do {;} while(0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115#define reiserfs_read_lock_xattrs(sb)
116#define reiserfs_read_unlock_xattrs(sb)
117
118#define reiserfs_permission NULL
119
120#define reiserfs_xattr_register_handlers() 0
121#define reiserfs_xattr_unregister_handlers()
122
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700123static inline int reiserfs_delete_xattrs(struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700125 return 0;
126};
127static inline int reiserfs_chown_xattrs(struct inode *inode,
128 struct iattr *attrs)
129{
130 return 0;
131};
132static 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;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136};
Alexey Dobriyan068fbb32006-09-29 01:59:58 -0700137static inline void reiserfs_init_xattr_rwsem(struct inode *inode)
138{
139}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140#endif
141
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700142#endif /* __KERNEL__ */