-/* $OpenBSD: subr_prf.c,v 1.28 2000/03/02 10:50:29 art Exp $ */
+/* $OpenBSD: subr_prf.c,v 1.29 2000/03/13 04:05:15 millert Exp $ */
/* $NetBSD: subr_prf.c,v 1.45 1997/10/24 18:14:25 chuck Exp $ */
/*-
/* Nothing we can do */
}
mbp->msg_bufc[mbp->msg_bufx++] = c;
+ mbp->msg_bufl = min(mbp->msg_bufl+1, mbp->msg_bufs);
if (mbp->msg_bufx < 0 || mbp->msg_bufx >= mbp->msg_bufs)
mbp->msg_bufx = 0;
/* If the buffer is full, keep the most recent data. */
-/* $OpenBSD: kernfs_vnops.c,v 1.18 2000/02/22 19:28:06 deraadt Exp $ */
+/* $OpenBSD: kernfs_vnops.c,v 1.19 2000/03/13 04:05:15 millert Exp $ */
/* $NetBSD: kernfs_vnops.c,v 1.43 1996/03/16 23:52:47 christos Exp $ */
/*
* message buffer header are corrupted, but that'll cause
* the system to die anyway.
*/
- if (off >= msgbufp->msg_bufs)
- return (0);
- n = msgbufp->msg_bufx + off;
- if (n >= msgbufp->msg_bufs)
- n -= msgbufp->msg_bufs;
- len = min(msgbufp->msg_bufs - n, msgbufp->msg_bufs - off);
+ if (msgbufp->msg_bufl < msgbufp->msg_bufs) {
+ if (off >= msgbufp->msg_bufx)
+ return (0);
+ n = off;
+ len = msgbufp->msg_bufx - n;
+ } else {
+ if (off >= msgbufp->msg_bufs)
+ return (0);
+ n = msgbufp->msg_bufx + off;
+ if (n >= msgbufp->msg_bufs)
+ n -= msgbufp->msg_bufs;
+ len = min(msgbufp->msg_bufs - n, msgbufp->msg_bufs - off);
+ }
*bufp = msgbufp->msg_bufc + n;
return (len);
}
-/* $OpenBSD: msgbuf.h,v 1.3 2000/02/22 19:28:05 deraadt Exp $ */
+/* $OpenBSD: msgbuf.h,v 1.4 2000/03/13 04:05:13 millert Exp $ */
/* $NetBSD: msgbuf.h,v 1.8 1995/03/26 20:24:27 jtc Exp $ */
/*
long msg_bufx; /* write pointer */
long msg_bufr; /* read pointer */
long msg_bufs; /* real msg_bufc size (bytes) */
+ long msg_bufl; /* # chars, <= msg_bufs */
char msg_bufc[1]; /* buffer */
};
#ifdef _KERNEL