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

Function logread

freebsd/kern/subr_log.c:147–179  ·  view source on GitHub ↗

ARGSUSED*/

Source from the content-addressed store, hash-verified

145
146/*ARGSUSED*/
147static int
148logread(struct cdev *dev, struct uio *uio, int flag)
149{
150 char buf[128];
151 struct msgbuf *mbp = msgbufp;
152 int error = 0, l;
153
154 mtx_lock(&msgbuf_lock);
155 while (msgbuf_getcount(mbp) == 0) {
156 if (flag & IO_NDELAY) {
157 mtx_unlock(&msgbuf_lock);
158 return (EWOULDBLOCK);
159 }
160 if ((error = cv_wait_sig(&log_wakeup, &msgbuf_lock)) != 0) {
161 mtx_unlock(&msgbuf_lock);
162 return (error);
163 }
164 }
165
166 while (uio->uio_resid > 0) {
167 l = imin(sizeof(buf), uio->uio_resid);
168 l = msgbuf_getbytes(mbp, buf, l);
169 if (l == 0)
170 break;
171 mtx_unlock(&msgbuf_lock);
172 error = uiomove(buf, l, uio);
173 if (error || uio->uio_resid == 0)
174 return (error);
175 mtx_lock(&msgbuf_lock);
176 }
177 mtx_unlock(&msgbuf_lock);
178 return (error);
179}
180
181/*ARGSUSED*/
182static int

Callers

nothing calls this directly

Calls 7

msgbuf_getcountFunction · 0.85
iminFunction · 0.85
msgbuf_getbytesFunction · 0.85
mtx_lockFunction · 0.70
mtx_unlockFunction · 0.70
uiomoveFunction · 0.70
cv_wait_sigFunction · 0.50

Tested by

no test coverage detected