nfs4xdr.c (c5c34f5793f384ed2895584c6e2350b059c3f161) nfs4xdr.c (16c663642c7ec03cd4cee5fec520bb69e97babe4)
1/*
2 * Server-side XDR for NFSv4
3 *
4 * Copyright (c) 2002 The Regents of the University of Michigan.
5 * All rights reserved.
6 *
7 * Kendrick Smith <kmsmith@umich.edu>
8 * Andy Adamson <andros@umich.edu>

--- 3096 unchanged lines hidden (view full) ---

3105 if (!p)
3106 goto out_resource;
3107 *p++ = cpu_to_be32(1);
3108 }
3109 if (bmval0 & FATTR4_WORD0_FILEHANDLE) {
3110 p = xdr_reserve_space(xdr, fhp->fh_handle.fh_size + 4);
3111 if (!p)
3112 goto out_resource;
1/*
2 * Server-side XDR for NFSv4
3 *
4 * Copyright (c) 2002 The Regents of the University of Michigan.
5 * All rights reserved.
6 *
7 * Kendrick Smith <kmsmith@umich.edu>
8 * Andy Adamson <andros@umich.edu>

--- 3096 unchanged lines hidden (view full) ---

3105 if (!p)
3106 goto out_resource;
3107 *p++ = cpu_to_be32(1);
3108 }
3109 if (bmval0 & FATTR4_WORD0_FILEHANDLE) {
3110 p = xdr_reserve_space(xdr, fhp->fh_handle.fh_size + 4);
3111 if (!p)
3112 goto out_resource;
3113 p = xdr_encode_opaque(p, &fhp->fh_handle.fh_base,
3113 p = xdr_encode_opaque(p, &fhp->fh_handle.fh_raw,
3114 fhp->fh_handle.fh_size);
3115 }
3116 if (bmval0 & FATTR4_WORD0_FILEID) {
3117 p = xdr_reserve_space(xdr, 8);
3118 if (!p)
3119 goto out_resource;
3120 p = xdr_encode_hyper(p, stat.ino);
3121 }

--- 417 unchanged lines hidden (view full) ---

3539 }
3540 }
3541 nfserr = nfserr_toosmall;
3542 entry_bytes = xdr->buf->len - start_offset;
3543 if (entry_bytes > cd->rd_maxcount)
3544 goto fail;
3545 cd->rd_maxcount -= entry_bytes;
3546 /*
3114 fhp->fh_handle.fh_size);
3115 }
3116 if (bmval0 & FATTR4_WORD0_FILEID) {
3117 p = xdr_reserve_space(xdr, 8);
3118 if (!p)
3119 goto out_resource;
3120 p = xdr_encode_hyper(p, stat.ino);
3121 }

--- 417 unchanged lines hidden (view full) ---

3539 }
3540 }
3541 nfserr = nfserr_toosmall;
3542 entry_bytes = xdr->buf->len - start_offset;
3543 if (entry_bytes > cd->rd_maxcount)
3544 goto fail;
3545 cd->rd_maxcount -= entry_bytes;
3546 /*
3547 * RFC 3530 14.2.24 describes rd_dircount as only a "hint", and
3548 * notes that it could be zero. If it is zero, then the server
3549 * should enforce only the rd_maxcount value.
3547 * RFC 3530 14.2.24 describes rd_dircount as only a "hint", so
3548 * let's always let through the first entry, at least:
3550 */
3549 */
3551 if (cd->rd_dircount) {
3552 name_and_cookie = 4 + 4 * XDR_QUADLEN(namlen) + 8;
3553 if (name_and_cookie > cd->rd_dircount && cd->cookie_offset)
3554 goto fail;
3555 cd->rd_dircount -= min(cd->rd_dircount, name_and_cookie);
3556 if (!cd->rd_dircount)
3557 cd->rd_maxcount = 0;
3558 }
3550 if (!cd->rd_dircount)
3551 goto fail;
3552 name_and_cookie = 4 + 4 * XDR_QUADLEN(namlen) + 8;
3553 if (name_and_cookie > cd->rd_dircount && cd->cookie_offset)
3554 goto fail;
3555 cd->rd_dircount -= min(cd->rd_dircount, name_and_cookie);
3559
3560 cd->cookie_offset = cookie_offset;
3561skip_entry:
3562 cd->common.err = nfs_ok;
3563 return 0;
3564fail:
3565 xdr_truncate_encode(xdr, start_offset);
3566 cd->common.err = nfserr;

--- 98 unchanged lines hidden (view full) ---

3665 struct svc_fh *fhp = *fhpp;
3666 unsigned int len;
3667 __be32 *p;
3668
3669 len = fhp->fh_handle.fh_size;
3670 p = xdr_reserve_space(xdr, len + 4);
3671 if (!p)
3672 return nfserr_resource;
3556
3557 cd->cookie_offset = cookie_offset;
3558skip_entry:
3559 cd->common.err = nfs_ok;
3560 return 0;
3561fail:
3562 xdr_truncate_encode(xdr, start_offset);
3563 cd->common.err = nfserr;

--- 98 unchanged lines hidden (view full) ---

3662 struct svc_fh *fhp = *fhpp;
3663 unsigned int len;
3664 __be32 *p;
3665
3666 len = fhp->fh_handle.fh_size;
3667 p = xdr_reserve_space(xdr, len + 4);
3668 if (!p)
3669 return nfserr_resource;
3673 p = xdr_encode_opaque(p, &fhp->fh_handle.fh_base, len);
3670 p = xdr_encode_opaque(p, &fhp->fh_handle.fh_raw, len);
3674 return 0;
3675}
3676
3677/*
3678* Including all fields other than the name, a LOCK4denied structure requires
3679* 8(clientid) + 4(namelen) + 8(offset) + 8(length) + 4(type) = 32 bytes.
3680*/
3681static __be32

--- 1728 unchanged lines hidden (view full) ---

5410 while (args->to_free) {
5411 struct svcxdr_tmpbuf *tb = args->to_free;
5412 args->to_free = tb->next;
5413 kfree(tb);
5414 }
5415}
5416
5417int
3671 return 0;
3672}
3673
3674/*
3675* Including all fields other than the name, a LOCK4denied structure requires
3676* 8(clientid) + 4(namelen) + 8(offset) + 8(length) + 4(type) = 32 bytes.
3677*/
3678static __be32

--- 1728 unchanged lines hidden (view full) ---

5407 while (args->to_free) {
5408 struct svcxdr_tmpbuf *tb = args->to_free;
5409 args->to_free = tb->next;
5410 kfree(tb);
5411 }
5412}
5413
5414int
5418nfs4svc_decode_compoundargs(struct svc_rqst *rqstp, __be32 *p)
5415nfs4svc_decode_compoundargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
5419{
5420 struct nfsd4_compoundargs *args = rqstp->rq_argp;
5421
5422 /* svcxdr_tmp_alloc */
5423 args->to_free = NULL;
5424
5416{
5417 struct nfsd4_compoundargs *args = rqstp->rq_argp;
5418
5419 /* svcxdr_tmp_alloc */
5420 args->to_free = NULL;
5421
5425 args->xdr = &rqstp->rq_arg_stream;
5422 args->xdr = xdr;
5426 args->ops = args->iops;
5427 args->rqstp = rqstp;
5428
5429 return nfsd4_decode_compound(args);
5430}
5431
5432int
5433nfs4svc_encode_compoundres(struct svc_rqst *rqstp, __be32 *p)

--- 20 unchanged lines hidden ---
5423 args->ops = args->iops;
5424 args->rqstp = rqstp;
5425
5426 return nfsd4_decode_compound(args);
5427}
5428
5429int
5430nfs4svc_encode_compoundres(struct svc_rqst *rqstp, __be32 *p)

--- 20 unchanged lines hidden ---