aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/nfs/nfs4proc.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index c91c09938a55..d969dd13e7db 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -2216,6 +2216,29 @@ static ssize_t nfs4_proc_get_acl(struct inode *inode, void *buf, size_t buflen)
2216 return ret; 2216 return ret;
2217} 2217}
2218 2218
2219static int nfs4_proc_set_acl(struct inode *inode, const void *buf, size_t buflen)
2220{
2221 struct nfs_server *server = NFS_SERVER(inode);
2222 struct page *pages[NFS4ACL_MAXPAGES];
2223 struct nfs_setaclargs arg = {
2224 .fh = NFS_FH(inode),
2225 .acl_pages = pages,
2226 .acl_len = buflen,
2227 };
2228 struct rpc_message msg = {
2229 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETACL],
2230 .rpc_argp = &arg,
2231 .rpc_resp = NULL,
2232 };
2233 int ret;
2234
2235 if (!nfs4_server_supports_acls(server))
2236 return -EOPNOTSUPP;
2237 buf_to_pages(buf, buflen, arg.acl_pages, &arg.acl_pgbase);
2238 ret = rpc_call_sync(NFS_SERVER(inode)->client, &msg, 0);
2239 return ret;
2240}
2241
2219static int 2242static int
2220nfs4_async_handle_error(struct rpc_task *task, struct nfs_server *server) 2243nfs4_async_handle_error(struct rpc_task *task, struct nfs_server *server)
2221{ 2244{
@@ -2792,7 +2815,16 @@ nfs4_proc_lock(struct file *filp, int cmd, struct file_lock *request)
2792int nfs4_setxattr(struct dentry *dentry, const char *key, const void *buf, 2815int nfs4_setxattr(struct dentry *dentry, const char *key, const void *buf,
2793 size_t buflen, int flags) 2816 size_t buflen, int flags)
2794{ 2817{
2795 return -EOPNOTSUPP; 2818 struct inode *inode = dentry->d_inode;
2819
2820 if (strcmp(key, XATTR_NAME_NFSV4_ACL) != 0)
2821 return -EOPNOTSUPP;
2822
2823 if (!S_ISREG(inode->i_mode) &&
2824 (!S_ISDIR(inode->i_mode) || inode->i_mode & S_ISVTX))
2825 return -EPERM;
2826
2827 return nfs4_proc_set_acl(inode, buf, buflen);
2796} 2828}
2797 2829
2798/* The getxattr man page suggests returning -ENODATA for unknown attributes, 2830/* The getxattr man page suggests returning -ENODATA for unknown attributes,