blob: 5353afb11db391671a6957ac0500f09ca0b12b38 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 */
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070010#define REISERFS_XATTR_MAGIC 0x52465841 /* "RFXA" */
Linus Torvalds1da177e2005-04-16 15:20:36 -070011
12struct reiserfs_xattr_header {
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070013 __le32 h_magic; /* magic number for identification */
14 __le32 h_hash; /* hash of the value */
Linus Torvalds1da177e2005-04-16 15:20:36 -070015};
16
17#ifdef __KERNEL__
18
19struct reiserfs_xattr_handler {
20 char *prefix;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070021 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,
29 char *out);
30 struct list_head handlers;
Linus Torvalds1da177e2005-04-16 15:20:36 -070031};
32
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#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)
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070036ssize_t reiserfs_getxattr(struct dentry *dentry, const char *name,
37 void *buffer, size_t size);
38int reiserfs_setxattr(struct dentry *dentry, const char *name,
39 const void *value, size_t size, int flags);
40ssize_t reiserfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
41int reiserfs_removexattr(struct dentry *dentry, const char *name);
42int reiserfs_delete_xattrs(struct inode *inode);
43int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs);
44int reiserfs_xattr_init(struct super_block *sb, int mount_flags);
45int reiserfs_permission(struct inode *inode, int mask, struct nameidata *nd);
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070047int reiserfs_xattr_del(struct inode *, const char *);
48int reiserfs_xattr_get(const struct inode *, const char *, void *, size_t);
49int reiserfs_xattr_set(struct inode *, const char *, const void *, size_t, int);
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
51extern struct reiserfs_xattr_handler user_handler;
52extern struct reiserfs_xattr_handler trusted_handler;
53#ifdef CONFIG_REISERFS_FS_SECURITY
54extern struct reiserfs_xattr_handler security_handler;
55#endif
56
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070057int reiserfs_xattr_register_handlers(void) __init;
58void reiserfs_xattr_unregister_handlers(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070060static inline void reiserfs_write_lock_xattrs(struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -070061{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070062 down_write(&REISERFS_XATTR_DIR_SEM(sb));
Linus Torvalds1da177e2005-04-16 15:20:36 -070063}
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070064static inline void reiserfs_write_unlock_xattrs(struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -070065{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070066 up_write(&REISERFS_XATTR_DIR_SEM(sb));
Linus Torvalds1da177e2005-04-16 15:20:36 -070067}
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070068static inline void reiserfs_read_lock_xattrs(struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -070069{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070070 down_read(&REISERFS_XATTR_DIR_SEM(sb));
Linus Torvalds1da177e2005-04-16 15:20:36 -070071}
72
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070073static inline void reiserfs_read_unlock_xattrs(struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -070074{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070075 up_read(&REISERFS_XATTR_DIR_SEM(sb));
Linus Torvalds1da177e2005-04-16 15:20:36 -070076}
77
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070078static inline void reiserfs_write_lock_xattr_i(struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -070079{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070080 down_write(&REISERFS_I(inode)->xattr_sem);
Linus Torvalds1da177e2005-04-16 15:20:36 -070081}
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070082static inline void reiserfs_write_unlock_xattr_i(struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -070083{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070084 up_write(&REISERFS_I(inode)->xattr_sem);
Linus Torvalds1da177e2005-04-16 15:20:36 -070085}
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070086static inline void reiserfs_read_lock_xattr_i(struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -070087{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070088 down_read(&REISERFS_I(inode)->xattr_sem);
Linus Torvalds1da177e2005-04-16 15:20:36 -070089}
90
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070091static inline void reiserfs_read_unlock_xattr_i(struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -070092{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070093 up_read(&REISERFS_I(inode)->xattr_sem);
Linus Torvalds1da177e2005-04-16 15:20:36 -070094}
95
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070096static inline void reiserfs_mark_inode_private(struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -070097{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070098 inode->i_flags |= S_PRIVATE;
Linus Torvalds1da177e2005-04-16 15:20:36 -070099}
100
101#else
102
103#define is_reiserfs_priv_object(inode) 0
Vladimir V. Savelievcd02b962006-03-25 03:07:15 -0800104#define reiserfs_mark_inode_private(inode) do {;} while(0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105#define reiserfs_getxattr NULL
106#define reiserfs_setxattr NULL
107#define reiserfs_listxattr NULL
108#define reiserfs_removexattr NULL
Vladimir V. Savelievcd02b962006-03-25 03:07:15 -0800109#define reiserfs_write_lock_xattrs(sb) do {;} while(0)
110#define reiserfs_write_unlock_xattrs(sb) do {;} while(0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111#define reiserfs_read_lock_xattrs(sb)
112#define reiserfs_read_unlock_xattrs(sb)
113
114#define reiserfs_permission NULL
115
116#define reiserfs_xattr_register_handlers() 0
117#define reiserfs_xattr_unregister_handlers()
118
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700119static inline int reiserfs_delete_xattrs(struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700121 return 0;
122};
123static inline int reiserfs_chown_xattrs(struct inode *inode,
124 struct iattr *attrs)
125{
126 return 0;
127};
128static inline int reiserfs_xattr_init(struct super_block *sb, int mount_flags)
129{
130 sb->s_flags = (sb->s_flags & ~MS_POSIXACL); /* to be sure */
131 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132};
133#endif
134
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700135#endif /* __KERNEL__ */