aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4xdr.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfs/nfs4xdr.c')
-rw-r--r--fs/nfs/nfs4xdr.c71
1 files changed, 70 insertions, 1 deletions
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 6f1c003ee33a..325cd6d4f23a 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -372,6 +372,13 @@ static int nfs_stat_to_errno(int);
372 decode_putfh_maxsz + \ 372 decode_putfh_maxsz + \
373 op_decode_hdr_maxsz + \ 373 op_decode_hdr_maxsz + \
374 nfs4_fattr_bitmap_maxsz + 1) 374 nfs4_fattr_bitmap_maxsz + 1)
375#define NFS4_enc_setacl_sz (compound_encode_hdr_maxsz + \
376 encode_putfh_maxsz + \
377 op_encode_hdr_maxsz + 4 + \
378 nfs4_fattr_bitmap_maxsz + 1)
379#define NFS4_dec_setacl_sz (compound_decode_hdr_maxsz + \
380 decode_putfh_maxsz + \
381 op_decode_hdr_maxsz + nfs4_fattr_bitmap_maxsz)
375 382
376static struct { 383static struct {
377 unsigned int mode; 384 unsigned int mode;
@@ -471,7 +478,7 @@ static int encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const s
471 * In the worst-case, this would be 478 * In the worst-case, this would be
472 * 12(bitmap) + 4(attrlen) + 8(size) + 4(mode) + 4(atime) + 4(mtime) 479 * 12(bitmap) + 4(attrlen) + 8(size) + 4(mode) + 4(atime) + 4(mtime)
473 * = 36 bytes, plus any contribution from variable-length fields 480 * = 36 bytes, plus any contribution from variable-length fields
474 * such as owner/group/acl's. 481 * such as owner/group.
475 */ 482 */
476 len = 16; 483 len = 16;
477 484
@@ -1096,6 +1103,25 @@ static int encode_renew(struct xdr_stream *xdr, const struct nfs4_client *client
1096} 1103}
1097 1104
1098static int 1105static int
1106encode_setacl(struct xdr_stream *xdr, struct nfs_setaclargs *arg)
1107{
1108 uint32_t *p;
1109
1110 RESERVE_SPACE(4+sizeof(zero_stateid.data));
1111 WRITE32(OP_SETATTR);
1112 WRITEMEM(zero_stateid.data, sizeof(zero_stateid.data));
1113 RESERVE_SPACE(2*4);
1114 WRITE32(1);
1115 WRITE32(FATTR4_WORD0_ACL);
1116 if (arg->acl_len % 4)
1117 return -EINVAL;
1118 RESERVE_SPACE(4);
1119 WRITE32(arg->acl_len);
1120 xdr_write_pages(xdr, arg->acl_pages, arg->acl_pgbase, arg->acl_len);
1121 return 0;
1122}
1123
1124static int
1099encode_savefh(struct xdr_stream *xdr) 1125encode_savefh(struct xdr_stream *xdr)
1100{ 1126{
1101 uint32_t *p; 1127 uint32_t *p;
@@ -3492,6 +3518,48 @@ out:
3492 3518
3493} 3519}
3494 3520
3521/*
3522 * Encode an SETACL request
3523 */
3524static int
3525nfs4_xdr_enc_setacl(struct rpc_rqst *req, uint32_t *p, struct nfs_setaclargs *args)
3526{
3527 struct xdr_stream xdr;
3528 struct compound_hdr hdr = {
3529 .nops = 2,
3530 };
3531 int status;
3532
3533 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
3534 encode_compound_hdr(&xdr, &hdr);
3535 status = encode_putfh(&xdr, args->fh);
3536 if (status)
3537 goto out;
3538 status = encode_setacl(&xdr, args);
3539out:
3540 return status;
3541}
3542/*
3543 * Decode SETACL response
3544 */
3545static int
3546nfs4_xdr_dec_setacl(struct rpc_rqst *rqstp, uint32_t *p, void *res)
3547{
3548 struct xdr_stream xdr;
3549 struct compound_hdr hdr;
3550 int status;
3551
3552 xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
3553 status = decode_compound_hdr(&xdr, &hdr);
3554 if (status)
3555 goto out;
3556 status = decode_putfh(&xdr);
3557 if (status)
3558 goto out;
3559 status = decode_setattr(&xdr, res);
3560out:
3561 return status;
3562}
3495 3563
3496/* 3564/*
3497 * Decode GETACL response 3565 * Decode GETACL response
@@ -4117,6 +4185,7 @@ struct rpc_procinfo nfs4_procedures[] = {
4117 PROC(SERVER_CAPS, enc_server_caps, dec_server_caps), 4185 PROC(SERVER_CAPS, enc_server_caps, dec_server_caps),
4118 PROC(DELEGRETURN, enc_delegreturn, dec_delegreturn), 4186 PROC(DELEGRETURN, enc_delegreturn, dec_delegreturn),
4119 PROC(GETACL, enc_getacl, dec_getacl), 4187 PROC(GETACL, enc_getacl, dec_getacl),
4188 PROC(SETACL, enc_setacl, dec_setacl),
4120}; 4189};
4121 4190
4122struct rpc_version nfs_version4 = { 4191struct rpc_version nfs_version4 = {