aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4proc.c
diff options
context:
space:
mode:
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2010-12-09 06:35:25 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2011-01-04 13:10:41 -0500
commit64c2ce8b72eceec4030b04bca32d098b3d1431bb (patch)
treed296c9282da04017457e44d36cf1bbda3451e2ac /fs/nfs/nfs4proc.c
parenta8a5da996df7d2d91b5aef2752da9adcefea4bc6 (diff)
nfsv4: Switch to generic xattr handling code
This patch make nfsv4 use the generic xattr handling code to get the nfsv4 acl. This will help us to add richacl support to nfsv4 in later patches Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs4proc.c')
-rw-r--r--fs/nfs/nfs4proc.c62
1 files changed, 35 insertions, 27 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index ca88f294f0af..82f3a82b7115 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -49,6 +49,7 @@
49#include <linux/mount.h> 49#include <linux/mount.h>
50#include <linux/module.h> 50#include <linux/module.h>
51#include <linux/sunrpc/bc_xprt.h> 51#include <linux/sunrpc/bc_xprt.h>
52#include <linux/xattr.h>
52 53
53#include "nfs4_fs.h" 54#include "nfs4_fs.h"
54#include "delegation.h" 55#include "delegation.h"
@@ -4403,42 +4404,36 @@ void nfs4_release_lockowner(const struct nfs4_lock_state *lsp)
4403 4404
4404#define XATTR_NAME_NFSV4_ACL "system.nfs4_acl" 4405#define XATTR_NAME_NFSV4_ACL "system.nfs4_acl"
4405 4406
4406int nfs4_setxattr(struct dentry *dentry, const char *key, const void *buf, 4407static int nfs4_xattr_set_nfs4_acl(struct dentry *dentry, const char *key,
4407 size_t buflen, int flags) 4408 const void *buf, size_t buflen,
4409 int flags, int type)
4408{ 4410{
4409 struct inode *inode = dentry->d_inode; 4411 if (strcmp(key, "") != 0)
4410 4412 return -EINVAL;
4411 if (strcmp(key, XATTR_NAME_NFSV4_ACL) != 0)
4412 return -EOPNOTSUPP;
4413 4413
4414 return nfs4_proc_set_acl(inode, buf, buflen); 4414 return nfs4_proc_set_acl(dentry->d_inode, buf, buflen);
4415} 4415}
4416 4416
4417/* The getxattr man page suggests returning -ENODATA for unknown attributes, 4417static int nfs4_xattr_get_nfs4_acl(struct dentry *dentry, const char *key,
4418 * and that's what we'll do for e.g. user attributes that haven't been set. 4418 void *buf, size_t buflen, int type)
4419 * But we'll follow ext2/ext3's lead by returning -EOPNOTSUPP for unsupported
4420 * attributes in kernel-managed attribute namespaces. */
4421ssize_t nfs4_getxattr(struct dentry *dentry, const char *key, void *buf,
4422 size_t buflen)
4423{ 4419{
4424 struct inode *inode = dentry->d_inode; 4420 if (strcmp(key, "") != 0)
4425 4421 return -EINVAL;
4426 if (strcmp(key, XATTR_NAME_NFSV4_ACL) != 0)
4427 return -EOPNOTSUPP;
4428 4422
4429 return nfs4_proc_get_acl(inode, buf, buflen); 4423 return nfs4_proc_get_acl(dentry->d_inode, buf, buflen);
4430} 4424}
4431 4425
4432ssize_t nfs4_listxattr(struct dentry *dentry, char *buf, size_t buflen) 4426static size_t nfs4_xattr_list_nfs4_acl(struct dentry *dentry, char *list,
4427 size_t list_len, const char *name,
4428 size_t name_len, int type)
4433{ 4429{
4434 size_t len = strlen(XATTR_NAME_NFSV4_ACL) + 1; 4430 size_t len = sizeof(XATTR_NAME_NFSV4_ACL);
4435 4431
4436 if (!nfs4_server_supports_acls(NFS_SERVER(dentry->d_inode))) 4432 if (!nfs4_server_supports_acls(NFS_SERVER(dentry->d_inode)))
4437 return 0; 4433 return 0;
4438 if (buf && buflen < len) 4434
4439 return -ERANGE; 4435 if (list && len <= list_len)
4440 if (buf) 4436 memcpy(list, XATTR_NAME_NFSV4_ACL, len);
4441 memcpy(buf, XATTR_NAME_NFSV4_ACL, len);
4442 return len; 4437 return len;
4443} 4438}
4444 4439
@@ -5509,9 +5504,10 @@ static const struct inode_operations nfs4_file_inode_operations = {
5509 .permission = nfs_permission, 5504 .permission = nfs_permission,
5510 .getattr = nfs_getattr, 5505 .getattr = nfs_getattr,
5511 .setattr = nfs_setattr, 5506 .setattr = nfs_setattr,
5512 .getxattr = nfs4_getxattr, 5507 .getxattr = generic_getxattr,
5513 .setxattr = nfs4_setxattr, 5508 .setxattr = generic_setxattr,
5514 .listxattr = nfs4_listxattr, 5509 .listxattr = generic_listxattr,
5510 .removexattr = generic_removexattr,
5515}; 5511};
5516 5512
5517const struct nfs_rpc_ops nfs_v4_clientops = { 5513const struct nfs_rpc_ops nfs_v4_clientops = {
@@ -5556,6 +5552,18 @@ const struct nfs_rpc_ops nfs_v4_clientops = {
5556 .open_context = nfs4_atomic_open, 5552 .open_context = nfs4_atomic_open,
5557}; 5553};
5558 5554
5555static const struct xattr_handler nfs4_xattr_nfs4_acl_handler = {
5556 .prefix = XATTR_NAME_NFSV4_ACL,
5557 .list = nfs4_xattr_list_nfs4_acl,
5558 .get = nfs4_xattr_get_nfs4_acl,
5559 .set = nfs4_xattr_set_nfs4_acl,
5560};
5561
5562const struct xattr_handler *nfs4_xattr_handlers[] = {
5563 &nfs4_xattr_nfs4_acl_handler,
5564 NULL
5565};
5566
5559/* 5567/*
5560 * Local variables: 5568 * Local variables:
5561 * c-basic-offset: 8 5569 * c-basic-offset: 8