1 #ifndef _LINUX_NFS_XDR_H
2 #define _LINUX_NFS_XDR_H
3 
4 struct nfs_fattr {
5 	unsigned short		valid;		/* which fields are valid */
6 	__u64			pre_size;	/* pre_op_attr.size	  */
7 	__u64			pre_mtime;	/* pre_op_attr.mtime	  */
8 	__u64			pre_ctime;	/* pre_op_attr.ctime	  */
9 	enum nfs_ftype		type;		/* always use NFSv2 types */
10 	__u32			mode;
11 	__u32			nlink;
12 	__u32			uid;
13 	__u32			gid;
14 	__u64			size;
15 	union {
16 		struct {
17 			__u32	blocksize;
18 			__u32	blocks;
19 		} nfs2;
20 		struct {
21 			__u64	used;
22 		} nfs3;
23 	} du;
24 	__u32			rdev;
25 	__u64			fsid;
26 	__u64			fileid;
27 	__u64			atime;
28 	__u64			mtime;
29 	__u64			ctime;
30 };
31 
32 #define NFS_ATTR_WCC		0x0001		/* pre-op WCC data    */
33 #define NFS_ATTR_FATTR		0x0002		/* post-op attributes */
34 #define NFS_ATTR_FATTR_V3	0x0004		/* NFSv3 attributes */
35 
36 /*
37  * Info on the file system
38  */
39 struct nfs_fsinfo {
40 	__u32			rtmax;	/* max.  read transfer size */
41 	__u32			rtpref;	/* pref. read transfer size */
42 	__u32			rtmult;	/* reads should be multiple of this */
43 	__u32			wtmax;	/* max.  write transfer size */
44 	__u32			wtpref;	/* pref. write transfer size */
45 	__u32			wtmult;	/* writes should be multiple of this */
46 	__u32			dtpref;	/* pref. readdir transfer size */
47 	__u64			maxfilesize;
48 	__u64			bsize;	/* block size */
49 	__u64			tbytes;	/* total size in bytes */
50 	__u64			fbytes;	/* # of free bytes */
51 	__u64			abytes;	/* # of bytes available to user */
52 	__u64			tfiles;	/* # of files */
53 	__u64			ffiles;	/* # of free files */
54 	__u64			afiles;	/* # of files available to user */
55 	__u32			linkmax;/* max # of hard links */
56 	__u32			namelen;/* max name length */
57 };
58 
59 /* Arguments to the read call.
60  * Note that NFS_READ_MAXIOV must be <= (MAX_IOVEC-2) from sunrpc/xprt.h
61  */
62 #define NFS_READ_MAXIOV		(9)
63 
64 struct nfs_readargs {
65 	struct nfs_fh *		fh;
66 	__u64			offset;
67 	__u32			count;
68 	unsigned int		pgbase;
69 	struct page **		pages;
70 };
71 
72 struct nfs_readres {
73 	struct nfs_fattr *	fattr;
74 	__u32			count;
75 	int                     eof;
76 };
77 
78 /* Arguments to the write call.
79  * Note that NFS_WRITE_MAXIOV must be <= (MAX_IOVEC-2) from sunrpc/xprt.h
80  */
81 #define NFS_WRITE_MAXIOV	(9)
82 struct nfs_writeargs {
83 	struct nfs_fh *		fh;
84 	__u64			offset;
85 	__u32			count;
86 	enum nfs3_stable_how	stable;
87 	unsigned int		pgbase;
88 	struct page **		pages;
89 };
90 
91 struct nfs_writeverf {
92 	enum nfs3_stable_how	committed;
93 	__u32			verifier[2];
94 };
95 
96 struct nfs_writeres {
97 	struct nfs_fattr *	fattr;
98 	struct nfs_writeverf *	verf;
99 	__u32			count;
100 };
101 
102 /*
103  * Argument struct for decode_entry function
104  */
105 struct nfs_entry {
106 	__u64			ino;
107 	__u64			cookie,
108 				prev_cookie;
109 	const char *		name;
110 	unsigned int		len;
111 	int			eof;
112 };
113 
114 /*
115  * The following types are for NFSv2 only.
116  */
117 struct nfs_sattrargs {
118 	struct nfs_fh *		fh;
119 	struct iattr *		sattr;
120 };
121 
122 struct nfs_diropargs {
123 	struct nfs_fh *		fh;
124 	const char *		name;
125 	unsigned int		len;
126 };
127 
128 struct nfs_createargs {
129 	struct nfs_fh *		fh;
130 	const char *		name;
131 	unsigned int		len;
132 	struct iattr *		sattr;
133 };
134 
135 struct nfs_renameargs {
136 	struct nfs_fh *		fromfh;
137 	const char *		fromname;
138 	unsigned int		fromlen;
139 	struct nfs_fh *		tofh;
140 	const char *		toname;
141 	unsigned int		tolen;
142 };
143 
144 struct nfs_linkargs {
145 	struct nfs_fh *		fromfh;
146 	struct nfs_fh *		tofh;
147 	const char *		toname;
148 	unsigned int		tolen;
149 };
150 
151 struct nfs_symlinkargs {
152 	struct nfs_fh *		fromfh;
153 	const char *		fromname;
154 	unsigned int		fromlen;
155 	const char *		topath;
156 	unsigned int		tolen;
157 	struct iattr *		sattr;
158 };
159 
160 struct nfs_readdirargs {
161 	struct nfs_fh *		fh;
162 	__u32			cookie;
163 	unsigned int		count;
164 	struct page **		pages;
165 };
166 
167 struct nfs_diropok {
168 	struct nfs_fh *		fh;
169 	struct nfs_fattr *	fattr;
170 };
171 
172 struct nfs_readlinkargs {
173 	struct nfs_fh *		fh;
174 	unsigned int		count;
175 	struct page **		pages;
176 };
177 
178 struct nfs3_sattrargs {
179 	struct nfs_fh *		fh;
180 	struct iattr *		sattr;
181 	unsigned int		guard;
182 	__u64			guardtime;
183 };
184 
185 struct nfs3_diropargs {
186 	struct nfs_fh *		fh;
187 	const char *		name;
188 	unsigned int		len;
189 };
190 
191 struct nfs3_accessargs {
192 	struct nfs_fh *		fh;
193 	__u32			access;
194 };
195 
196 struct nfs3_createargs {
197 	struct nfs_fh *		fh;
198 	const char *		name;
199 	unsigned int		len;
200 	struct iattr *		sattr;
201 	enum nfs3_createmode	createmode;
202 	__u32			verifier[2];
203 };
204 
205 struct nfs3_mkdirargs {
206 	struct nfs_fh *		fh;
207 	const char *		name;
208 	unsigned int		len;
209 	struct iattr *		sattr;
210 };
211 
212 struct nfs3_symlinkargs {
213 	struct nfs_fh *		fromfh;
214 	const char *		fromname;
215 	unsigned int		fromlen;
216 	const char *		topath;
217 	unsigned int		tolen;
218 	struct iattr *		sattr;
219 };
220 
221 struct nfs3_mknodargs {
222 	struct nfs_fh *		fh;
223 	const char *		name;
224 	unsigned int		len;
225 	enum nfs3_ftype		type;
226 	struct iattr *		sattr;
227 	dev_t			rdev;
228 };
229 
230 struct nfs3_renameargs {
231 	struct nfs_fh *		fromfh;
232 	const char *		fromname;
233 	unsigned int		fromlen;
234 	struct nfs_fh *		tofh;
235 	const char *		toname;
236 	unsigned int		tolen;
237 };
238 
239 struct nfs3_linkargs {
240 	struct nfs_fh *		fromfh;
241 	struct nfs_fh *		tofh;
242 	const char *		toname;
243 	unsigned int		tolen;
244 };
245 
246 struct nfs3_readdirargs {
247 	struct nfs_fh *		fh;
248 	__u64			cookie;
249 	__u32			verf[2];
250 	int			plus;
251 	unsigned int            count;
252 	struct page **		pages;
253 };
254 
255 struct nfs3_diropres {
256 	struct nfs_fattr *	dir_attr;
257 	struct nfs_fh *		fh;
258 	struct nfs_fattr *	fattr;
259 };
260 
261 struct nfs3_accessres {
262 	struct nfs_fattr *	fattr;
263 	__u32			access;
264 };
265 
266 struct nfs3_readlinkargs {
267 	struct nfs_fh *		fh;
268 	unsigned int		count;
269 	struct page **		pages;
270 };
271 
272 struct nfs3_renameres {
273 	struct nfs_fattr *	fromattr;
274 	struct nfs_fattr *	toattr;
275 };
276 
277 struct nfs3_linkres {
278 	struct nfs_fattr *	dir_attr;
279 	struct nfs_fattr *	fattr;
280 };
281 
282 struct nfs3_readdirres {
283 	struct nfs_fattr *	dir_attr;
284 	__u32 *			verf;
285 	int			plus;
286 };
287 
288 /*
289  * RPC procedure vector for NFSv2/NFSv3 demuxing
290  */
291 struct nfs_rpc_ops {
292 	int	version;		/* Protocol version */
293 
294 	int	(*getroot) (struct nfs_server *, struct nfs_fh *,
295 			    struct nfs_fattr *);
296 	int	(*getattr) (struct inode *, struct nfs_fattr *);
297 	int	(*setattr) (struct inode *, struct nfs_fattr *,
298 			    struct iattr *);
299 	int	(*lookup)  (struct inode *, struct qstr *,
300 			    struct nfs_fh *, struct nfs_fattr *);
301 	int	(*access)  (struct inode *, int , int);
302 	int	(*readlink)(struct inode *, struct page *);
303 	int	(*read)    (struct inode *, struct rpc_cred *,
304 			    struct nfs_fattr *,
305 			    int, unsigned int, unsigned int,
306 			    struct page *, int *eofp);
307 	int	(*write)   (struct inode *, struct rpc_cred *,
308 			    struct nfs_fattr *,
309 			    int, unsigned int, unsigned int,
310 			    struct page *, struct nfs_writeverf *verfp);
311 	int	(*commit)  (struct inode *, struct nfs_fattr *,
312 			    unsigned long, unsigned int);
313 	int	(*create)  (struct inode *, struct qstr *, struct iattr *,
314 			    int, struct nfs_fh *, struct nfs_fattr *);
315 	int	(*remove)  (struct inode *, struct qstr *);
316 	int	(*unlink_setup)  (struct rpc_message *,
317 			    struct dentry *, struct qstr *);
318 	void	(*unlink_done) (struct dentry *, struct rpc_message *);
319 	int	(*rename)  (struct inode *, struct qstr *,
320 			    struct inode *, struct qstr *);
321 	int	(*link)    (struct inode *, struct inode *, struct qstr *);
322 	int	(*symlink) (struct inode *, struct qstr *, struct qstr *,
323 			    struct iattr *, struct nfs_fh *,
324 			    struct nfs_fattr *);
325 	int	(*mkdir)   (struct inode *, struct qstr *, struct iattr *,
326 			    struct nfs_fh *, struct nfs_fattr *);
327 	int	(*rmdir)   (struct inode *, struct qstr *);
328 	int	(*readdir) (struct inode *, struct rpc_cred *,
329 			    u64, struct page *, unsigned int, int);
330 	int	(*mknod)   (struct inode *, struct qstr *, struct iattr *,
331 			    dev_t, struct nfs_fh *, struct nfs_fattr *);
332 	int	(*statfs)  (struct nfs_server *, struct nfs_fh *,
333 			    struct nfs_fsinfo *);
334 	u32 *	(*decode_dirent)(u32 *, struct nfs_entry *, int plus);
335 };
336 
337 /*
338  * 	NFS_CALL(getattr, inode, (fattr));
339  * into
340  *	NFS_PROTO(inode)->getattr(fattr);
341  */
342 #define NFS_CALL(op, inode, args)	NFS_PROTO(inode)->op args
343 
344 /*
345  * Function vectors etc. for the NFS client
346  */
347 extern struct nfs_rpc_ops	nfs_v2_clientops;
348 extern struct nfs_rpc_ops	nfs_v3_clientops;
349 extern struct rpc_version	nfs_version2;
350 extern struct rpc_version	nfs_version3;
351 extern struct rpc_program	nfs_program;
352 extern struct rpc_stat		nfs_rpcstat;
353 
354 #endif
355