reiserfs_xattr.h 4.4 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4
/*
  File: linux/reiserfs_xattr.h
*/

5 6 7 8
#ifndef _LINUX_REISERFS_XATTR_H
#define _LINUX_REISERFS_XATTR_H

#include <linux/types.h>
L
Linus Torvalds 已提交
9 10

/* Magic value in header */
11
#define REISERFS_XATTR_MAGIC 0x52465841	/* "RFXA" */
L
Linus Torvalds 已提交
12 13

struct reiserfs_xattr_header {
14 15
	__le32 h_magic;		/* magic number for identification */
	__le32 h_hash;		/* hash of the value */
L
Linus Torvalds 已提交
16 17 18
};

#ifdef __KERNEL__
19

20
#include <linux/init.h>
21 22 23 24 25 26 27 28 29 30
#include <linux/list.h>
#include <linux/rwsem.h>
#include <linux/reiserfs_fs_i.h>
#include <linux/reiserfs_fs.h>

struct inode;
struct dentry;
struct iattr;
struct super_block;
struct nameidata;
L
Linus Torvalds 已提交
31 32 33

struct reiserfs_xattr_handler {
	char *prefix;
34 35 36 37 38 39 40 41 42 43
	int (*init) (void);
	void (*exit) (void);
	int (*get) (struct inode * inode, const char *name, void *buffer,
		    size_t size);
	int (*set) (struct inode * inode, const char *name, const void *buffer,
		    size_t size, int flags);
	int (*del) (struct inode * inode, const char *name);
	int (*list) (struct inode * inode, const char *name, int namelen,
		     char *out);
	struct list_head handlers;
L
Linus Torvalds 已提交
44 45 46 47 48
};

#ifdef CONFIG_REISERFS_FS_XATTR
#define is_reiserfs_priv_object(inode) IS_PRIVATE(inode)
#define has_xattr_dir(inode) (REISERFS_I(inode)->i_flags & i_has_xattr_dir)
49 50 51 52 53 54 55 56 57 58 59 60 61 62
ssize_t reiserfs_getxattr(struct dentry *dentry, const char *name,
			  void *buffer, size_t size);
int reiserfs_setxattr(struct dentry *dentry, const char *name,
		      const void *value, size_t size, int flags);
ssize_t reiserfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
int reiserfs_removexattr(struct dentry *dentry, const char *name);
int reiserfs_delete_xattrs(struct inode *inode);
int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs);
int reiserfs_xattr_init(struct super_block *sb, int mount_flags);
int reiserfs_permission(struct inode *inode, int mask, struct nameidata *nd);

int reiserfs_xattr_del(struct inode *, const char *);
int reiserfs_xattr_get(const struct inode *, const char *, void *, size_t);
int reiserfs_xattr_set(struct inode *, const char *, const void *, size_t, int);
L
Linus Torvalds 已提交
63 64 65 66 67

extern struct reiserfs_xattr_handler user_handler;
extern struct reiserfs_xattr_handler trusted_handler;
extern struct reiserfs_xattr_handler security_handler;

68 69
int reiserfs_xattr_register_handlers(void) __init;
void reiserfs_xattr_unregister_handlers(void);
L
Linus Torvalds 已提交
70

71
static inline void reiserfs_write_lock_xattrs(struct super_block *sb)
L
Linus Torvalds 已提交
72
{
73
	down_write(&REISERFS_XATTR_DIR_SEM(sb));
L
Linus Torvalds 已提交
74
}
75
static inline void reiserfs_write_unlock_xattrs(struct super_block *sb)
L
Linus Torvalds 已提交
76
{
77
	up_write(&REISERFS_XATTR_DIR_SEM(sb));
L
Linus Torvalds 已提交
78
}
79
static inline void reiserfs_read_lock_xattrs(struct super_block *sb)
L
Linus Torvalds 已提交
80
{
81
	down_read(&REISERFS_XATTR_DIR_SEM(sb));
L
Linus Torvalds 已提交
82 83
}

84
static inline void reiserfs_read_unlock_xattrs(struct super_block *sb)
L
Linus Torvalds 已提交
85
{
86
	up_read(&REISERFS_XATTR_DIR_SEM(sb));
L
Linus Torvalds 已提交
87 88
}

89
static inline void reiserfs_write_lock_xattr_i(struct inode *inode)
L
Linus Torvalds 已提交
90
{
91
	down_write(&REISERFS_I(inode)->xattr_sem);
L
Linus Torvalds 已提交
92
}
93
static inline void reiserfs_write_unlock_xattr_i(struct inode *inode)
L
Linus Torvalds 已提交
94
{
95
	up_write(&REISERFS_I(inode)->xattr_sem);
L
Linus Torvalds 已提交
96
}
97
static inline void reiserfs_read_lock_xattr_i(struct inode *inode)
L
Linus Torvalds 已提交
98
{
99
	down_read(&REISERFS_I(inode)->xattr_sem);
L
Linus Torvalds 已提交
100 101
}

102
static inline void reiserfs_read_unlock_xattr_i(struct inode *inode)
L
Linus Torvalds 已提交
103
{
104
	up_read(&REISERFS_I(inode)->xattr_sem);
L
Linus Torvalds 已提交
105 106
}

107
static inline void reiserfs_mark_inode_private(struct inode *inode)
L
Linus Torvalds 已提交
108
{
109
	inode->i_flags |= S_PRIVATE;
L
Linus Torvalds 已提交
110 111
}

112 113 114 115 116
static inline void reiserfs_init_xattr_rwsem(struct inode *inode)
{
	init_rwsem(&REISERFS_I(inode)->xattr_sem);
}

L
Linus Torvalds 已提交
117 118 119
#else

#define is_reiserfs_priv_object(inode) 0
120
#define reiserfs_mark_inode_private(inode) do {;} while(0)
L
Linus Torvalds 已提交
121 122 123 124
#define reiserfs_getxattr NULL
#define reiserfs_setxattr NULL
#define reiserfs_listxattr NULL
#define reiserfs_removexattr NULL
125 126
#define reiserfs_write_lock_xattrs(sb) do {;} while(0)
#define reiserfs_write_unlock_xattrs(sb) do {;} while(0)
L
Linus Torvalds 已提交
127 128 129 130 131 132 133 134
#define reiserfs_read_lock_xattrs(sb)
#define reiserfs_read_unlock_xattrs(sb)

#define reiserfs_permission NULL

#define reiserfs_xattr_register_handlers() 0
#define reiserfs_xattr_unregister_handlers()

135 136 137 138 139 140 141 142 143 144
static inline int reiserfs_delete_xattrs(struct inode *inode)
{
	return 0;
};
static inline int reiserfs_chown_xattrs(struct inode *inode,
					struct iattr *attrs)
{
	return 0;
};
static inline int reiserfs_xattr_init(struct super_block *sb, int mount_flags)
L
Linus Torvalds 已提交
145
{
146 147
	sb->s_flags = (sb->s_flags & ~MS_POSIXACL);	/* to be sure */
	return 0;
L
Linus Torvalds 已提交
148
};
149 150 151
static inline void reiserfs_init_xattr_rwsem(struct inode *inode)
{
}
152 153 154
#endif  /*  CONFIG_REISERFS_FS_XATTR  */

#endif  /*  __KERNEL__  */
L
Linus Torvalds 已提交
155

156
#endif  /*  _LINUX_REISERFS_XATTR_H  */