NFSv4: Add {get,set,list}xattr methods for nfs4 Add {get,set,list}xattr methods for nfs4. The new methods are no-ops, to be used by subsequent ACL patch. Signed-off-by: J. Bruce Fields Signed-off-by: Trond Myklebust --- dir.c | 3 +++ file.c | 14 ++++++++++++++ inode.c | 31 ++++++++++++++++++++++++++++++- nfs4_fs.h | 7 +++++++ nfs4proc.c | 2 +- 5 files changed, 55 insertions(+), 2 deletions(-) Index: linux-2.6.11/fs/nfs/dir.c =================================================================== --- linux-2.6.11.orig/fs/nfs/dir.c +++ linux-2.6.11/fs/nfs/dir.c @@ -91,6 +91,9 @@ struct inode_operations nfs4_dir_inode_o .permission = nfs_permission, .getattr = nfs_getattr, .setattr = nfs_setattr, + .getxattr = nfs4_getxattr, + .setxattr = nfs4_setxattr, + .listxattr = nfs4_listxattr, }; #endif /* CONFIG_NFS_V4 */ Index: linux-2.6.11/fs/nfs/file.c =================================================================== --- linux-2.6.11.orig/fs/nfs/file.c +++ linux-2.6.11/fs/nfs/file.c @@ -31,6 +31,7 @@ #include #include +#include "nfs4_fs.h" #include "delegation.h" #define NFSDBG_FACILITY NFSDBG_FILE @@ -70,6 +71,19 @@ struct inode_operations nfs_file_inode_o .setattr = nfs_setattr, }; +#ifdef CONFIG_NFS_V4 + +struct inode_operations nfs4_file_inode_operations = { + .permission = nfs_permission, + .getattr = nfs_getattr, + .setattr = nfs_setattr, + .getxattr = nfs4_getxattr, + .setxattr = nfs4_setxattr, + .listxattr = nfs4_listxattr, +}; + +#endif /* CONFIG_NFS_V4 */ + /* Hack for future NFS swap support */ #ifndef IS_SWAPFILE # define IS_SWAPFILE(inode) (0) Index: linux-2.6.11/fs/nfs/inode.c =================================================================== --- linux-2.6.11.orig/fs/nfs/inode.c +++ linux-2.6.11/fs/nfs/inode.c @@ -1496,8 +1496,37 @@ static struct file_system_type nfs_fs_ty #ifdef CONFIG_NFS_V4 -static void nfs4_clear_inode(struct inode *); +int +nfs4_setxattr(struct dentry *dentry, const char *key, const void *buf, + size_t buflen, int flags) +{ + return -EOPNOTSUPP; +} + +/* The getxattr man page suggests returning -ENODATA for unknown attributes, + * and that's what we'll do for e.g. user attributes that haven't been set. + * But we'll follow ext2/ext3's lead by returning -EOPNOTSUPP for unsupported + * attributes in kernel-managed attribute namespaces. */ +ssize_t +nfs4_getxattr(struct dentry *dentry, const char *key, void *buf, + size_t buflen) +{ + return -EOPNOTSUPP; +} +ssize_t +nfs4_listxattr(struct dentry *dentry, char *buf, size_t buflen) +{ + ssize_t len = 0; + + if (buf && buflen < len) + return -ERANGE; + if (buf) + memcpy(buf, "", 0); + return 0; +} + +static void nfs4_clear_inode(struct inode *); static struct super_operations nfs4_sops = { .alloc_inode = nfs_alloc_inode, Index: linux-2.6.11/fs/nfs/nfs4proc.c =================================================================== --- linux-2.6.11.orig/fs/nfs/nfs4proc.c +++ linux-2.6.11/fs/nfs/nfs4proc.c @@ -2746,7 +2746,7 @@ struct nfs_rpc_ops nfs_v4_clientops = { .version = 4, /* protocol version */ .dentry_ops = &nfs4_dentry_operations, .dir_inode_ops = &nfs4_dir_inode_operations, - .file_inode_ops = &nfs_file_inode_operations, + .file_inode_ops = &nfs4_file_inode_operations, .getroot = nfs4_proc_get_root, .getattr = nfs4_proc_getattr, .setattr = nfs4_proc_setattr, Index: linux-2.6.11/fs/nfs/nfs4_fs.h =================================================================== --- linux-2.6.11.orig/fs/nfs/nfs4_fs.h +++ linux-2.6.11/fs/nfs/nfs4_fs.h @@ -176,6 +176,13 @@ struct nfs4_state_recovery_ops { extern struct dentry_operations nfs4_dentry_operations; extern struct inode_operations nfs4_dir_inode_operations; +extern struct inode_operations nfs4_file_inode_operations; + +/* inode.c */ +extern ssize_t nfs4_getxattr(struct dentry *, const char *, void *, size_t); +extern int nfs4_setxattr(struct dentry *, const char *, const void *, size_t, int); +extern ssize_t nfs4_listxattr(struct dentry *, char *, size_t); + /* nfs4proc.c */ extern int nfs4_map_errors(int err);