xref: /linux/fs/lockd/xdr.h (revision bba2c3615bd6cfee7456d1130f2e6b01b3f4e9ba)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * XDR types for the NLM protocol
4  *
5  * Copyright (C) 1996 Olaf Kirch <okir@monad.swb.de>
6  */
7 
8 #ifndef _LOCKD_XDR_H
9 #define _LOCKD_XDR_H
10 
11 #include <linux/fs.h>
12 #include <linux/filelock.h>
13 #include <linux/nfs.h>
14 #include <linux/sunrpc/xdr.h>
15 
16 #define SM_MAXSTRLEN		1024
17 #define SM_PRIV_SIZE		16
18 
19 struct nsm_private {
20 	unsigned char		data[SM_PRIV_SIZE];
21 };
22 
23 #define NLM_MAXCOOKIELEN    	32
24 #define NLM_MAXSTRLEN		1024
25 
26 #define	nlm_granted		cpu_to_be32(NLM_LCK_GRANTED)
27 #define	nlm_lck_denied		cpu_to_be32(NLM_LCK_DENIED)
28 #define	nlm_lck_denied_nolocks	cpu_to_be32(NLM_LCK_DENIED_NOLOCKS)
29 #define	nlm_lck_blocked		cpu_to_be32(NLM_LCK_BLOCKED)
30 #define	nlm_lck_denied_grace_period	cpu_to_be32(NLM_LCK_DENIED_GRACE_PERIOD)
31 
32 /* Lock info passed via NLM */
33 struct lockd_lock {
34 	char *			caller;
35 	unsigned int		len; 	/* length of "caller" */
36 	struct nfs_fh		fh;
37 	struct xdr_netobj	oh;
38 	u32			svid;
39 	u64			lock_start;
40 	u64			lock_len;
41 	struct file_lock	fl;
42 };
43 
44 /*
45  *	NLM cookies. Technically they can be 1K, but Linux only uses 8 bytes.
46  *	FreeBSD uses 16, Apple Mac OS X 10.3 uses 20. Therefore we set it to
47  *	32 bytes.
48  */
49 
50 struct lockd_cookie {
51 	unsigned char data[NLM_MAXCOOKIELEN];
52 	unsigned int len;
53 };
54 
55 /*
56  * Generic lockd arguments for all but sm_notify
57  */
58 struct lockd_args {
59 	struct lockd_cookie	cookie;
60 	struct lockd_lock	lock;
61 	u32			block;
62 	u32			reclaim;
63 	u32			state;
64 };
65 
66 /*
67  * Generic lockd result
68  */
69 struct lockd_res {
70 	struct lockd_cookie	cookie;
71 	__be32			status;
72 	struct lockd_lock	lock;
73 };
74 
75 /*
76  * statd callback when client has rebooted
77  */
78 struct lockd_reboot {
79 	char			*mon;
80 	unsigned int		len;
81 	u32			state;
82 	struct nsm_private	priv;
83 };
84 
85 #endif /* _LOCKD_XDR_H */
86