1 #include <linux/nfs_fs.h> 2 #include <linux/nfs_mount.h> 3 #include "internal.h" 4 #include "nfs3_fs.h" 5 6 #ifdef CONFIG_NFS_V3_ACL 7 static struct rpc_stat nfsacl_rpcstat = { &nfsacl_program }; 8 static const struct rpc_version *nfsacl_version[] = { 9 [3] = &nfsacl_version3, 10 }; 11 12 const 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 */ 23 static 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 36 out_noacl: 37 server->caps &= ~NFS_CAP_ACLS; 38 } 39 #else 40 static 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 47 struct 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 57 struct 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 } 67