From dbcd7a5fb9d12336fb4a758ff9f3fe57dd21772c Mon Sep 17 00:00:00 2001 From: James Morris Date: Mon, 18 Oct 2004 18:15:51 -0700 Subject: [PATCH] xattr consolidation v3 - generic xattr API This patch consolidates common xattr handling logic into the core fs code, with modifications suggested by Christoph Hellwig (hang off superblock, remove locking, use generic code as methods), for use by ext2, ext3 and devpts, as well as upcoming tmpfs xattr code. Signed-off-by: James Morris Signed-off-by: Stephen Smalley Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/fs.h | 1 + include/linux/xattr.h | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) (limited to 'include') diff --git a/include/linux/fs.h b/include/linux/fs.h index 13e1b4cb7c74..6768655fd11d 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -758,6 +758,7 @@ struct super_block { int s_need_sync_fs; atomic_t s_active; void *s_security; + struct xattr_handler **s_xattr; struct list_head s_dirty; /* dirty inodes */ struct list_head s_io; /* parked for writeback */ diff --git a/include/linux/xattr.h b/include/linux/xattr.h index d9c5d5c83d49..23f9c61d9546 100644 --- a/include/linux/xattr.h +++ b/include/linux/xattr.h @@ -5,6 +5,7 @@ Copyright (C) 2001 by Andreas Gruenbacher Copyright (c) 2001-2002 Silicon Graphics, Inc. All Rights Reserved. + Copyright (c) 2004 Red Hat, Inc., James Morris */ #ifndef _LINUX_XATTR_H #define _LINUX_XATTR_H @@ -14,4 +15,19 @@ #define XATTR_SECURITY_PREFIX "security." +struct xattr_handler { + char *prefix; + size_t (*list)(struct inode *inode, char *list, size_t list_size, + const char *name, size_t name_len); + 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); +}; + +ssize_t generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size); +ssize_t generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size); +int generic_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags); +int generic_removexattr(struct dentry *dentry, const char *name); + #endif /* _LINUX_XATTR_H */ -- cgit v1.2.3