aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/uipc_mbuf.c
diff options
context:
space:
mode:
authorAndre Oppermann <andre@FreeBSD.org>2009-06-22 22:20:38 +0000
committerAndre Oppermann <andre@FreeBSD.org>2009-06-22 22:20:38 +0000
commitbc05b2f6fa37a823fa90b48518aed4b3b3529a7f (patch)
tree34358b0131e50a6171e6f0c8c318b06b5c90c566 /sys/kern/uipc_mbuf.c
parent0622974ab238eb6f07082cdfa0c0809187599439 (diff)
downloadsrc-bc05b2f6fa37a823fa90b48518aed4b3b3529a7f.tar.gz
src-bc05b2f6fa37a823fa90b48518aed4b3b3529a7f.zip
Notes
Diffstat (limited to 'sys/kern/uipc_mbuf.c')
-rw-r--r--sys/kern/uipc_mbuf.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index d78bee903bec..bc0e88d0a477 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -1770,6 +1770,34 @@ m_uiotombuf(struct uio *uio, int how, int len, int align, int flags)
}
/*
+ * Copy an mbuf chain into a uio limited by len if set.
+ */
+int
+m_mbuftouio(struct uio *uio, struct mbuf *m, int len)
+{
+ int error, length, total;
+ int progress = 0;
+
+ if (len > 0)
+ total = min(uio->uio_resid, len);
+ else
+ total = uio->uio_resid;
+
+ /* Fill the uio with data from the mbufs. */
+ for (; m != NULL; m = m->m_next) {
+ length = min(m->m_len, total - progress);
+
+ error = uiomove(mtod(m, void *), length, uio);
+ if (error)
+ return (error);
+
+ progress += length;
+ }
+
+ return (0);
+}
+
+/*
* Set the m_data pointer of a newly-allocated mbuf
* to place an object of the specified size at the
* end of the mbuf, longword aligned.