Commit 4517d526c8aa31b5c14165ef180cc19518ff0a35

Authored by Trond Myklebust
1 parent 64bd577ea0

SUNRPC: Add the helper xdr_stream_pos

Add a helper to report the current offset from the start of the
xdr_stream.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>

Showing 2 changed files with 11 additions and 0 deletions Side-by-side Diff

include/linux/sunrpc/xdr.h
... ... @@ -218,6 +218,7 @@
218 218 extern __be32 *xdr_reserve_space(struct xdr_stream *xdr, size_t nbytes);
219 219 extern void xdr_write_pages(struct xdr_stream *xdr, struct page **pages,
220 220 unsigned int base, unsigned int len);
  221 +extern unsigned int xdr_stream_pos(const struct xdr_stream *xdr);
221 222 extern void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p);
222 223 extern void xdr_init_decode_pages(struct xdr_stream *xdr, struct xdr_buf *buf,
223 224 struct page **pages, unsigned int len);
... ... @@ -455,6 +455,16 @@
455 455 EXPORT_SYMBOL_GPL(xdr_shift_buf);
456 456  
457 457 /**
  458 + * xdr_stream_pos - Return the current offset from the start of the xdr_stream
  459 + * @xdr: pointer to struct xdr_stream
  460 + */
  461 +unsigned int xdr_stream_pos(const struct xdr_stream *xdr)
  462 +{
  463 + return (unsigned int)(XDR_QUADLEN(xdr->buf->len) - xdr->nwords) << 2;
  464 +}
  465 +EXPORT_SYMBOL_GPL(xdr_stream_pos);
  466 +
  467 +/**
458 468 * xdr_init_encode - Initialize a struct xdr_stream for sending data.
459 469 * @xdr: pointer to xdr_stream struct
460 470 * @buf: pointer to XDR buffer in which to encode data