MCPcopy Create free account
hub / github.com/F-Stack/f-stack / msgbuf_reinit

Function msgbuf_reinit

freebsd/kern/subr_msgbuf.c:85–113  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

83 * recovered, the message buffer is cleared.
84 */
85void
86msgbuf_reinit(struct msgbuf *mbp, void *ptr, int size)
87{
88 u_int cksum;
89
90 if (mbp->msg_magic != MSG_MAGIC || mbp->msg_size != size) {
91 msgbuf_init(mbp, ptr, size);
92 return;
93 }
94 mbp->msg_seqmod = SEQMOD(size);
95 mbp->msg_wseq = MSGBUF_SEQNORM(mbp, mbp->msg_wseq);
96 mbp->msg_rseq = MSGBUF_SEQNORM(mbp, mbp->msg_rseq);
97 mbp->msg_ptr = ptr;
98 cksum = msgbuf_cksum(mbp);
99 if (cksum != mbp->msg_cksum) {
100 if (bootverbose) {
101 printf("msgbuf cksum mismatch (read %x, calc %x)\n",
102 mbp->msg_cksum, cksum);
103 printf("Old msgbuf not recovered\n");
104 }
105 msgbuf_clear(mbp);
106 }
107
108 mbp->msg_lastpri = -1;
109 /* Assume that the old message buffer didn't end in a newline. */
110 mbp->msg_flags |= MSGBUF_NEEDNL;
111 bzero(&mbp->msg_lock, sizeof(mbp->msg_lock));
112 mtx_init(&mbp->msg_lock, "msgbuf", NULL, MTX_SPIN);
113}
114
115/*
116 * Clear the message buffer.

Callers 1

msgbufinitFunction · 0.85

Calls 6

msgbuf_initFunction · 0.85
msgbuf_cksumFunction · 0.85
msgbuf_clearFunction · 0.85
bzeroFunction · 0.85
mtx_initFunction · 0.85
printfFunction · 0.70

Tested by

no test coverage detected