FreeBSD/sys/kern/subr_msgbuf.c
/*
 * Reinitialize a message buffer, retaining its previous contents if
 * the size and checksum are correct. If the old contents cannot be
 * recovered, the message buffer is cleared.
 */
Reinitialize a message buffer, retaining its previous contents if
the size and checksum are correct. If the old contents cannot be
recovered, the message buffer is cleared.
Reinitialize a message buffer retaining its previous contents if the size and checksum are correct . If the old contents cannot be recovered the message buffer is cleared .
void
msgbuf_reinit(struct msgbuf *mbp, void *ptr, int size)
{
	u_int cksum;
	if (mbp->msg_magic != MSG_MAGIC || mbp->msg_size != size) {
		msgbuf_init(mbp, ptr, size);
		return;
	}
	mbp->msg_seqmod = SEQMOD(size);
	mbp->msg_wseq = MSGBUF_SEQNORM(mbp, mbp->msg_wseq);
	mbp->msg_rseq = MSGBUF_SEQNORM(mbp, mbp->msg_rseq);
        mbp->msg_ptr = ptr;
	cksum = msgbuf_cksum(mbp);
	if (cksum != mbp->msg_cksum) {
		if (bootverbose) {
			printf("msgbuf cksum mismatch (read %x, calc %x)\n",
			    mbp->msg_cksum, cksum);
			printf("Old msgbuf not recovered\n");
		}
		msgbuf_clear(mbp);
	}
	mbp->msg_lastpri = -1;
	mbp->msg_flags |= MSGBUF_NEEDNL;
	bzero(&mbp->msg_lock, sizeof(mbp->msg_lock));
	mtx_init(&mbp->msg_lock, "msgbuf", NULL, MTX_SPIN);
}
void msgbuf_reinit ( struct msgbuf * mbp , void * ptr , int size ) { u_int cksum ; if ( mbp -> msg_magic != MSG_MAGIC || mbp -> msg_size != size ) { msgbuf_init ( mbp , ptr , size ) ; return ; } mbp -> msg_seqmod = SEQMOD ( size ) ; mbp -> msg_wseq = MSGBUF_SEQNORM ( mbp , mbp -> msg_wseq ) ; mbp -> msg_rseq = MSGBUF_SEQNORM ( mbp , mbp -> msg_rseq ) ; mbp -> msg_ptr = ptr ; cksum = msgbuf_cksum ( mbp ) ; if ( cksum != mbp -> msg_cksum ) { if ( bootverbose ) { printf ( " \n " , mbp -> msg_cksum , cksum ) ; printf ( " \n " ) ; } msgbuf_clear ( mbp ) ; } mbp -> msg_lastpri = -1 ; mbp -> msg_flags |= MSGBUF_NEEDNL ; bzero ( & mbp -> msg_lock , sizeof ( mbp -> msg_lock ) ) ; mtx_init ( & mbp -> msg_lock , " " , NULL , MTX_SPIN ) ; }
Reinitialize a message buffer, retaining its previous contents if
 the size and checksum are correct.
Reinitialize a message buffer retaining its previous contents if the size and checksum are correct .
/* Assume that the old message buffer didn't end in a newline. */