xref: /OK3568_Linux_fs/kernel/include/linux/lockd/bind.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * linux/include/linux/lockd/bind.h
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * This is the part of lockd visible to nfsd and the nfs client.
6*4882a593Smuzhiyun  *
7*4882a593Smuzhiyun  * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
8*4882a593Smuzhiyun  */
9*4882a593Smuzhiyun 
10*4882a593Smuzhiyun #ifndef LINUX_LOCKD_BIND_H
11*4882a593Smuzhiyun #define LINUX_LOCKD_BIND_H
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun #include <linux/lockd/nlm.h>
14*4882a593Smuzhiyun /* need xdr-encoded error codes too, so... */
15*4882a593Smuzhiyun #include <linux/lockd/xdr.h>
16*4882a593Smuzhiyun #ifdef CONFIG_LOCKD_V4
17*4882a593Smuzhiyun #include <linux/lockd/xdr4.h>
18*4882a593Smuzhiyun #endif
19*4882a593Smuzhiyun 
20*4882a593Smuzhiyun /* Dummy declarations */
21*4882a593Smuzhiyun struct svc_rqst;
22*4882a593Smuzhiyun struct rpc_task;
23*4882a593Smuzhiyun 
24*4882a593Smuzhiyun /*
25*4882a593Smuzhiyun  * This is the set of functions for lockd->nfsd communication
26*4882a593Smuzhiyun  */
27*4882a593Smuzhiyun struct nlmsvc_binding {
28*4882a593Smuzhiyun 	__be32			(*fopen)(struct svc_rqst *,
29*4882a593Smuzhiyun 						struct nfs_fh *,
30*4882a593Smuzhiyun 						struct file **);
31*4882a593Smuzhiyun 	void			(*fclose)(struct file *);
32*4882a593Smuzhiyun };
33*4882a593Smuzhiyun 
34*4882a593Smuzhiyun extern const struct nlmsvc_binding *nlmsvc_ops;
35*4882a593Smuzhiyun 
36*4882a593Smuzhiyun /*
37*4882a593Smuzhiyun  * Similar to nfs_client_initdata, but without the NFS-specific
38*4882a593Smuzhiyun  * rpc_ops field.
39*4882a593Smuzhiyun  */
40*4882a593Smuzhiyun struct nlmclnt_initdata {
41*4882a593Smuzhiyun 	const char		*hostname;
42*4882a593Smuzhiyun 	const struct sockaddr	*address;
43*4882a593Smuzhiyun 	size_t			addrlen;
44*4882a593Smuzhiyun 	unsigned short		protocol;
45*4882a593Smuzhiyun 	u32			nfs_version;
46*4882a593Smuzhiyun 	int			noresvport;
47*4882a593Smuzhiyun 	struct net		*net;
48*4882a593Smuzhiyun 	const struct nlmclnt_operations	*nlmclnt_ops;
49*4882a593Smuzhiyun 	const struct cred	*cred;
50*4882a593Smuzhiyun };
51*4882a593Smuzhiyun 
52*4882a593Smuzhiyun /*
53*4882a593Smuzhiyun  * Functions exported by the lockd module
54*4882a593Smuzhiyun  */
55*4882a593Smuzhiyun 
56*4882a593Smuzhiyun extern struct nlm_host *nlmclnt_init(const struct nlmclnt_initdata *nlm_init);
57*4882a593Smuzhiyun extern void	nlmclnt_done(struct nlm_host *host);
58*4882a593Smuzhiyun 
59*4882a593Smuzhiyun /*
60*4882a593Smuzhiyun  * NLM client operations provide a means to modify RPC processing of NLM
61*4882a593Smuzhiyun  * requests.  Callbacks receive a pointer to data passed into the call to
62*4882a593Smuzhiyun  * nlmclnt_proc().
63*4882a593Smuzhiyun  */
64*4882a593Smuzhiyun struct nlmclnt_operations {
65*4882a593Smuzhiyun 	/* Called on successful allocation of nlm_rqst, use for allocation or
66*4882a593Smuzhiyun 	 * reference counting. */
67*4882a593Smuzhiyun 	void (*nlmclnt_alloc_call)(void *);
68*4882a593Smuzhiyun 
69*4882a593Smuzhiyun 	/* Called in rpc_task_prepare for unlock.  A return value of true
70*4882a593Smuzhiyun 	 * indicates the callback has put the task to sleep on a waitqueue
71*4882a593Smuzhiyun 	 * and NLM should not call rpc_call_start(). */
72*4882a593Smuzhiyun 	bool (*nlmclnt_unlock_prepare)(struct rpc_task*, void *);
73*4882a593Smuzhiyun 
74*4882a593Smuzhiyun 	/* Called when the nlm_rqst is freed, callbacks should clean up here */
75*4882a593Smuzhiyun 	void (*nlmclnt_release_call)(void *);
76*4882a593Smuzhiyun };
77*4882a593Smuzhiyun 
78*4882a593Smuzhiyun extern int	nlmclnt_proc(struct nlm_host *host, int cmd, struct file_lock *fl, void *data);
79*4882a593Smuzhiyun extern int	lockd_up(struct net *net, const struct cred *cred);
80*4882a593Smuzhiyun extern void	lockd_down(struct net *net);
81*4882a593Smuzhiyun 
82*4882a593Smuzhiyun #endif /* LINUX_LOCKD_BIND_H */
83