2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
File: linux/reiserfs_xattr.h
|
|
|
|
*/
|
|
|
|
|
2007-02-10 17:46:24 +08:00
|
|
|
#ifndef _LINUX_REISERFS_XATTR_H
|
|
|
|
#define _LINUX_REISERFS_XATTR_H
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Magic value in header */
|
2005-07-13 11:21:28 +08:00
|
|
|
#define REISERFS_XATTR_MAGIC 0x52465841 /* "RFXA" */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
struct reiserfs_xattr_header {
|
2005-07-13 11:21:28 +08:00
|
|
|
__le32 h_magic; /* magic number for identification */
|
|
|
|
__le32 h_hash; /* hash of the value */
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2009-03-31 02:02:41 +08:00
|
|
|
struct reiserfs_security_handle {
|
|
|
|
char *name;
|
|
|
|
void *value;
|
|
|
|
size_t length;
|
|
|
|
};
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#ifdef __KERNEL__
|
2007-02-10 17:46:24 +08:00
|
|
|
|
2006-04-25 21:52:51 +08:00
|
|
|
#include <linux/init.h>
|
2007-02-10 17:46:24 +08:00
|
|
|
#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;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-03-31 02:02:33 +08:00
|
|
|
int reiserfs_xattr_register_handlers(void) __init;
|
|
|
|
void reiserfs_xattr_unregister_handlers(void);
|
|
|
|
int reiserfs_xattr_init(struct super_block *sb, int mount_flags);
|
2009-05-03 18:00:05 +08:00
|
|
|
int reiserfs_lookup_privroot(struct super_block *sb);
|
2009-03-31 02:02:33 +08:00
|
|
|
int reiserfs_delete_xattrs(struct inode *inode);
|
|
|
|
int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs);
|
2011-06-21 07:28:19 +08:00
|
|
|
int reiserfs_permission(struct inode *inode, int mask);
|
2009-03-31 02:02:33 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#ifdef CONFIG_REISERFS_FS_XATTR
|
|
|
|
#define has_xattr_dir(inode) (REISERFS_I(inode)->i_flags & i_has_xattr_dir)
|
2005-07-13 11:21:28 +08:00
|
|
|
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);
|
|
|
|
|
2009-03-31 02:02:38 +08:00
|
|
|
int reiserfs_xattr_get(struct inode *, const char *, void *, size_t);
|
2005-07-13 11:21:28 +08:00
|
|
|
int reiserfs_xattr_set(struct inode *, const char *, const void *, size_t, int);
|
2009-03-31 02:02:39 +08:00
|
|
|
int reiserfs_xattr_set_handle(struct reiserfs_transaction_handle *,
|
|
|
|
struct inode *, const char *, const void *,
|
|
|
|
size_t, int);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-05-14 08:53:19 +08:00
|
|
|
extern const struct xattr_handler reiserfs_xattr_user_handler;
|
|
|
|
extern const struct xattr_handler reiserfs_xattr_trusted_handler;
|
|
|
|
extern const struct xattr_handler reiserfs_xattr_security_handler;
|
2009-03-31 02:02:41 +08:00
|
|
|
#ifdef CONFIG_REISERFS_FS_SECURITY
|
|
|
|
int reiserfs_security_init(struct inode *dir, struct inode *inode,
|
2011-02-02 00:05:39 +08:00
|
|
|
const struct qstr *qstr,
|
2009-03-31 02:02:41 +08:00
|
|
|
struct reiserfs_security_handle *sec);
|
|
|
|
int reiserfs_security_write(struct reiserfs_transaction_handle *th,
|
|
|
|
struct inode *inode,
|
|
|
|
struct reiserfs_security_handle *sec);
|
|
|
|
void reiserfs_security_free(struct reiserfs_security_handle *sec);
|
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-03-24 04:35:38 +08:00
|
|
|
static inline int reiserfs_xattrs_initialized(struct super_block *sb)
|
|
|
|
{
|
|
|
|
return REISERFS_SB(sb)->priv_root != NULL;
|
|
|
|
}
|
|
|
|
|
2009-03-31 02:02:39 +08:00
|
|
|
#define xattr_size(size) ((size) + sizeof(struct reiserfs_xattr_header))
|
|
|
|
static inline loff_t reiserfs_xattr_nblocks(struct inode *inode, loff_t size)
|
|
|
|
{
|
|
|
|
loff_t ret = 0;
|
|
|
|
if (reiserfs_file_data_log(inode)) {
|
|
|
|
ret = _ROUND_UP(xattr_size(size), inode->i_sb->s_blocksize);
|
|
|
|
ret >>= inode->i_sb->s_blocksize_bits;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We may have to create up to 3 objects: xattr root, xattr dir, xattr file.
|
|
|
|
* Let's try to be smart about it.
|
|
|
|
* xattr root: We cache it. If it's not cached, we may need to create it.
|
|
|
|
* xattr dir: If anything has been loaded for this inode, we can set a flag
|
|
|
|
* saying so.
|
|
|
|
* xattr file: Since we don't cache xattrs, we can't tell. We always include
|
|
|
|
* blocks for it.
|
|
|
|
*
|
|
|
|
* However, since root and dir can be created between calls - YOU MUST SAVE
|
|
|
|
* THIS VALUE.
|
|
|
|
*/
|
|
|
|
static inline size_t reiserfs_xattr_jcreate_nblocks(struct inode *inode)
|
|
|
|
{
|
|
|
|
size_t nblocks = JOURNAL_BLOCKS_PER_OBJECT(inode->i_sb);
|
|
|
|
|
|
|
|
if ((REISERFS_I(inode)->i_flags & i_has_xattr_dir) == 0) {
|
|
|
|
nblocks += JOURNAL_BLOCKS_PER_OBJECT(inode->i_sb);
|
2009-05-06 03:30:15 +08:00
|
|
|
if (!REISERFS_SB(inode->i_sb)->xattr_root->d_inode)
|
2009-03-31 02:02:39 +08:00
|
|
|
nblocks += JOURNAL_BLOCKS_PER_OBJECT(inode->i_sb);
|
|
|
|
}
|
|
|
|
|
|
|
|
return nblocks;
|
|
|
|
}
|
|
|
|
|
2006-09-29 16:59:58 +08:00
|
|
|
static inline void reiserfs_init_xattr_rwsem(struct inode *inode)
|
|
|
|
{
|
2009-03-31 02:02:35 +08:00
|
|
|
init_rwsem(&REISERFS_I(inode)->i_xattr_sem);
|
2006-09-29 16:59:58 +08:00
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#else
|
|
|
|
|
|
|
|
#define reiserfs_getxattr NULL
|
|
|
|
#define reiserfs_setxattr NULL
|
|
|
|
#define reiserfs_listxattr NULL
|
|
|
|
#define reiserfs_removexattr NULL
|
|
|
|
|
2006-09-29 16:59:58 +08:00
|
|
|
static inline void reiserfs_init_xattr_rwsem(struct inode *inode)
|
|
|
|
{
|
|
|
|
}
|
2007-02-10 17:46:24 +08:00
|
|
|
#endif /* CONFIG_REISERFS_FS_XATTR */
|
|
|
|
|
2009-03-31 02:02:41 +08:00
|
|
|
#ifndef CONFIG_REISERFS_FS_SECURITY
|
|
|
|
static inline int reiserfs_security_init(struct inode *dir,
|
|
|
|
struct inode *inode,
|
2011-02-02 00:05:39 +08:00
|
|
|
const struct qstr *qstr,
|
2009-03-31 02:02:41 +08:00
|
|
|
struct reiserfs_security_handle *sec)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static inline int
|
|
|
|
reiserfs_security_write(struct reiserfs_transaction_handle *th,
|
|
|
|
struct inode *inode,
|
|
|
|
struct reiserfs_security_handle *sec)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static inline void reiserfs_security_free(struct reiserfs_security_handle *sec)
|
|
|
|
{}
|
|
|
|
#endif
|
|
|
|
|
2007-02-10 17:46:24 +08:00
|
|
|
#endif /* __KERNEL__ */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-10 17:46:24 +08:00
|
|
|
#endif /* _LINUX_REISERFS_XATTR_H */
|