nfs4xdr.c (4d68c05ce11f4cdf6a6392f3a18dc6a985b4d0c4) nfs4xdr.c (2c8bd7e0d1b66b2f8f267fd6ab62a30569c792c0)
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>

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

633 READ_BUF(lookup->lo_len);
634 SAVEMEM(lookup->lo_name, lookup->lo_len);
635 if ((status = check_filename(lookup->lo_name, lookup->lo_len, nfserr_noent)))
636 return status;
637
638 DECODE_TAIL;
639}
640
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>

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

633 READ_BUF(lookup->lo_len);
634 SAVEMEM(lookup->lo_name, lookup->lo_len);
635 if ((status = check_filename(lookup->lo_name, lookup->lo_len, nfserr_noent)))
636 return status;
637
638 DECODE_TAIL;
639}
640
641static __be32 nfsd4_decode_share_access(struct nfsd4_compoundargs *argp, u32 *x)
641static __be32 nfsd4_decode_share_access(struct nfsd4_compoundargs *argp, u32 *share_access, u32 *deleg_want, u32 *deleg_when)
642{
643 __be32 *p;
644 u32 w;
645
646 READ_BUF(4);
647 READ32(w);
642{
643 __be32 *p;
644 u32 w;
645
646 READ_BUF(4);
647 READ32(w);
648 *x = w;
648 *share_access = w & NFS4_SHARE_ACCESS_MASK;
649 *deleg_want = w & NFS4_SHARE_WANT_MASK;
650 if (deleg_when)
651 *deleg_when = w & NFS4_SHARE_WHEN_MASK;
652
649 switch (w & NFS4_SHARE_ACCESS_MASK) {
650 case NFS4_SHARE_ACCESS_READ:
651 case NFS4_SHARE_ACCESS_WRITE:
652 case NFS4_SHARE_ACCESS_BOTH:
653 break;
654 default:
655 return nfserr_bad_xdr;
656 }

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

668 case NFS4_SHARE_WANT_CANCEL:
669 break;
670 default:
671 return nfserr_bad_xdr;
672 }
673 w &= ~NFS4_SHARE_WANT_MASK;
674 if (!w)
675 return nfs_ok;
653 switch (w & NFS4_SHARE_ACCESS_MASK) {
654 case NFS4_SHARE_ACCESS_READ:
655 case NFS4_SHARE_ACCESS_WRITE:
656 case NFS4_SHARE_ACCESS_BOTH:
657 break;
658 default:
659 return nfserr_bad_xdr;
660 }

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

672 case NFS4_SHARE_WANT_CANCEL:
673 break;
674 default:
675 return nfserr_bad_xdr;
676 }
677 w &= ~NFS4_SHARE_WANT_MASK;
678 if (!w)
679 return nfs_ok;
680
681 if (!deleg_when) /* open_downgrade */
682 return nfserr_inval;
676 switch (w) {
677 case NFS4_SHARE_SIGNAL_DELEG_WHEN_RESRC_AVAIL:
678 case NFS4_SHARE_PUSH_DELEG_WHEN_UNCONTENDED:
679 case (NFS4_SHARE_SIGNAL_DELEG_WHEN_RESRC_AVAIL |
680 NFS4_SHARE_PUSH_DELEG_WHEN_UNCONTENDED):
681 return nfs_ok;
682 }
683xdr_error:

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

714xdr_error:
715 return nfserr_bad_xdr;
716}
717
718static __be32
719nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open)
720{
721 DECODE_HEAD;
683 switch (w) {
684 case NFS4_SHARE_SIGNAL_DELEG_WHEN_RESRC_AVAIL:
685 case NFS4_SHARE_PUSH_DELEG_WHEN_UNCONTENDED:
686 case (NFS4_SHARE_SIGNAL_DELEG_WHEN_RESRC_AVAIL |
687 NFS4_SHARE_PUSH_DELEG_WHEN_UNCONTENDED):
688 return nfs_ok;
689 }
690xdr_error:

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

721xdr_error:
722 return nfserr_bad_xdr;
723}
724
725static __be32
726nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open)
727{
728 DECODE_HEAD;
729 u32 dummy;
722
723 memset(open->op_bmval, 0, sizeof(open->op_bmval));
724 open->op_iattr.ia_valid = 0;
725 open->op_openowner = NULL;
726
727 /* seqid, share_access, share_deny, clientid, ownerlen */
728 READ_BUF(4);
729 READ32(open->op_seqid);
730
731 memset(open->op_bmval, 0, sizeof(open->op_bmval));
732 open->op_iattr.ia_valid = 0;
733 open->op_openowner = NULL;
734
735 /* seqid, share_access, share_deny, clientid, ownerlen */
736 READ_BUF(4);
737 READ32(open->op_seqid);
730 status = nfsd4_decode_share_access(argp, &open->op_share_access);
738 /* decode, yet ignore deleg_when until supported */
739 status = nfsd4_decode_share_access(argp, &open->op_share_access,
740 &open->op_deleg_want, &dummy);
731 if (status)
732 goto xdr_error;
733 status = nfsd4_decode_share_deny(argp, &open->op_share_deny);
734 if (status)
735 goto xdr_error;
736 READ_BUF(sizeof(clientid_t));
737 COPYMEM(&open->op_clientid, sizeof(clientid_t));
738 status = nfsd4_decode_opaque(argp, &open->op_owner);

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

843{
844 DECODE_HEAD;
845
846 status = nfsd4_decode_stateid(argp, &open_down->od_stateid);
847 if (status)
848 return status;
849 READ_BUF(4);
850 READ32(open_down->od_seqid);
741 if (status)
742 goto xdr_error;
743 status = nfsd4_decode_share_deny(argp, &open->op_share_deny);
744 if (status)
745 goto xdr_error;
746 READ_BUF(sizeof(clientid_t));
747 COPYMEM(&open->op_clientid, sizeof(clientid_t));
748 status = nfsd4_decode_opaque(argp, &open->op_owner);

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

853{
854 DECODE_HEAD;
855
856 status = nfsd4_decode_stateid(argp, &open_down->od_stateid);
857 if (status)
858 return status;
859 READ_BUF(4);
860 READ32(open_down->od_seqid);
851 status = nfsd4_decode_share_access(argp, &open_down->od_share_access);
861 status = nfsd4_decode_share_access(argp, &open_down->od_share_access,
862 &open_down->od_deleg_want, NULL);
852 if (status)
853 return status;
854 status = nfsd4_decode_share_deny(argp, &open_down->od_share_deny);
855 if (status)
856 return status;
857 DECODE_TAIL;
858}
859

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

3527 length = xb->head[0].iov_len + xb->page_len + tlen + pad;
3528 }
3529 dprintk("%s length %u, xb->page_len %u tlen %u pad %u\n", __func__,
3530 length, xb->page_len, tlen, pad);
3531
3532 if (length > session->se_fchannel.maxresp_sz)
3533 return nfserr_rep_too_big;
3534
863 if (status)
864 return status;
865 status = nfsd4_decode_share_deny(argp, &open_down->od_share_deny);
866 if (status)
867 return status;
868 DECODE_TAIL;
869}
870

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

3538 length = xb->head[0].iov_len + xb->page_len + tlen + pad;
3539 }
3540 dprintk("%s length %u, xb->page_len %u tlen %u pad %u\n", __func__,
3541 length, xb->page_len, tlen, pad);
3542
3543 if (length > session->se_fchannel.maxresp_sz)
3544 return nfserr_rep_too_big;
3545
3535 if (slot->sl_cachethis == 1 &&
3546 if ((slot->sl_flags & NFSD4_SLOT_CACHETHIS) &&
3536 length > session->se_fchannel.maxresp_cached)
3537 return nfserr_rep_too_big_to_cache;
3538
3539 return 0;
3540}
3541
3542void
3543nfsd4_encode_operation(struct nfsd4_compoundres *resp, struct nfsd4_op *op)

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

3651 iov = &rqstp->rq_res.tail[0];
3652 else
3653 iov = &rqstp->rq_res.head[0];
3654 iov->iov_len = ((char*)resp->p) - (char*)iov->iov_base;
3655 BUG_ON(iov->iov_len > PAGE_SIZE);
3656 if (nfsd4_has_session(cs)) {
3657 if (cs->status != nfserr_replay_cache) {
3658 nfsd4_store_cache_entry(resp);
3547 length > session->se_fchannel.maxresp_cached)
3548 return nfserr_rep_too_big_to_cache;
3549
3550 return 0;
3551}
3552
3553void
3554nfsd4_encode_operation(struct nfsd4_compoundres *resp, struct nfsd4_op *op)

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

3662 iov = &rqstp->rq_res.tail[0];
3663 else
3664 iov = &rqstp->rq_res.head[0];
3665 iov->iov_len = ((char*)resp->p) - (char*)iov->iov_base;
3666 BUG_ON(iov->iov_len > PAGE_SIZE);
3667 if (nfsd4_has_session(cs)) {
3668 if (cs->status != nfserr_replay_cache) {
3669 nfsd4_store_cache_entry(resp);
3659 dprintk("%s: SET SLOT STATE TO AVAILABLE\n", __func__);
3660 cs->slot->sl_inuse = false;
3670 cs->slot->sl_flags &= ~NFSD4_SLOT_INUSE;
3661 }
3662 /* Renew the clientid on success and on replay */
3663 release_session_client(cs->session);
3664 nfsd4_put_session(cs->session);
3665 }
3666 return 1;
3667}
3668
3669/*
3670 * Local variables:
3671 * c-basic-offset: 8
3672 * End:
3673 */
3671 }
3672 /* Renew the clientid on success and on replay */
3673 release_session_client(cs->session);
3674 nfsd4_put_session(cs->session);
3675 }
3676 return 1;
3677}
3678
3679/*
3680 * Local variables:
3681 * c-basic-offset: 8
3682 * End:
3683 */