Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F144380467
D48548.id149595.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D48548.id149595.diff
View Options
diff --git a/sys/xdr/xdr_mem.c b/sys/xdr/xdr_mem.c
--- a/sys/xdr/xdr_mem.c
+++ b/sys/xdr/xdr_mem.c
@@ -44,6 +44,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/malloc.h>
+#include <sys/mbuf.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
@@ -55,6 +56,7 @@
static bool_t xdrmem_putlong_unaligned(XDR *, const long *);
static bool_t xdrmem_getbytes(XDR *, char *, u_int);
static bool_t xdrmem_putbytes(XDR *, const char *, u_int);
+static bool_t xdrmem_putmbuf(XDR *, struct mbuf *);
/* XXX: w/64-bit pointers, u_int not enough! */
static u_int xdrmem_getpos(XDR *);
static bool_t xdrmem_setpos(XDR *, u_int);
@@ -67,6 +69,7 @@
.x_putlong = xdrmem_putlong_aligned,
.x_getbytes = xdrmem_getbytes,
.x_putbytes = xdrmem_putbytes,
+ .x_putmbuf = xdrmem_putmbuf,
.x_getpostn = xdrmem_getpos,
.x_setpostn = xdrmem_setpos,
.x_inline = xdrmem_inline_aligned,
@@ -79,6 +82,7 @@
.x_putlong = xdrmem_putlong_unaligned,
.x_getbytes = xdrmem_getbytes,
.x_putbytes = xdrmem_putbytes,
+ .x_putmbuf = xdrmem_putmbuf,
.x_getpostn = xdrmem_getpos,
.x_setpostn = xdrmem_setpos,
.x_inline = xdrmem_inline_unaligned,
@@ -184,6 +188,27 @@
return (TRUE);
}
+/*
+ * Append mbuf. May fail if not enough space. Caller owns the mbuf.
+ */
+static bool_t
+xdrmem_putmbuf(XDR *xdrs, struct mbuf *m)
+{
+ u_int len;
+
+ if (__predict_false(m == NULL))
+ return (TRUE);
+
+ len = m_length(m, NULL);
+
+ if (__predict_false(xdrs->x_handy < len))
+ return (FALSE);
+ xdrs->x_handy -= len;
+ m_copydata(m, 0, len, xdrs->x_private);
+ xdrs->x_private = (char *)xdrs->x_private + len;
+ return (TRUE);
+}
+
static u_int
xdrmem_getpos(XDR *xdrs)
{
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Feb 9, 3:44 AM (1 h, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28514269
Default Alt Text
D48548.id149595.diff (1 KB)
Attached To
Mode
D48548: xdr: provide x_putmbuf method for xdrmem
Attached
Detach File
Event Timeline
Log In to Comment