aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@primarydata.com>2018-03-20 17:03:06 -0400
committerAnna Schumaker <Anna.Schumaker@Netapp.com>2018-04-10 16:06:22 -0400
commit85e3dd44c514a8bed6c713df4af657be83d00f68 (patch)
tree6849c4e8f6df03f8dc41b28807c56ddd4434cfd9
parent0e779aa70308462e45f7cd1a54de418dfe101694 (diff)
SUNRPC: Add a helper for encoding opaque data inline
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
-rw-r--r--include/linux/sunrpc/xdr.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h
index 7e609de34d85..a43c3b6455b6 100644
--- a/include/linux/sunrpc/xdr.h
+++ b/include/linux/sunrpc/xdr.h
@@ -319,6 +319,31 @@ xdr_stream_encode_u64(struct xdr_stream *xdr, __u64 n)
319} 319}
320 320
321/** 321/**
322 * xdr_stream_encode_opaque_inline - Encode opaque xdr data
323 * @xdr: pointer to xdr_stream
324 * @ptr: pointer to void pointer
325 * @len: size of object
326 *
327 * Return values:
328 * On success, returns length in bytes of XDR buffer consumed
329 * %-EMSGSIZE on XDR buffer overflow
330 */
331static inline ssize_t
332xdr_stream_encode_opaque_inline(struct xdr_stream *xdr, void **ptr, size_t len)
333{
334 size_t count = sizeof(__u32) + xdr_align_size(len);
335 __be32 *p = xdr_reserve_space(xdr, count);
336
337 if (unlikely(!p)) {
338 *ptr = NULL;
339 return -EMSGSIZE;
340 }
341 xdr_encode_opaque(p, NULL, len);
342 *ptr = ++p;
343 return count;
344}
345
346/**
322 * xdr_stream_encode_opaque_fixed - Encode fixed length opaque xdr data 347 * xdr_stream_encode_opaque_fixed - Encode fixed length opaque xdr data
323 * @xdr: pointer to xdr_stream 348 * @xdr: pointer to xdr_stream
324 * @ptr: pointer to opaque data object 349 * @ptr: pointer to opaque data object