subr_prf.c (10b3b54548f2290bbe8d8f88c59c28d12b7a635d) subr_prf.c (ca1d2f657ac8942f180f7d1ab328400ae8524bf0)
1/*-
2 * Copyright (c) 1986, 1988, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 909 unchanged lines hidden (view full) ---

918
919 if (!unprivileged_read_msgbuf) {
920 error = priv_check(req->td, PRIV_MSGBUF);
921 if (error)
922 return (error);
923 }
924
925 /* Read the whole buffer, one chunk at a time. */
1/*-
2 * Copyright (c) 1986, 1988, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 909 unchanged lines hidden (view full) ---

918
919 if (!unprivileged_read_msgbuf) {
920 error = priv_check(req->td, PRIV_MSGBUF);
921 if (error)
922 return (error);
923 }
924
925 /* Read the whole buffer, one chunk at a time. */
926 mtx_lock(&msgbuf_lock);
926 msgbuf_peekbytes(msgbufp, NULL, 0, &seq);
927 msgbuf_peekbytes(msgbufp, NULL, 0, &seq);
927 while ((len = msgbuf_peekbytes(msgbufp, buf, sizeof(buf), &seq)) > 0) {
928 for (;;) {
929 len = msgbuf_peekbytes(msgbufp, buf, sizeof(buf), &seq);
930 mtx_unlock(&msgbuf_lock);
931 if (len == 0)
932 return (0);
933
928 error = sysctl_handle_opaque(oidp, buf, len, req);
929 if (error)
930 return (error);
934 error = sysctl_handle_opaque(oidp, buf, len, req);
935 if (error)
936 return (error);
937
938 mtx_lock(&msgbuf_lock);
931 }
939 }
932 return (0);
933}
934
940}
941
935SYSCTL_PROC(_kern, OID_AUTO, msgbuf, CTLTYPE_STRING | CTLFLAG_RD,
942SYSCTL_PROC(_kern, OID_AUTO, msgbuf,
943 CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE,
936 NULL, 0, sysctl_kern_msgbuf, "A", "Contents of kernel message buffer");
937
938static int msgbuf_clearflag;
939
940static int
941sysctl_kern_msgbuf_clear(SYSCTL_HANDLER_ARGS)
942{
943 int error;
944 error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2, req);
945 if (!error && req->newptr) {
944 NULL, 0, sysctl_kern_msgbuf, "A", "Contents of kernel message buffer");
945
946static int msgbuf_clearflag;
947
948static int
949sysctl_kern_msgbuf_clear(SYSCTL_HANDLER_ARGS)
950{
951 int error;
952 error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2, req);
953 if (!error && req->newptr) {
954 mtx_lock(&msgbuf_lock);
946 msgbuf_clear(msgbufp);
955 msgbuf_clear(msgbufp);
956 mtx_unlock(&msgbuf_lock);
947 msgbuf_clearflag = 0;
948 }
949 return (error);
950}
951
952SYSCTL_PROC(_kern, OID_AUTO, msgbuf_clear,
957 msgbuf_clearflag = 0;
958 }
959 return (error);
960}
961
962SYSCTL_PROC(_kern, OID_AUTO, msgbuf_clear,
953 CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_SECURE, &msgbuf_clearflag, 0,
954 sysctl_kern_msgbuf_clear, "I", "Clear kernel message buffer");
963 CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_SECURE | CTLFLAG_MPSAFE,
964 &msgbuf_clearflag, 0, sysctl_kern_msgbuf_clear, "I",
965 "Clear kernel message buffer");
955
956#ifdef DDB
957
958DB_SHOW_COMMAND(msgbuf, db_show_msgbuf)
959{
960 int i, j;
961
962 if (!msgbufmapped) {

--- 69 unchanged lines hidden ---
966
967#ifdef DDB
968
969DB_SHOW_COMMAND(msgbuf, db_show_msgbuf)
970{
971 int i, j;
972
973 if (!msgbufmapped) {

--- 69 unchanged lines hidden ---