blob: 528fb299430e6a53a5d4c90dd6863f9cbe458dcc [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
J. Bruce Fields7663dac2009-12-04 19:49:00 -05002/* XDR types for nfsd. This is mainly a typing exercise. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003
4#ifndef LINUX_NFSD_H
5#define LINUX_NFSD_H
6
Linus Torvalds1da177e2005-04-16 15:20:36 -07007#include <linux/vfs.h>
Boaz Harrosh9a74af22009-12-03 20:30:56 +02008#include "nfsd.h"
J. Bruce Fields1557aca2009-12-04 19:36:06 -05009#include "nfsfh.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070010
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;
Chuck Lever29d5e552007-11-01 16:57:04 -040023 unsigned int len;
Linus Torvalds1da177e2005-04-16 15:20:36 -070024};
25
26struct nfsd_readargs {
27 struct svc_fh fh;
28 __u32 offset;
29 __u32 count;
Linus Torvalds1da177e2005-04-16 15:20:36 -070030};
31
32struct nfsd_writeargs {
33 svc_fh fh;
34 __u32 offset;
35 int len;
Chuck Leverdae9a6c2021-09-30 17:06:21 -040036 struct xdr_buf payload;
Linus Torvalds1da177e2005-04-16 15:20:36 -070037};
38
39struct nfsd_createargs {
40 struct svc_fh fh;
41 char * name;
Chuck Lever29d5e552007-11-01 16:57:04 -040042 unsigned int len;
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 struct iattr attrs;
44};
45
46struct nfsd_renameargs {
47 struct svc_fh ffh;
48 char * fname;
Chuck Lever29d5e552007-11-01 16:57:04 -040049 unsigned int flen;
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 struct svc_fh tfh;
51 char * tname;
Chuck Lever29d5e552007-11-01 16:57:04 -040052 unsigned int tlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -070053};
54
Linus Torvalds1da177e2005-04-16 15:20:36 -070055struct nfsd_linkargs {
56 struct svc_fh ffh;
57 struct svc_fh tfh;
58 char * tname;
Chuck Lever29d5e552007-11-01 16:57:04 -040059 unsigned int tlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -070060};
61
62struct nfsd_symlinkargs {
63 struct svc_fh ffh;
64 char * fname;
Chuck Lever29d5e552007-11-01 16:57:04 -040065 unsigned int flen;
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 char * tname;
Chuck Lever48b4ba32007-11-01 16:57:25 -040067 unsigned int tlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 struct iattr attrs;
Chuck Lever38a70312018-03-27 10:54:21 -040069 struct kvec first;
Linus Torvalds1da177e2005-04-16 15:20:36 -070070};
71
72struct nfsd_readdirargs {
73 struct svc_fh fh;
74 __u32 cookie;
75 __u32 count;
Linus Torvalds1da177e2005-04-16 15:20:36 -070076};
77
Chuck Levercc028a12020-10-02 15:52:44 -040078struct nfsd_stat {
79 __be32 status;
80};
81
Linus Torvalds1da177e2005-04-16 15:20:36 -070082struct nfsd_attrstat {
Chuck Leverf0af2212020-10-01 18:59:49 -040083 __be32 status;
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 struct svc_fh fh;
David Shawa334de22006-01-06 00:19:58 -080085 struct kstat stat;
Linus Torvalds1da177e2005-04-16 15:20:36 -070086};
87
88struct nfsd_diropres {
Chuck Leverf0af2212020-10-01 18:59:49 -040089 __be32 status;
Linus Torvalds1da177e2005-04-16 15:20:36 -070090 struct svc_fh fh;
David Shawa334de22006-01-06 00:19:58 -080091 struct kstat stat;
Linus Torvalds1da177e2005-04-16 15:20:36 -070092};
93
94struct nfsd_readlinkres {
Chuck Leverf0af2212020-10-01 18:59:49 -040095 __be32 status;
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 int len;
Chuck Leverd9014b02020-10-23 15:41:09 -040097 struct page *page;
Linus Torvalds1da177e2005-04-16 15:20:36 -070098};
99
100struct nfsd_readres {
Chuck Leverf0af2212020-10-01 18:59:49 -0400101 __be32 status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 struct svc_fh fh;
103 unsigned long count;
David Shawa334de22006-01-06 00:19:58 -0800104 struct kstat stat;
Chuck Levera6f8d9d2020-10-23 16:40:11 -0400105 struct page **pages;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106};
107
108struct nfsd_readdirres {
Chuck Leverf5dcccd2020-11-14 13:45:35 -0500109 /* Components of the reply */
Chuck Leverf0af2212020-10-01 18:59:49 -0400110 __be32 status;
111
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112 int count;
113
Chuck Leverf5dcccd2020-11-14 13:45:35 -0500114 /* Used to encode the reply's entry list */
115 struct xdr_stream xdr;
116 struct xdr_buf dirlist;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117 struct readdir_cd common;
Chuck Leverf5dcccd2020-11-14 13:45:35 -0500118 unsigned int cookie_offset;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119};
120
121struct nfsd_statfsres {
Chuck Leverf0af2212020-10-01 18:59:49 -0400122 __be32 status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 struct kstatfs stats;
124};
125
126/*
127 * Storage requirements for XDR arguments and results.
128 */
129union nfsd_xdrstore {
130 struct nfsd_sattrargs sattr;
131 struct nfsd_diropargs dirop;
132 struct nfsd_readargs read;
133 struct nfsd_writeargs write;
134 struct nfsd_createargs create;
135 struct nfsd_renameargs rename;
136 struct nfsd_linkargs link;
137 struct nfsd_symlinkargs symlink;
138 struct nfsd_readdirargs readdir;
139};
140
141#define NFS2_SVC_XDRSIZE sizeof(union nfsd_xdrstore)
142
143
Chuck Leverc44b31c2021-10-12 11:57:28 -0400144bool nfssvc_decode_fhandleargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
145bool nfssvc_decode_sattrargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
146bool nfssvc_decode_diropargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
147bool nfssvc_decode_readargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
148bool nfssvc_decode_writeargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
149bool nfssvc_decode_createargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
150bool nfssvc_decode_renameargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
151bool nfssvc_decode_linkargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
152bool nfssvc_decode_symlinkargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
153bool nfssvc_decode_readdirargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
Chuck Lever16c66362021-10-12 11:57:22 -0400154
Chuck Lever130e2052021-10-13 10:41:13 -0400155bool nfssvc_encode_statres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
156bool nfssvc_encode_attrstatres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
157bool nfssvc_encode_diropres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
158bool nfssvc_encode_readlinkres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
159bool nfssvc_encode_readres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
160bool nfssvc_encode_statfsres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
161bool nfssvc_encode_readdirres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162
Chuck Leverd52532002020-11-13 16:53:17 -0500163void nfssvc_encode_nfscookie(struct nfsd_readdirres *resp, u32 offset);
Chuck Lever8a2cf9f2020-11-15 14:30:13 -0500164int nfssvc_encode_entry(void *data, const char *name, int namlen,
165 loff_t offset, u64 ino, unsigned int d_type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166
Chuck Lever1841b9b2020-10-01 18:59:44 -0400167void nfssvc_release_attrstat(struct svc_rqst *rqstp);
168void nfssvc_release_diropres(struct svc_rqst *rqstp);
169void nfssvc_release_readres(struct svc_rqst *rqstp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170
Andreas Gruenbachera257cdd2005-06-22 17:16:26 +0000171/* Helper functions for NFSv2 ACL code */
Chuck Lever635a45d2020-11-17 11:32:04 -0500172bool svcxdr_decode_fhandle(struct xdr_stream *xdr, struct svc_fh *fhp);
Chuck Leverf8cba472020-11-18 14:38:47 -0500173bool svcxdr_encode_stat(struct xdr_stream *xdr, __be32 status);
174bool svcxdr_encode_fattr(struct svc_rqst *rqstp, struct xdr_stream *xdr,
175 const struct svc_fh *fhp, const struct kstat *stat);
Andreas Gruenbachera257cdd2005-06-22 17:16:26 +0000176
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177#endif /* LINUX_NFSD_H */