FreeBSD/sys/kern/subr_prf.c
/* Sysctls for accessing/clearing the msgbuf */
Sysctls for accessing/clearing the msgbuf
Sysctls for accessing / clearing the msgbuf
static int
sysctl_kern_msgbuf(SYSCTL_HANDLER_ARGS)
{
	char buf[128];
	u_int seq;
	int error, len;
	if (!unprivileged_read_msgbuf) {
		error = priv_check(req->td, PRIV_MSGBUF);
		if (error)
			return (error);
	}
	mtx_lock(&msgbuf_lock);
	msgbuf_peekbytes(msgbufp, NULL, 0, &seq);
	for (;;) {
		len = msgbuf_peekbytes(msgbufp, buf, sizeof(buf), &seq);
		mtx_unlock(&msgbuf_lock);
		if (len == 0)
			return (SYSCTL_OUT(req, "", 1)); 
		error = sysctl_handle_opaque(oidp, buf, len, req);
		if (error)
			return (error);
		mtx_lock(&msgbuf_lock);
	}
}
static int sysctl_kern_msgbuf ( SYSCTL_HANDLER_ARGS ) { char buf [ 128 ] ; u_int seq ; int error , len ; if ( ! unprivileged_read_msgbuf ) { error = priv_check ( req -> td , PRIV_MSGBUF ) ; if ( error ) return ( error ) ; } mtx_lock ( & msgbuf_lock ) ; msgbuf_peekbytes ( msgbufp , NULL , 0 , & seq ) ; for ( ; ; ) { len = msgbuf_peekbytes ( msgbufp , buf , sizeof ( buf ) , & seq ) ; mtx_unlock ( & msgbuf_lock ) ; if ( len == 0 ) return ( SYSCTL_OUT ( req , " " , 1 ) ) ; error = sysctl_handle_opaque ( oidp , buf , len , req ) ; if ( error ) return ( error ) ; mtx_lock ( & msgbuf_lock ) ; } }
Sysctls for accessing/clearing the msgbuf
Sysctls for accessing / clearing the msgbuf
/* Read the whole buffer, one chunk at a time. */ /* add nulterm */