aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs2xdr.c
diff options
context:
space:
mode:
authorAl Viro <viro@ftp.linux.org.uk>2006-10-20 02:28:47 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-20 13:26:40 -0400
commit9d787a75a00679c3ebcb88236a7af7b38a0b5932 (patch)
treeb897379d9bc846234b5449430c6bde0a0b5d9af0 /fs/nfs/nfs2xdr.c
parent52921e02a4f4163a7b1f4b5dde71e1debc71de4a (diff)
[PATCH] xdr annotations: NFSv2
on-the-wire data is big-endian [in large part pulled from Alexey's patch] Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Acked-by: Trond Myklebust <trond.myklebust@fys.uio.no> Acked-by: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/nfs/nfs2xdr.c')
-rw-r--r--fs/nfs/nfs2xdr.c74
1 files changed, 37 insertions, 37 deletions
diff --git a/fs/nfs/nfs2xdr.c b/fs/nfs/nfs2xdr.c
index b49501fc0a79..1d801e30c40e 100644
--- a/fs/nfs/nfs2xdr.c
+++ b/fs/nfs/nfs2xdr.c
@@ -66,15 +66,15 @@
66/* 66/*
67 * Common NFS XDR functions as inlines 67 * Common NFS XDR functions as inlines
68 */ 68 */
69static inline u32 * 69static inline __be32 *
70xdr_encode_fhandle(u32 *p, struct nfs_fh *fhandle) 70xdr_encode_fhandle(__be32 *p, struct nfs_fh *fhandle)
71{ 71{
72 memcpy(p, fhandle->data, NFS2_FHSIZE); 72 memcpy(p, fhandle->data, NFS2_FHSIZE);
73 return p + XDR_QUADLEN(NFS2_FHSIZE); 73 return p + XDR_QUADLEN(NFS2_FHSIZE);
74} 74}
75 75
76static inline u32 * 76static inline __be32 *
77xdr_decode_fhandle(u32 *p, struct nfs_fh *fhandle) 77xdr_decode_fhandle(__be32 *p, struct nfs_fh *fhandle)
78{ 78{
79 /* NFSv2 handles have a fixed length */ 79 /* NFSv2 handles have a fixed length */
80 fhandle->size = NFS2_FHSIZE; 80 fhandle->size = NFS2_FHSIZE;
@@ -82,8 +82,8 @@ xdr_decode_fhandle(u32 *p, struct nfs_fh *fhandle)
82 return p + XDR_QUADLEN(NFS2_FHSIZE); 82 return p + XDR_QUADLEN(NFS2_FHSIZE);
83} 83}
84 84
85static inline u32* 85static inline __be32*
86xdr_encode_time(u32 *p, struct timespec *timep) 86xdr_encode_time(__be32 *p, struct timespec *timep)
87{ 87{
88 *p++ = htonl(timep->tv_sec); 88 *p++ = htonl(timep->tv_sec);
89 /* Convert nanoseconds into microseconds */ 89 /* Convert nanoseconds into microseconds */
@@ -91,8 +91,8 @@ xdr_encode_time(u32 *p, struct timespec *timep)
91 return p; 91 return p;
92} 92}
93 93
94static inline u32* 94static inline __be32*
95xdr_encode_current_server_time(u32 *p, struct timespec *timep) 95xdr_encode_current_server_time(__be32 *p, struct timespec *timep)
96{ 96{
97 /* 97 /*
98 * Passing the invalid value useconds=1000000 is a 98 * Passing the invalid value useconds=1000000 is a
@@ -108,8 +108,8 @@ xdr_encode_current_server_time(u32 *p, struct timespec *timep)
108 return p; 108 return p;
109} 109}
110 110
111static inline u32* 111static inline __be32*
112xdr_decode_time(u32 *p, struct timespec *timep) 112xdr_decode_time(__be32 *p, struct timespec *timep)
113{ 113{
114 timep->tv_sec = ntohl(*p++); 114 timep->tv_sec = ntohl(*p++);
115 /* Convert microseconds into nanoseconds */ 115 /* Convert microseconds into nanoseconds */
@@ -117,8 +117,8 @@ xdr_decode_time(u32 *p, struct timespec *timep)
117 return p; 117 return p;
118} 118}
119 119
120static u32 * 120static __be32 *
121xdr_decode_fattr(u32 *p, struct nfs_fattr *fattr) 121xdr_decode_fattr(__be32 *p, struct nfs_fattr *fattr)
122{ 122{
123 u32 rdev; 123 u32 rdev;
124 fattr->type = (enum nfs_ftype) ntohl(*p++); 124 fattr->type = (enum nfs_ftype) ntohl(*p++);
@@ -146,10 +146,10 @@ xdr_decode_fattr(u32 *p, struct nfs_fattr *fattr)
146 return p; 146 return p;
147} 147}
148 148
149static inline u32 * 149static inline __be32 *
150xdr_encode_sattr(u32 *p, struct iattr *attr) 150xdr_encode_sattr(__be32 *p, struct iattr *attr)
151{ 151{
152 const u32 not_set = __constant_htonl(0xFFFFFFFF); 152 const __be32 not_set = __constant_htonl(0xFFFFFFFF);
153 153
154 *p++ = (attr->ia_valid & ATTR_MODE) ? htonl(attr->ia_mode) : not_set; 154 *p++ = (attr->ia_valid & ATTR_MODE) ? htonl(attr->ia_mode) : not_set;
155 *p++ = (attr->ia_valid & ATTR_UID) ? htonl(attr->ia_uid) : not_set; 155 *p++ = (attr->ia_valid & ATTR_UID) ? htonl(attr->ia_uid) : not_set;
@@ -184,7 +184,7 @@ xdr_encode_sattr(u32 *p, struct iattr *attr)
184 * GETATTR, READLINK, STATFS 184 * GETATTR, READLINK, STATFS
185 */ 185 */
186static int 186static int
187nfs_xdr_fhandle(struct rpc_rqst *req, u32 *p, struct nfs_fh *fh) 187nfs_xdr_fhandle(struct rpc_rqst *req, __be32 *p, struct nfs_fh *fh)
188{ 188{
189 p = xdr_encode_fhandle(p, fh); 189 p = xdr_encode_fhandle(p, fh);
190 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p); 190 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
@@ -195,7 +195,7 @@ nfs_xdr_fhandle(struct rpc_rqst *req, u32 *p, struct nfs_fh *fh)
195 * Encode SETATTR arguments 195 * Encode SETATTR arguments
196 */ 196 */
197static int 197static int
198nfs_xdr_sattrargs(struct rpc_rqst *req, u32 *p, struct nfs_sattrargs *args) 198nfs_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs_sattrargs *args)
199{ 199{
200 p = xdr_encode_fhandle(p, args->fh); 200 p = xdr_encode_fhandle(p, args->fh);
201 p = xdr_encode_sattr(p, args->sattr); 201 p = xdr_encode_sattr(p, args->sattr);
@@ -208,7 +208,7 @@ nfs_xdr_sattrargs(struct rpc_rqst *req, u32 *p, struct nfs_sattrargs *args)
208 * LOOKUP, REMOVE, RMDIR 208 * LOOKUP, REMOVE, RMDIR
209 */ 209 */
210static int 210static int
211nfs_xdr_diropargs(struct rpc_rqst *req, u32 *p, struct nfs_diropargs *args) 211nfs_xdr_diropargs(struct rpc_rqst *req, __be32 *p, struct nfs_diropargs *args)
212{ 212{
213 p = xdr_encode_fhandle(p, args->fh); 213 p = xdr_encode_fhandle(p, args->fh);
214 p = xdr_encode_array(p, args->name, args->len); 214 p = xdr_encode_array(p, args->name, args->len);
@@ -222,7 +222,7 @@ nfs_xdr_diropargs(struct rpc_rqst *req, u32 *p, struct nfs_diropargs *args)
222 * exactly to the page we want to fetch. 222 * exactly to the page we want to fetch.
223 */ 223 */
224static int 224static int
225nfs_xdr_readargs(struct rpc_rqst *req, u32 *p, struct nfs_readargs *args) 225nfs_xdr_readargs(struct rpc_rqst *req, __be32 *p, struct nfs_readargs *args)
226{ 226{
227 struct rpc_auth *auth = req->rq_task->tk_auth; 227 struct rpc_auth *auth = req->rq_task->tk_auth;
228 unsigned int replen; 228 unsigned int replen;
@@ -246,7 +246,7 @@ nfs_xdr_readargs(struct rpc_rqst *req, u32 *p, struct nfs_readargs *args)
246 * Decode READ reply 246 * Decode READ reply
247 */ 247 */
248static int 248static int
249nfs_xdr_readres(struct rpc_rqst *req, u32 *p, struct nfs_readres *res) 249nfs_xdr_readres(struct rpc_rqst *req, __be32 *p, struct nfs_readres *res)
250{ 250{
251 struct kvec *iov = req->rq_rcv_buf.head; 251 struct kvec *iov = req->rq_rcv_buf.head;
252 int status, count, recvd, hdrlen; 252 int status, count, recvd, hdrlen;
@@ -286,7 +286,7 @@ nfs_xdr_readres(struct rpc_rqst *req, u32 *p, struct nfs_readres *res)
286 * Write arguments. Splice the buffer to be written into the iovec. 286 * Write arguments. Splice the buffer to be written into the iovec.
287 */ 287 */
288static int 288static int
289nfs_xdr_writeargs(struct rpc_rqst *req, u32 *p, struct nfs_writeargs *args) 289nfs_xdr_writeargs(struct rpc_rqst *req, __be32 *p, struct nfs_writeargs *args)
290{ 290{
291 struct xdr_buf *sndbuf = &req->rq_snd_buf; 291 struct xdr_buf *sndbuf = &req->rq_snd_buf;
292 u32 offset = (u32)args->offset; 292 u32 offset = (u32)args->offset;
@@ -309,7 +309,7 @@ nfs_xdr_writeargs(struct rpc_rqst *req, u32 *p, struct nfs_writeargs *args)
309 * CREATE, MKDIR 309 * CREATE, MKDIR
310 */ 310 */
311static int 311static int
312nfs_xdr_createargs(struct rpc_rqst *req, u32 *p, struct nfs_createargs *args) 312nfs_xdr_createargs(struct rpc_rqst *req, __be32 *p, struct nfs_createargs *args)
313{ 313{
314 p = xdr_encode_fhandle(p, args->fh); 314 p = xdr_encode_fhandle(p, args->fh);
315 p = xdr_encode_array(p, args->name, args->len); 315 p = xdr_encode_array(p, args->name, args->len);
@@ -322,7 +322,7 @@ nfs_xdr_createargs(struct rpc_rqst *req, u32 *p, struct nfs_createargs *args)
322 * Encode RENAME arguments 322 * Encode RENAME arguments
323 */ 323 */
324static int 324static int
325nfs_xdr_renameargs(struct rpc_rqst *req, u32 *p, struct nfs_renameargs *args) 325nfs_xdr_renameargs(struct rpc_rqst *req, __be32 *p, struct nfs_renameargs *args)
326{ 326{
327 p = xdr_encode_fhandle(p, args->fromfh); 327 p = xdr_encode_fhandle(p, args->fromfh);
328 p = xdr_encode_array(p, args->fromname, args->fromlen); 328 p = xdr_encode_array(p, args->fromname, args->fromlen);
@@ -336,7 +336,7 @@ nfs_xdr_renameargs(struct rpc_rqst *req, u32 *p, struct nfs_renameargs *args)
336 * Encode LINK arguments 336 * Encode LINK arguments
337 */ 337 */
338static int 338static int
339nfs_xdr_linkargs(struct rpc_rqst *req, u32 *p, struct nfs_linkargs *args) 339nfs_xdr_linkargs(struct rpc_rqst *req, __be32 *p, struct nfs_linkargs *args)
340{ 340{
341 p = xdr_encode_fhandle(p, args->fromfh); 341 p = xdr_encode_fhandle(p, args->fromfh);
342 p = xdr_encode_fhandle(p, args->tofh); 342 p = xdr_encode_fhandle(p, args->tofh);
@@ -349,7 +349,7 @@ nfs_xdr_linkargs(struct rpc_rqst *req, u32 *p, struct nfs_linkargs *args)
349 * Encode SYMLINK arguments 349 * Encode SYMLINK arguments
350 */ 350 */
351static int 351static int
352nfs_xdr_symlinkargs(struct rpc_rqst *req, u32 *p, struct nfs_symlinkargs *args) 352nfs_xdr_symlinkargs(struct rpc_rqst *req, __be32 *p, struct nfs_symlinkargs *args)
353{ 353{
354 struct xdr_buf *sndbuf = &req->rq_snd_buf; 354 struct xdr_buf *sndbuf = &req->rq_snd_buf;
355 size_t pad; 355 size_t pad;
@@ -378,7 +378,7 @@ nfs_xdr_symlinkargs(struct rpc_rqst *req, u32 *p, struct nfs_symlinkargs *args)
378 * Encode arguments to readdir call 378 * Encode arguments to readdir call
379 */ 379 */
380static int 380static int
381nfs_xdr_readdirargs(struct rpc_rqst *req, u32 *p, struct nfs_readdirargs *args) 381nfs_xdr_readdirargs(struct rpc_rqst *req, __be32 *p, struct nfs_readdirargs *args)
382{ 382{
383 struct rpc_task *task = req->rq_task; 383 struct rpc_task *task = req->rq_task;
384 struct rpc_auth *auth = task->tk_auth; 384 struct rpc_auth *auth = task->tk_auth;
@@ -404,7 +404,7 @@ nfs_xdr_readdirargs(struct rpc_rqst *req, u32 *p, struct nfs_readdirargs *args)
404 * from nfs_readdir for each entry. 404 * from nfs_readdir for each entry.
405 */ 405 */
406static int 406static int
407nfs_xdr_readdirres(struct rpc_rqst *req, u32 *p, void *dummy) 407nfs_xdr_readdirres(struct rpc_rqst *req, __be32 *p, void *dummy)
408{ 408{
409 struct xdr_buf *rcvbuf = &req->rq_rcv_buf; 409 struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
410 struct kvec *iov = rcvbuf->head; 410 struct kvec *iov = rcvbuf->head;
@@ -412,7 +412,7 @@ nfs_xdr_readdirres(struct rpc_rqst *req, u32 *p, void *dummy)
412 int hdrlen, recvd; 412 int hdrlen, recvd;
413 int status, nr; 413 int status, nr;
414 unsigned int len, pglen; 414 unsigned int len, pglen;
415 u32 *end, *entry, *kaddr; 415 __be32 *end, *entry, *kaddr;
416 416
417 if ((status = ntohl(*p++))) 417 if ((status = ntohl(*p++)))
418 return -nfs_stat_to_errno(status); 418 return -nfs_stat_to_errno(status);
@@ -432,8 +432,8 @@ nfs_xdr_readdirres(struct rpc_rqst *req, u32 *p, void *dummy)
432 if (pglen > recvd) 432 if (pglen > recvd)
433 pglen = recvd; 433 pglen = recvd;
434 page = rcvbuf->pages; 434 page = rcvbuf->pages;
435 kaddr = p = (u32 *)kmap_atomic(*page, KM_USER0); 435 kaddr = p = kmap_atomic(*page, KM_USER0);
436 end = (u32 *)((char *)p + pglen); 436 end = (__be32 *)((char *)p + pglen);
437 entry = p; 437 entry = p;
438 for (nr = 0; *p++; nr++) { 438 for (nr = 0; *p++; nr++) {
439 if (p + 2 > end) 439 if (p + 2 > end)
@@ -496,7 +496,7 @@ nfs_decode_dirent(u32 *p, struct nfs_entry *entry, int plus)
496 * Decode simple status reply 496 * Decode simple status reply
497 */ 497 */
498static int 498static int
499nfs_xdr_stat(struct rpc_rqst *req, u32 *p, void *dummy) 499nfs_xdr_stat(struct rpc_rqst *req, __be32 *p, void *dummy)
500{ 500{
501 int status; 501 int status;
502 502
@@ -510,7 +510,7 @@ nfs_xdr_stat(struct rpc_rqst *req, u32 *p, void *dummy)
510 * GETATTR, SETATTR, WRITE 510 * GETATTR, SETATTR, WRITE
511 */ 511 */
512static int 512static int
513nfs_xdr_attrstat(struct rpc_rqst *req, u32 *p, struct nfs_fattr *fattr) 513nfs_xdr_attrstat(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
514{ 514{
515 int status; 515 int status;
516 516
@@ -525,7 +525,7 @@ nfs_xdr_attrstat(struct rpc_rqst *req, u32 *p, struct nfs_fattr *fattr)
525 * LOOKUP, CREATE, MKDIR 525 * LOOKUP, CREATE, MKDIR
526 */ 526 */
527static int 527static int
528nfs_xdr_diropres(struct rpc_rqst *req, u32 *p, struct nfs_diropok *res) 528nfs_xdr_diropres(struct rpc_rqst *req, __be32 *p, struct nfs_diropok *res)
529{ 529{
530 int status; 530 int status;
531 531
@@ -540,7 +540,7 @@ nfs_xdr_diropres(struct rpc_rqst *req, u32 *p, struct nfs_diropok *res)
540 * Encode READLINK args 540 * Encode READLINK args
541 */ 541 */
542static int 542static int
543nfs_xdr_readlinkargs(struct rpc_rqst *req, u32 *p, struct nfs_readlinkargs *args) 543nfs_xdr_readlinkargs(struct rpc_rqst *req, __be32 *p, struct nfs_readlinkargs *args)
544{ 544{
545 struct rpc_auth *auth = req->rq_task->tk_auth; 545 struct rpc_auth *auth = req->rq_task->tk_auth;
546 unsigned int replen; 546 unsigned int replen;
@@ -558,7 +558,7 @@ nfs_xdr_readlinkargs(struct rpc_rqst *req, u32 *p, struct nfs_readlinkargs *args
558 * Decode READLINK reply 558 * Decode READLINK reply
559 */ 559 */
560static int 560static int
561nfs_xdr_readlinkres(struct rpc_rqst *req, u32 *p, void *dummy) 561nfs_xdr_readlinkres(struct rpc_rqst *req, __be32 *p, void *dummy)
562{ 562{
563 struct xdr_buf *rcvbuf = &req->rq_rcv_buf; 563 struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
564 struct kvec *iov = rcvbuf->head; 564 struct kvec *iov = rcvbuf->head;
@@ -601,7 +601,7 @@ nfs_xdr_readlinkres(struct rpc_rqst *req, u32 *p, void *dummy)
601 * Decode WRITE reply 601 * Decode WRITE reply
602 */ 602 */
603static int 603static int
604nfs_xdr_writeres(struct rpc_rqst *req, u32 *p, struct nfs_writeres *res) 604nfs_xdr_writeres(struct rpc_rqst *req, __be32 *p, struct nfs_writeres *res)
605{ 605{
606 res->verf->committed = NFS_FILE_SYNC; 606 res->verf->committed = NFS_FILE_SYNC;
607 return nfs_xdr_attrstat(req, p, res->fattr); 607 return nfs_xdr_attrstat(req, p, res->fattr);
@@ -611,7 +611,7 @@ nfs_xdr_writeres(struct rpc_rqst *req, u32 *p, struct nfs_writeres *res)
611 * Decode STATFS reply 611 * Decode STATFS reply
612 */ 612 */
613static int 613static int
614nfs_xdr_statfsres(struct rpc_rqst *req, u32 *p, struct nfs2_fsstat *res) 614nfs_xdr_statfsres(struct rpc_rqst *req, __be32 *p, struct nfs2_fsstat *res)
615{ 615{
616 int status; 616 int status;
617 617