blob: 0ff336b0b25f9a3b498516dab19863631e96f088 [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 int vlen;
31};
32
33struct nfsd_writeargs {
34 svc_fh fh;
35 __u32 offset;
36 int len;
Chuck Lever8154ef22018-03-27 10:54:07 -040037 struct kvec first;
Linus Torvalds1da177e2005-04-16 15:20:36 -070038};
39
40struct nfsd_createargs {
41 struct svc_fh fh;
42 char * name;
Chuck Lever29d5e552007-11-01 16:57:04 -040043 unsigned int len;
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 struct iattr attrs;
45};
46
47struct nfsd_renameargs {
48 struct svc_fh ffh;
49 char * fname;
Chuck Lever29d5e552007-11-01 16:57:04 -040050 unsigned int flen;
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 struct svc_fh tfh;
52 char * tname;
Chuck Lever29d5e552007-11-01 16:57:04 -040053 unsigned int tlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -070054};
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;
Chuck Lever29d5e552007-11-01 16:57:04 -040065 unsigned int tlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -070066};
67
68struct nfsd_symlinkargs {
69 struct svc_fh ffh;
70 char * fname;
Chuck Lever29d5e552007-11-01 16:57:04 -040071 unsigned int flen;
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 char * tname;
Chuck Lever48b4ba32007-11-01 16:57:25 -040073 unsigned int tlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 struct iattr attrs;
Chuck Lever38a70312018-03-27 10:54:21 -040075 struct kvec first;
Linus Torvalds1da177e2005-04-16 15:20:36 -070076};
77
78struct nfsd_readdirargs {
79 struct svc_fh fh;
80 __u32 cookie;
81 __u32 count;
Al Viro131a21c2006-10-19 23:28:56 -070082 __be32 * buffer;
Linus Torvalds1da177e2005-04-16 15:20:36 -070083};
84
Chuck Levercc028a12020-10-02 15:52:44 -040085struct nfsd_stat {
86 __be32 status;
87};
88
Linus Torvalds1da177e2005-04-16 15:20:36 -070089struct nfsd_attrstat {
Chuck Leverf0af2212020-10-01 18:59:49 -040090 __be32 status;
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 struct svc_fh fh;
David Shawa334de22006-01-06 00:19:58 -080092 struct kstat stat;
Linus Torvalds1da177e2005-04-16 15:20:36 -070093};
94
95struct nfsd_diropres {
Chuck Leverf0af2212020-10-01 18:59:49 -040096 __be32 status;
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 struct svc_fh fh;
David Shawa334de22006-01-06 00:19:58 -080098 struct kstat stat;
Linus Torvalds1da177e2005-04-16 15:20:36 -070099};
100
101struct nfsd_readlinkres {
Chuck Leverf0af2212020-10-01 18:59:49 -0400102 __be32 status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 int len;
104};
105
106struct nfsd_readres {
Chuck Leverf0af2212020-10-01 18:59:49 -0400107 __be32 status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 struct svc_fh fh;
109 unsigned long count;
David Shawa334de22006-01-06 00:19:58 -0800110 struct kstat stat;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111};
112
113struct nfsd_readdirres {
Chuck Leverf0af2212020-10-01 18:59:49 -0400114 __be32 status;
115
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 int count;
117
118 struct readdir_cd common;
Al Viro131a21c2006-10-19 23:28:56 -0700119 __be32 * buffer;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 int buflen;
Al Viro131a21c2006-10-19 23:28:56 -0700121 __be32 * offset;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122};
123
124struct nfsd_statfsres {
Chuck Leverf0af2212020-10-01 18:59:49 -0400125 __be32 status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 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
Christoph Hellwig026fec72017-05-08 19:01:48 +0200147int 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 *);
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200159int nfssvc_encode_void(struct svc_rqst *, __be32 *);
Chuck Levercc028a12020-10-02 15:52:44 -0400160int nfssvc_encode_stat(struct svc_rqst *, __be32 *);
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200161int 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 *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167
NeilBrowna0ad13e2007-01-26 00:57:10 -0800168int nfssvc_encode_entry(void *, const char *name,
169 int namlen, loff_t offset, u64 ino, unsigned int);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170
Chuck Lever1841b9b2020-10-01 18:59:44 -0400171void nfssvc_release_attrstat(struct svc_rqst *rqstp);
172void nfssvc_release_diropres(struct svc_rqst *rqstp);
173void nfssvc_release_readres(struct svc_rqst *rqstp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174
Andreas Gruenbachera257cdd2005-06-22 17:16:26 +0000175/* Helper functions for NFSv2 ACL code */
J. Bruce Fields4f4a4fa2013-02-01 15:13:04 -0500176__be32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp, struct kstat *stat);
Al Viro131a21c2006-10-19 23:28:56 -0700177__be32 *nfs2svc_decode_fh(__be32 *p, struct svc_fh *fhp);
Andreas Gruenbachera257cdd2005-06-22 17:16:26 +0000178
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179#endif /* LINUX_NFSD_H */