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