Commit 9d787a75a00679c3ebcb88236a7af7b38a0b5932

Authored by Al Viro
Committed by Linus Torvalds
1 parent 52921e02a4

[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>

Showing 1 changed file with 37 additions and 37 deletions Side-by-side Diff

... ... @@ -66,15 +66,15 @@
66 66 /*
67 67 * Common NFS XDR functions as inlines
68 68 */
69   -static inline u32 *
70   -xdr_encode_fhandle(u32 *p, struct nfs_fh *fhandle)
  69 +static inline __be32 *
  70 +xdr_encode_fhandle(__be32 *p, struct nfs_fh *fhandle)
71 71 {
72 72 memcpy(p, fhandle->data, NFS2_FHSIZE);
73 73 return p + XDR_QUADLEN(NFS2_FHSIZE);
74 74 }
75 75  
76   -static inline u32 *
77   -xdr_decode_fhandle(u32 *p, struct nfs_fh *fhandle)
  76 +static inline __be32 *
  77 +xdr_decode_fhandle(__be32 *p, struct nfs_fh *fhandle)
78 78 {
79 79 /* NFSv2 handles have a fixed length */
80 80 fhandle->size = NFS2_FHSIZE;
... ... @@ -82,8 +82,8 @@
82 82 return p + XDR_QUADLEN(NFS2_FHSIZE);
83 83 }
84 84  
85   -static inline u32*
86   -xdr_encode_time(u32 *p, struct timespec *timep)
  85 +static inline __be32*
  86 +xdr_encode_time(__be32 *p, struct timespec *timep)
87 87 {
88 88 *p++ = htonl(timep->tv_sec);
89 89 /* Convert nanoseconds into microseconds */
... ... @@ -91,8 +91,8 @@
91 91 return p;
92 92 }
93 93  
94   -static inline u32*
95   -xdr_encode_current_server_time(u32 *p, struct timespec *timep)
  94 +static inline __be32*
  95 +xdr_encode_current_server_time(__be32 *p, struct timespec *timep)
96 96 {
97 97 /*
98 98 * Passing the invalid value useconds=1000000 is a
... ... @@ -108,8 +108,8 @@
108 108 return p;
109 109 }
110 110  
111   -static inline u32*
112   -xdr_decode_time(u32 *p, struct timespec *timep)
  111 +static inline __be32*
  112 +xdr_decode_time(__be32 *p, struct timespec *timep)
113 113 {
114 114 timep->tv_sec = ntohl(*p++);
115 115 /* Convert microseconds into nanoseconds */
... ... @@ -117,8 +117,8 @@
117 117 return p;
118 118 }
119 119  
120   -static u32 *
121   -xdr_decode_fattr(u32 *p, struct nfs_fattr *fattr)
  120 +static __be32 *
  121 +xdr_decode_fattr(__be32 *p, struct nfs_fattr *fattr)
122 122 {
123 123 u32 rdev;
124 124 fattr->type = (enum nfs_ftype) ntohl(*p++);
125 125  
... ... @@ -146,10 +146,10 @@
146 146 return p;
147 147 }
148 148  
149   -static inline u32 *
150   -xdr_encode_sattr(u32 *p, struct iattr *attr)
  149 +static inline __be32 *
  150 +xdr_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 154 *p++ = (attr->ia_valid & ATTR_MODE) ? htonl(attr->ia_mode) : not_set;
155 155 *p++ = (attr->ia_valid & ATTR_UID) ? htonl(attr->ia_uid) : not_set;
... ... @@ -184,7 +184,7 @@
184 184 * GETATTR, READLINK, STATFS
185 185 */
186 186 static int
187   -nfs_xdr_fhandle(struct rpc_rqst *req, u32 *p, struct nfs_fh *fh)
  187 +nfs_xdr_fhandle(struct rpc_rqst *req, __be32 *p, struct nfs_fh *fh)
188 188 {
189 189 p = xdr_encode_fhandle(p, fh);
190 190 req->rq_slen = xdr_adjust_iovec(req->rq_svec, p);
... ... @@ -195,7 +195,7 @@
195 195 * Encode SETATTR arguments
196 196 */
197 197 static int
198   -nfs_xdr_sattrargs(struct rpc_rqst *req, u32 *p, struct nfs_sattrargs *args)
  198 +nfs_xdr_sattrargs(struct rpc_rqst *req, __be32 *p, struct nfs_sattrargs *args)
199 199 {
200 200 p = xdr_encode_fhandle(p, args->fh);
201 201 p = xdr_encode_sattr(p, args->sattr);
... ... @@ -208,7 +208,7 @@
208 208 * LOOKUP, REMOVE, RMDIR
209 209 */
210 210 static int
211   -nfs_xdr_diropargs(struct rpc_rqst *req, u32 *p, struct nfs_diropargs *args)
  211 +nfs_xdr_diropargs(struct rpc_rqst *req, __be32 *p, struct nfs_diropargs *args)
212 212 {
213 213 p = xdr_encode_fhandle(p, args->fh);
214 214 p = xdr_encode_array(p, args->name, args->len);
... ... @@ -222,7 +222,7 @@
222 222 * exactly to the page we want to fetch.
223 223 */
224 224 static int
225   -nfs_xdr_readargs(struct rpc_rqst *req, u32 *p, struct nfs_readargs *args)
  225 +nfs_xdr_readargs(struct rpc_rqst *req, __be32 *p, struct nfs_readargs *args)
226 226 {
227 227 struct rpc_auth *auth = req->rq_task->tk_auth;
228 228 unsigned int replen;
... ... @@ -246,7 +246,7 @@
246 246 * Decode READ reply
247 247 */
248 248 static int
249   -nfs_xdr_readres(struct rpc_rqst *req, u32 *p, struct nfs_readres *res)
  249 +nfs_xdr_readres(struct rpc_rqst *req, __be32 *p, struct nfs_readres *res)
250 250 {
251 251 struct kvec *iov = req->rq_rcv_buf.head;
252 252 int status, count, recvd, hdrlen;
... ... @@ -286,7 +286,7 @@
286 286 * Write arguments. Splice the buffer to be written into the iovec.
287 287 */
288 288 static int
289   -nfs_xdr_writeargs(struct rpc_rqst *req, u32 *p, struct nfs_writeargs *args)
  289 +nfs_xdr_writeargs(struct rpc_rqst *req, __be32 *p, struct nfs_writeargs *args)
290 290 {
291 291 struct xdr_buf *sndbuf = &req->rq_snd_buf;
292 292 u32 offset = (u32)args->offset;
... ... @@ -309,7 +309,7 @@
309 309 * CREATE, MKDIR
310 310 */
311 311 static int
312   -nfs_xdr_createargs(struct rpc_rqst *req, u32 *p, struct nfs_createargs *args)
  312 +nfs_xdr_createargs(struct rpc_rqst *req, __be32 *p, struct nfs_createargs *args)
313 313 {
314 314 p = xdr_encode_fhandle(p, args->fh);
315 315 p = xdr_encode_array(p, args->name, args->len);
... ... @@ -322,7 +322,7 @@
322 322 * Encode RENAME arguments
323 323 */
324 324 static int
325   -nfs_xdr_renameargs(struct rpc_rqst *req, u32 *p, struct nfs_renameargs *args)
  325 +nfs_xdr_renameargs(struct rpc_rqst *req, __be32 *p, struct nfs_renameargs *args)
326 326 {
327 327 p = xdr_encode_fhandle(p, args->fromfh);
328 328 p = xdr_encode_array(p, args->fromname, args->fromlen);
... ... @@ -336,7 +336,7 @@
336 336 * Encode LINK arguments
337 337 */
338 338 static int
339   -nfs_xdr_linkargs(struct rpc_rqst *req, u32 *p, struct nfs_linkargs *args)
  339 +nfs_xdr_linkargs(struct rpc_rqst *req, __be32 *p, struct nfs_linkargs *args)
340 340 {
341 341 p = xdr_encode_fhandle(p, args->fromfh);
342 342 p = xdr_encode_fhandle(p, args->tofh);
... ... @@ -349,7 +349,7 @@
349 349 * Encode SYMLINK arguments
350 350 */
351 351 static int
352   -nfs_xdr_symlinkargs(struct rpc_rqst *req, u32 *p, struct nfs_symlinkargs *args)
  352 +nfs_xdr_symlinkargs(struct rpc_rqst *req, __be32 *p, struct nfs_symlinkargs *args)
353 353 {
354 354 struct xdr_buf *sndbuf = &req->rq_snd_buf;
355 355 size_t pad;
... ... @@ -378,7 +378,7 @@
378 378 * Encode arguments to readdir call
379 379 */
380 380 static int
381   -nfs_xdr_readdirargs(struct rpc_rqst *req, u32 *p, struct nfs_readdirargs *args)
  381 +nfs_xdr_readdirargs(struct rpc_rqst *req, __be32 *p, struct nfs_readdirargs *args)
382 382 {
383 383 struct rpc_task *task = req->rq_task;
384 384 struct rpc_auth *auth = task->tk_auth;
... ... @@ -404,7 +404,7 @@
404 404 * from nfs_readdir for each entry.
405 405 */
406 406 static int
407   -nfs_xdr_readdirres(struct rpc_rqst *req, u32 *p, void *dummy)
  407 +nfs_xdr_readdirres(struct rpc_rqst *req, __be32 *p, void *dummy)
408 408 {
409 409 struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
410 410 struct kvec *iov = rcvbuf->head;
... ... @@ -412,7 +412,7 @@
412 412 int hdrlen, recvd;
413 413 int status, nr;
414 414 unsigned int len, pglen;
415   - u32 *end, *entry, *kaddr;
  415 + __be32 *end, *entry, *kaddr;
416 416  
417 417 if ((status = ntohl(*p++)))
418 418 return -nfs_stat_to_errno(status);
... ... @@ -432,8 +432,8 @@
432 432 if (pglen > recvd)
433 433 pglen = recvd;
434 434 page = rcvbuf->pages;
435   - kaddr = p = (u32 *)kmap_atomic(*page, KM_USER0);
436   - end = (u32 *)((char *)p + pglen);
  435 + kaddr = p = kmap_atomic(*page, KM_USER0);
  436 + end = (__be32 *)((char *)p + pglen);
437 437 entry = p;
438 438 for (nr = 0; *p++; nr++) {
439 439 if (p + 2 > end)
... ... @@ -496,7 +496,7 @@
496 496 * Decode simple status reply
497 497 */
498 498 static int
499   -nfs_xdr_stat(struct rpc_rqst *req, u32 *p, void *dummy)
  499 +nfs_xdr_stat(struct rpc_rqst *req, __be32 *p, void *dummy)
500 500 {
501 501 int status;
502 502  
... ... @@ -510,7 +510,7 @@
510 510 * GETATTR, SETATTR, WRITE
511 511 */
512 512 static int
513   -nfs_xdr_attrstat(struct rpc_rqst *req, u32 *p, struct nfs_fattr *fattr)
  513 +nfs_xdr_attrstat(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
514 514 {
515 515 int status;
516 516  
... ... @@ -525,7 +525,7 @@
525 525 * LOOKUP, CREATE, MKDIR
526 526 */
527 527 static int
528   -nfs_xdr_diropres(struct rpc_rqst *req, u32 *p, struct nfs_diropok *res)
  528 +nfs_xdr_diropres(struct rpc_rqst *req, __be32 *p, struct nfs_diropok *res)
529 529 {
530 530 int status;
531 531  
... ... @@ -540,7 +540,7 @@
540 540 * Encode READLINK args
541 541 */
542 542 static int
543   -nfs_xdr_readlinkargs(struct rpc_rqst *req, u32 *p, struct nfs_readlinkargs *args)
  543 +nfs_xdr_readlinkargs(struct rpc_rqst *req, __be32 *p, struct nfs_readlinkargs *args)
544 544 {
545 545 struct rpc_auth *auth = req->rq_task->tk_auth;
546 546 unsigned int replen;
... ... @@ -558,7 +558,7 @@
558 558 * Decode READLINK reply
559 559 */
560 560 static int
561   -nfs_xdr_readlinkres(struct rpc_rqst *req, u32 *p, void *dummy)
  561 +nfs_xdr_readlinkres(struct rpc_rqst *req, __be32 *p, void *dummy)
562 562 {
563 563 struct xdr_buf *rcvbuf = &req->rq_rcv_buf;
564 564 struct kvec *iov = rcvbuf->head;
... ... @@ -601,7 +601,7 @@
601 601 * Decode WRITE reply
602 602 */
603 603 static int
604   -nfs_xdr_writeres(struct rpc_rqst *req, u32 *p, struct nfs_writeres *res)
  604 +nfs_xdr_writeres(struct rpc_rqst *req, __be32 *p, struct nfs_writeres *res)
605 605 {
606 606 res->verf->committed = NFS_FILE_SYNC;
607 607 return nfs_xdr_attrstat(req, p, res->fattr);
... ... @@ -611,7 +611,7 @@
611 611 * Decode STATFS reply
612 612 */
613 613 static int
614   -nfs_xdr_statfsres(struct rpc_rqst *req, u32 *p, struct nfs2_fsstat *res)
  614 +nfs_xdr_statfsres(struct rpc_rqst *req, __be32 *p, struct nfs2_fsstat *res)
615 615 {
616 616 int status;
617 617