1/*- 2 * Copyright (c) 2000, 2001 Boris Popov 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: head/sys/kern/subr_mchain.c 177599 2008-03-25 09:39:02Z ru $"); |
32 33#include <sys/param.h> 34#include <sys/systm.h> 35#include <sys/endian.h> 36#include <sys/errno.h> 37#include <sys/mbuf.h> 38#include <sys/module.h> 39#include <sys/uio.h> --- 11 unchanged lines hidden (view full) --- 51/* 52 * Various helper functions 53 */ 54int 55mb_init(struct mbchain *mbp) 56{ 57 struct mbuf *m; 58 |
59 m = m_gethdr(M_WAIT, MT_DATA); |
60 m->m_len = 0; 61 mb_initm(mbp, m); 62 return 0; 63} 64 65void 66mb_initm(struct mbchain *mbp, struct mbuf *m) 67{ --- 38 unchanged lines hidden (view full) --- 106{ 107 struct mbuf *m, *mn; 108 caddr_t bpos; 109 110 if (size > MLEN) 111 panic("mb_reserve: size = %d\n", size); 112 m = mbp->mb_cur; 113 if (mbp->mb_mleft < size) { |
114 mn = m_get(M_WAIT, MT_DATA); |
115 mbp->mb_cur = m->m_next = mn; 116 m = mn; 117 m->m_len = 0; 118 mbp->mb_mleft = M_TRAILINGSPACE(m); 119 } 120 mbp->mb_mleft -= size; 121 mbp->mb_count += size; 122 bpos = mtod(m, caddr_t) + m->m_len; --- 58 unchanged lines hidden (view full) --- 181 int cplen, error, mleft, count; 182 size_t srclen, dstlen; 183 184 m = mbp->mb_cur; 185 mleft = mbp->mb_mleft; 186 187 while (size > 0) { 188 if (mleft == 0) { |
189 if (m->m_next == NULL) 190 m = m_getm(m, size, M_WAIT, MT_DATA); 191 else |
192 m = m->m_next; 193 mleft = M_TRAILINGSPACE(m); 194 continue; 195 } 196 cplen = mleft > size ? size : mleft; 197 srclen = dstlen = cplen; 198 dst = mtod(m, caddr_t) + m->m_len; 199 switch (type) { --- 84 unchanged lines hidden (view full) --- 284/* 285 * Routines for fetching data from an mbuf chain 286 */ 287int 288md_init(struct mdchain *mdp) 289{ 290 struct mbuf *m; 291 |
292 m = m_gethdr(M_WAIT, MT_DATA); |
293 m->m_len = 0; 294 md_initm(mdp, m); 295 return 0; 296} 297 298void 299md_initm(struct mdchain *mdp, struct mbuf *m) 300{ --- 189 unchanged lines hidden (view full) --- 490 return 0; 491} 492 493int 494md_get_mbuf(struct mdchain *mdp, int size, struct mbuf **ret) 495{ 496 struct mbuf *m = mdp->md_cur, *rm; 497 |
498 rm = m_copym(m, mdp->md_pos - mtod(m, u_char*), size, M_WAIT); |
499 md_get_mem(mdp, NULL, size, MB_MZERO); 500 *ret = rm; 501 return 0; 502} 503 504int 505md_get_uio(struct mdchain *mdp, struct uio *uiop, int size) 506{ --- 29 unchanged lines hidden --- |