blob: 8c1b437c540363133d8d0547ad9e172a0816ed9d [file] [log] [blame]
Bryan Schumaker1179acc2012-07-30 16:05:19 -04001#include <linux/nfs_fs.h>
2#include <linux/nfs_mount.h>
3#include "internal.h"
Trond Myklebust3fc3edf2014-09-25 16:28:53 -04004#include "nfs3_fs.h"
Bryan Schumaker1179acc2012-07-30 16:05:19 -04005
6#ifdef CONFIG_NFS_V3_ACL
7static struct rpc_stat nfsacl_rpcstat = { &nfsacl_program };
8static const struct rpc_version *nfsacl_version[] = {
9 [3] = &nfsacl_version3,
10};
11
12const struct rpc_program nfsacl_program = {
13 .name = "nfsacl",
14 .number = NFS_ACL_PROGRAM,
15 .nrvers = ARRAY_SIZE(nfsacl_version),
16 .version = nfsacl_version,
17 .stats = &nfsacl_rpcstat,
18};
19
20/*
21 * Initialise an NFSv3 ACL client connection
22 */
23static void nfs_init_server_aclclient(struct nfs_server *server)
24{
25 if (server->flags & NFS_MOUNT_NOACL)
26 goto out_noacl;
27
28 server->client_acl = rpc_bind_new_program(server->client, &nfsacl_program, 3);
29 if (IS_ERR(server->client_acl))
30 goto out_noacl;
31
32 /* No errors! Assume that Sun nfsacls are supported */
33 server->caps |= NFS_CAP_ACLS;
34 return;
35
36out_noacl:
37 server->caps &= ~NFS_CAP_ACLS;
38}
39#else
40static inline void nfs_init_server_aclclient(struct nfs_server *server)
41{
42 server->flags &= ~NFS_MOUNT_NOACL;
43 server->caps &= ~NFS_CAP_ACLS;
44}
45#endif
46
47struct nfs_server *nfs3_create_server(struct nfs_mount_info *mount_info,
48 struct nfs_subversion *nfs_mod)
49{
50 struct nfs_server *server = nfs_create_server(mount_info, nfs_mod);
51 /* Create a client RPC handle for the NFS v3 ACL management interface */
52 if (!IS_ERR(server))
53 nfs_init_server_aclclient(server);
54 return server;
55}
56
57struct nfs_server *nfs3_clone_server(struct nfs_server *source,
58 struct nfs_fh *fh,
59 struct nfs_fattr *fattr,
60 rpc_authflavor_t flavor)
61{
62 struct nfs_server *server = nfs_clone_server(source, fh, fattr, flavor);
63 if (!IS_ERR(server) && !IS_ERR(source->client_acl))
64 nfs_init_server_aclclient(server);
65 return server;
66}