blob: 2f4f22e6b8cbe9b79ac513b306880eb05e569938 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001/* 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 int len;
37 int vlen;
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};
76
77struct nfsd_readdirargs {
78 struct svc_fh fh;
79 __u32 cookie;
80 __u32 count;
81 __be32 * buffer;
82};
83
84struct nfsd_attrstat {
85 struct svc_fh fh;
86 struct kstat stat;
87};
88
89struct nfsd_diropres {
90 struct svc_fh fh;
91 struct kstat stat;
92};
93
94struct nfsd_readlinkres {
95 int len;
96};
97
98struct nfsd_readres {
99 struct svc_fh fh;
100 unsigned long count;
101 struct kstat stat;
102};
103
104struct nfsd_readdirres {
105 int count;
106
107 struct readdir_cd common;
108 __be32 * buffer;
109 int buflen;
110 __be32 * offset;
111};
112
113struct nfsd_statfsres {
114 struct kstatfs stats;
115};
116
117/*
118 * Storage requirements for XDR arguments and results.
119 */
120union nfsd_xdrstore {
121 struct nfsd_sattrargs sattr;
122 struct nfsd_diropargs dirop;
123 struct nfsd_readargs read;
124 struct nfsd_writeargs write;
125 struct nfsd_createargs create;
126 struct nfsd_renameargs rename;
127 struct nfsd_linkargs link;
128 struct nfsd_symlinkargs symlink;
129 struct nfsd_readdirargs readdir;
130};
131
132#define NFS2_SVC_XDRSIZE sizeof(union nfsd_xdrstore)
133
134
135int nfssvc_decode_void(struct svc_rqst *, __be32 *);
136int nfssvc_decode_fhandle(struct svc_rqst *, __be32 *);
137int nfssvc_decode_sattrargs(struct svc_rqst *, __be32 *);
138int nfssvc_decode_diropargs(struct svc_rqst *, __be32 *);
139int nfssvc_decode_readargs(struct svc_rqst *, __be32 *);
140int nfssvc_decode_writeargs(struct svc_rqst *, __be32 *);
141int nfssvc_decode_createargs(struct svc_rqst *, __be32 *);
142int nfssvc_decode_renameargs(struct svc_rqst *, __be32 *);
143int nfssvc_decode_readlinkargs(struct svc_rqst *, __be32 *);
144int nfssvc_decode_linkargs(struct svc_rqst *, __be32 *);
145int nfssvc_decode_symlinkargs(struct svc_rqst *, __be32 *);
146int nfssvc_decode_readdirargs(struct svc_rqst *, __be32 *);
147int nfssvc_encode_void(struct svc_rqst *, __be32 *);
148int nfssvc_encode_attrstat(struct svc_rqst *, __be32 *);
149int nfssvc_encode_diropres(struct svc_rqst *, __be32 *);
150int nfssvc_encode_readlinkres(struct svc_rqst *, __be32 *);
151int nfssvc_encode_readres(struct svc_rqst *, __be32 *);
152int nfssvc_encode_statfsres(struct svc_rqst *, __be32 *);
153int nfssvc_encode_readdirres(struct svc_rqst *, __be32 *);
154
155int nfssvc_encode_entry(void *, const char *name,
156 int namlen, loff_t offset, u64 ino, unsigned int);
157
158void nfssvc_release_fhandle(struct svc_rqst *);
159
160/* Helper functions for NFSv2 ACL code */
161__be32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp, struct kstat *stat);
162__be32 *nfs2svc_decode_fh(__be32 *p, struct svc_fh *fhp);
163
164#endif /* LINUX_NFSD_H */