sunrpc-xdr-words
Subsystems (3)
PATCH 4/11 sunrpc-xdr-words
Encode 32-bit words in xdr_buf's
Andreas Gruenbacher <[email protected]>, SUSE Labs
include/linux/sunrpc/xdr.h +3 -0
@@ -153,6 +153,9 @@extern int xdr_buf_subsegment (struct xdr_buf *,struct xdr_buf *,int ,int );extern int xdr_buf_read_netobj (struct xdr_buf *,struct xdr_netobj *,int );extern int read_bytes_from_xdr_buf (struct xdr_buf *buf,int base,void *obj,int len); +extern int read_u32_from_xdr_buf (struct xdr_buf *,int ,u32 *); +extern int write_bytes_to_xdr_buf (struct xdr_buf *,int ,void *,int ); +extern int write_u32_to_xdr_buf (struct xdr_buf *,int ,u32 );/* * Helper structure for copying from an sk_buff.
net/sunrpc/sunrpc_syms.c +3 -0
@@ -132,6 +132,9 @@EXPORT_SYMBOL (xdr_buf_subsegment);EXPORT_SYMBOL (xdr_buf_read_netobj);EXPORT_SYMBOL (read_bytes_from_xdr_buf); +EXPORT_SYMBOL (read_u32_from_xdr_buf); +EXPORT_SYMBOL (write_bytes_to_xdr_buf); +EXPORT_SYMBOL (write_u32_to_xdr_buf);/* Debugging symbols */ #ifdef RPC_DEBUG
net/sunrpc/xdr.c +36 -1
@@ -990,7 +990,7 @@return status; } -static int +int read_u32_from_xdr_buf (struct xdr_buf *buf,int base,u32 *obj) {u32 raw;
@@ -1003,6 +1003,41 @@return 0 ; } +/* obj is assumed to point to allocated memory of size at least len: */ +int +write_bytes_to_xdr_buf (struct xdr_buf *buf,int base,void *obj,int len) +{ +struct xdr_buf subbuf; +int this_len; +int status; + + status =xdr_buf_subsegment (buf, &subbuf, base, len); +if (status) + goto out; + this_len =min (len, (int )subbuf.head[0 ].iov_len); +memcpy (subbuf.head[0 ].iov_base, obj, this_len); + len -= this_len; + obj += this_len; + this_len =min (len, (int )subbuf.page_len); +if (this_len) +_copy_to_pages (subbuf.pages, subbuf.page_base, obj, this_len); + len -= this_len; + obj += this_len; + this_len =min (len, (int )subbuf.tail[0 ].iov_len); +memcpy (subbuf.tail[0 ].iov_base, obj, this_len); +out: +return status; +} + +int +write_u32_to_xdr_buf (struct xdr_buf *buf,int base,u32 obj) +{ +int status; + + obj =htonl (obj); +return write_bytes_to_xdr_buf (buf, base, &obj,sizeof (obj)); +} +/* If the netobj starting offset bytes from the start of xdr_buf is contained * entirely in the head or the tail, set object to point to it; otherwise * try to find space for it at the end of the tail, copy it there, and
Quoted 2 lines · Andreas Gruenbacher
Encode 32-bit words in xdr_buf's
+extern intread_u32_from_xdr_buf(struct xdr_buf *, int, u32 *);
Note that the same function is defined as a static inline in net/sunrpc/auth_gss/svcauth_gss.c, so gcc will complain if CONFIG_SUNRPC_GSS is also defined.
--Bruce Fields
Hi Bruce,
thanks, we can move both functions into include/linux/sunrpc/xdr.h; they are trivial enough.
Quoted 9 lines · J. Bruce Fields
Quoted 2 lines · Andreas Gruenbacher
Encode 32-bit words in xdr_buf's
+extern intread_u32_from_xdr_buf(struct xdr_buf *, int, u32 *);Note that the same function is defined as a static inline in
net/sunrpc/auth_gss/svcauth_gss.c, so gcc will complain ifCONFIG_SUNRPC_GSSis also defined.--Bruce Fields
Cheers,
Signature · 2 lines
Andreas Gruenbacher <[email protected]> SUSE Labs, SUSE LINUX AG