HID: hiddev: Fix slab-out-of-bounds write in hiddev_ioctl_usage()
[linux/fpc-iii.git] / fs / nfs / nfs3client.c
blob9e9fa347a948698dabd2ea53580d7538658fc327
1 #include <linux/nfs_fs.h>
2 #include <linux/nfs_mount.h>
3 #include <linux/sunrpc/addr.h>
4 #include "internal.h"
5 #include "nfs3_fs.h"
7 #ifdef CONFIG_NFS_V3_ACL
8 static struct rpc_stat nfsacl_rpcstat = { &nfsacl_program };
9 static const struct rpc_version *nfsacl_version[] = {
10 [3] = &nfsacl_version3,
13 const struct rpc_program nfsacl_program = {
14 .name = "nfsacl",
15 .number = NFS_ACL_PROGRAM,
16 .nrvers = ARRAY_SIZE(nfsacl_version),
17 .version = nfsacl_version,
18 .stats = &nfsacl_rpcstat,
22 * Initialise an NFSv3 ACL client connection
24 static void nfs_init_server_aclclient(struct nfs_server *server)
26 if (server->flags & NFS_MOUNT_NOACL)
27 goto out_noacl;
29 server->client_acl = rpc_bind_new_program(server->client, &nfsacl_program, 3);
30 if (IS_ERR(server->client_acl))
31 goto out_noacl;
33 /* No errors! Assume that Sun nfsacls are supported */
34 server->caps |= NFS_CAP_ACLS;
35 return;
37 out_noacl:
38 server->caps &= ~NFS_CAP_ACLS;
40 #else
41 static inline void nfs_init_server_aclclient(struct nfs_server *server)
43 server->flags &= ~NFS_MOUNT_NOACL;
44 server->caps &= ~NFS_CAP_ACLS;
46 #endif
48 struct nfs_server *nfs3_create_server(struct nfs_mount_info *mount_info,
49 struct nfs_subversion *nfs_mod)
51 struct nfs_server *server = nfs_create_server(mount_info, nfs_mod);
52 /* Create a client RPC handle for the NFS v3 ACL management interface */
53 if (!IS_ERR(server))
54 nfs_init_server_aclclient(server);
55 return server;
58 struct nfs_server *nfs3_clone_server(struct nfs_server *source,
59 struct nfs_fh *fh,
60 struct nfs_fattr *fattr,
61 rpc_authflavor_t flavor)
63 struct nfs_server *server = nfs_clone_server(source, fh, fattr, flavor);
64 if (!IS_ERR(server) && !IS_ERR(source->client_acl))
65 nfs_init_server_aclclient(server);
66 return server;
70 * Set up a pNFS Data Server client over NFSv3.
72 * Return any existing nfs_client that matches server address,port,version
73 * and minorversion.
75 * For a new nfs_client, use a soft mount (default), a low retrans and a
76 * low timeout interval so that if a connection is lost, we retry through
77 * the MDS.
79 struct nfs_client *nfs3_set_ds_client(struct nfs_client *mds_clp,
80 const struct sockaddr *ds_addr, int ds_addrlen,
81 int ds_proto, unsigned int ds_timeo, unsigned int ds_retrans,
82 rpc_authflavor_t au_flavor)
84 struct nfs_client_initdata cl_init = {
85 .addr = ds_addr,
86 .addrlen = ds_addrlen,
87 .nfs_mod = &nfs_v3,
88 .proto = ds_proto,
89 .net = mds_clp->cl_net,
91 struct rpc_timeout ds_timeout;
92 struct nfs_client *clp;
93 char buf[INET6_ADDRSTRLEN + 1];
95 /* fake a hostname because lockd wants it */
96 if (rpc_ntop(ds_addr, buf, sizeof(buf)) <= 0)
97 return ERR_PTR(-EINVAL);
98 cl_init.hostname = buf;
100 /* Use the MDS nfs_client cl_ipaddr. */
101 nfs_init_timeout_values(&ds_timeout, ds_proto, ds_timeo, ds_retrans);
102 clp = nfs_get_client(&cl_init, &ds_timeout, mds_clp->cl_ipaddr,
103 au_flavor);
105 return clp;
107 EXPORT_SYMBOL_GPL(nfs3_set_ds_client);