Example #1
0
static int nfs_lookup_with_sec(struct nfs_server *server, struct dentry *parent,
			       struct dentry *dentry, struct path *path,
			       struct nfs_fh *fh, struct nfs_fattr *fattr,
			       rpc_authflavor_t *flavor)
{
	struct rpc_clnt *clone;
	struct rpc_auth *auth;
	int err;

	err = nfs_negotiate_security(parent, path->dentry, flavor);
	if (err < 0)
		goto out;
	clone  = rpc_clone_client(server->client);
	auth   = rpcauth_create(*flavor, clone);
	if (!auth) {
		err = -EIO;
		goto out_shutdown;
	}
	err = server->nfs_client->rpc_ops->lookup(clone, parent->d_inode,
						  &path->dentry->d_name,
						  fh, fattr);
out_shutdown:
	rpc_shutdown_client(clone);
out:
	return err;
}
Example #2
0
static inline struct rpc_clnt *nfs_lookup_mountpoint(struct inode *dir,
						     struct qstr *name,
						     struct nfs_fh *fh,
						     struct nfs_fattr *fattr)
{
	int err = NFS_PROTO(dir)->lookup(NFS_SERVER(dir)->client, dir, name, fh, fattr);
	if (err)
		return ERR_PTR(err);
	return rpc_clone_client(NFS_SERVER(dir)->client);
}
/*
 * Please call rpc_shutdown_client() when you are done with this client.
 */
struct rpc_clnt *nfs4_create_sec_client(struct rpc_clnt *clnt, struct inode *inode,
					struct qstr *name)
{
	struct rpc_clnt *clone;
	struct rpc_auth *auth;
	rpc_authflavor_t flavor;

	flavor = nfs4_negotiate_security(inode, name);
	if (flavor < 0)
		return ERR_PTR(flavor);

	clone = rpc_clone_client(clnt);
	if (IS_ERR(clone))
		return clone;

	auth = rpcauth_create(flavor, clone);
	if (!auth) {
		rpc_shutdown_client(clone);
		clone = ERR_PTR(-EIO);
	}

	return clone;
}