xref: /openbmc/linux/fs/nfsd/xdr.h (revision 8c293ef993c8df0b1bea9ecb0de6eb96dec3ac9d)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* XDR types for nfsd. This is mainly a typing exercise. */
3 
4 #ifndef LINUX_NFSD_H
5 #define LINUX_NFSD_H
6 
7 #include <linux/vfs.h>
8 #include "nfsd.h"
9 #include "nfsfh.h"
10 
11 struct nfsd_fhandle {
12 	struct svc_fh		fh;
13 };
14 
15 struct nfsd_sattrargs {
16 	struct svc_fh		fh;
17 	struct iattr		attrs;
18 };
19 
20 struct nfsd_diropargs {
21 	struct svc_fh		fh;
22 	char *			name;
23 	unsigned int		len;
24 };
25 
26 struct nfsd_readargs {
27 	struct svc_fh		fh;
28 	__u32			offset;
29 	__u32			count;
30 };
31 
32 struct nfsd_writeargs {
33 	svc_fh			fh;
34 	__u32			offset;
35 	int			len;
36 	struct kvec		first;
37 };
38 
39 struct nfsd_createargs {
40 	struct svc_fh		fh;
41 	char *			name;
42 	unsigned int		len;
43 	struct iattr		attrs;
44 };
45 
46 struct nfsd_renameargs {
47 	struct svc_fh		ffh;
48 	char *			fname;
49 	unsigned int		flen;
50 	struct svc_fh		tfh;
51 	char *			tname;
52 	unsigned int		tlen;
53 };
54 
55 struct nfsd_readlinkargs {
56 	struct svc_fh		fh;
57 	char *			buffer;
58 };
59 
60 struct nfsd_linkargs {
61 	struct svc_fh		ffh;
62 	struct svc_fh		tfh;
63 	char *			tname;
64 	unsigned int		tlen;
65 };
66 
67 struct nfsd_symlinkargs {
68 	struct svc_fh		ffh;
69 	char *			fname;
70 	unsigned int		flen;
71 	char *			tname;
72 	unsigned int		tlen;
73 	struct iattr		attrs;
74 	struct kvec		first;
75 };
76 
77 struct nfsd_readdirargs {
78 	struct svc_fh		fh;
79 	__u32			cookie;
80 	__u32			count;
81 	__be32 *		buffer;
82 };
83 
84 struct nfsd_stat {
85 	__be32			status;
86 };
87 
88 struct nfsd_attrstat {
89 	__be32			status;
90 	struct svc_fh		fh;
91 	struct kstat		stat;
92 };
93 
94 struct nfsd_diropres  {
95 	__be32			status;
96 	struct svc_fh		fh;
97 	struct kstat		stat;
98 };
99 
100 struct nfsd_readlinkres {
101 	__be32			status;
102 	int			len;
103 };
104 
105 struct nfsd_readres {
106 	__be32			status;
107 	struct svc_fh		fh;
108 	unsigned long		count;
109 	struct kstat		stat;
110 };
111 
112 struct nfsd_readdirres {
113 	__be32			status;
114 
115 	int			count;
116 
117 	struct readdir_cd	common;
118 	__be32 *		buffer;
119 	int			buflen;
120 	__be32 *		offset;
121 };
122 
123 struct nfsd_statfsres {
124 	__be32			status;
125 	struct kstatfs		stats;
126 };
127 
128 /*
129  * Storage requirements for XDR arguments and results.
130  */
131 union nfsd_xdrstore {
132 	struct nfsd_sattrargs	sattr;
133 	struct nfsd_diropargs	dirop;
134 	struct nfsd_readargs	read;
135 	struct nfsd_writeargs	write;
136 	struct nfsd_createargs	create;
137 	struct nfsd_renameargs	rename;
138 	struct nfsd_linkargs	link;
139 	struct nfsd_symlinkargs	symlink;
140 	struct nfsd_readdirargs	readdir;
141 };
142 
143 #define NFS2_SVC_XDRSIZE	sizeof(union nfsd_xdrstore)
144 
145 
146 int nfssvc_decode_fhandleargs(struct svc_rqst *, __be32 *);
147 int nfssvc_decode_sattrargs(struct svc_rqst *, __be32 *);
148 int nfssvc_decode_diropargs(struct svc_rqst *, __be32 *);
149 int nfssvc_decode_readargs(struct svc_rqst *, __be32 *);
150 int nfssvc_decode_writeargs(struct svc_rqst *, __be32 *);
151 int nfssvc_decode_createargs(struct svc_rqst *, __be32 *);
152 int nfssvc_decode_renameargs(struct svc_rqst *, __be32 *);
153 int nfssvc_decode_readlinkargs(struct svc_rqst *, __be32 *);
154 int nfssvc_decode_linkargs(struct svc_rqst *, __be32 *);
155 int nfssvc_decode_symlinkargs(struct svc_rqst *, __be32 *);
156 int nfssvc_decode_readdirargs(struct svc_rqst *, __be32 *);
157 int nfssvc_encode_stat(struct svc_rqst *, __be32 *);
158 int nfssvc_encode_attrstat(struct svc_rqst *, __be32 *);
159 int nfssvc_encode_diropres(struct svc_rqst *, __be32 *);
160 int nfssvc_encode_readlinkres(struct svc_rqst *, __be32 *);
161 int nfssvc_encode_readres(struct svc_rqst *, __be32 *);
162 int nfssvc_encode_statfsres(struct svc_rqst *, __be32 *);
163 int nfssvc_encode_readdirres(struct svc_rqst *, __be32 *);
164 
165 int nfssvc_encode_entry(void *, const char *name,
166 			int namlen, loff_t offset, u64 ino, unsigned int);
167 
168 void nfssvc_release_attrstat(struct svc_rqst *rqstp);
169 void nfssvc_release_diropres(struct svc_rqst *rqstp);
170 void nfssvc_release_readres(struct svc_rqst *rqstp);
171 
172 /* Helper functions for NFSv2 ACL code */
173 __be32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp, struct kstat *stat);
174 __be32 *nfs2svc_decode_fh(__be32 *p, struct svc_fh *fhp);
175 
176 #endif /* LINUX_NFSD_H */
177