From owner-freebsd-bugs@FreeBSD.ORG Thu May 2 09:30:00 2013 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id DB728AFE for ; Thu, 2 May 2013 09:30:00 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id C38C5109D for ; Thu, 2 May 2013 09:30:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.6/8.14.6) with ESMTP id r429U0t6070799 for ; Thu, 2 May 2013 09:30:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.6/8.14.6/Submit) id r429U07t070798; Thu, 2 May 2013 09:30:00 GMT (envelope-from gnats) Resent-Date: Thu, 2 May 2013 09:30:00 GMT Resent-Message-Id: <201305020930.r429U07t070798@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Levent Serinol Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 4B5DC95F for ; Thu, 2 May 2013 09:23:25 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [69.147.83.34]) by mx1.freebsd.org (Postfix) with ESMTP id 2317F1052 for ; Thu, 2 May 2013 09:23:25 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.5/8.14.5) with ESMTP id r429NOLr061918 for ; Thu, 2 May 2013 09:23:24 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.5/8.14.5/Submit) id r429NOGw061917; Thu, 2 May 2013 09:23:24 GMT (envelope-from nobody) Message-Id: <201305020923.r429NOGw061917@red.freebsd.org> Date: Thu, 2 May 2013 09:23:24 GMT From: Levent Serinol To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: misc/178295: small change to dmesg utility X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 May 2013 09:30:00 -0000 >Number: 178295 >Category: misc >Synopsis: small change to dmesg utility >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu May 02 09:30:00 UTC 2013 >Closed-Date: >Last-Modified: >Originator: Levent Serinol >Release: 9 and 10 >Organization: Mynet >Environment: FreeBSD webmail105.mynet.com 10.0-CURRENT FreeBSD 10.0-CURRENT #5: Thu Mar 14 20:28:24 EET 2013 root@xxx.com:/usr/obj/usr/src/sys/GENERIC amd64 >Description: I would like to submit a small patch for dmesg system utility which implements "-c" parameter like the other *nix systems support to clear current kernel message buffer instead of using "sysctl kern.msgbuf_clear=1" command for easier administration usage and similarity between other unix systems. Here i wrote an article about this issue sometime ago. http://lserinol.blogspot.com/2012/02/linux-like-dmesg-in-freebsd.html >How-To-Repeat: >Fix: Patch attached with submission follows: *** dmesg.c.org Tue Jan 3 19:04:44 2012 --- dmesg.c Mon Mar 12 15:48:34 2012 *************** *** 82,95 **** size_t buflen, bufpos; long pri; ! int all, ch; all = 0; (void) setlocale(LC_CTYPE, ""); memf = nlistf = NULL; ! while ((ch = getopt(argc, argv, "aM:N:")) != -1) switch(ch) { case 'a': all++; break; case 'M': memf = optarg; --- 82,99 ---- size_t buflen, bufpos; long pri; ! int all, ch, clear; all = 0; + clear = 0; (void) setlocale(LC_CTYPE, ""); memf = nlistf = NULL; ! while ((ch = getopt(argc, argv, "acM:N:")) != -1) switch(ch) { case 'a': all++; break; + case 'c': + clear++; + break; case 'M': memf = optarg; *************** *** 192,195 **** --- 196,202 ---- (void)strvisx(visbp, p, nextp - p, 0); (void)printf("%s", visbp); + if (clear) + if (sysctlbyname("kern.msgbuf_clear", NULL, NULL, &clear, sizeof(int)) == -1) + err(1, "sysctl kern.msgbuf_clear"); } exit(0); *************** *** 199,203 **** usage(void) { ! (void)fprintf(stderr, "usage: dmesg [-a] [-M core [-N system]]\n"); exit(1); } --- 206,210 ---- usage(void) { ! (void)fprintf(stderr, "usage: dmesg [-a] [-c] [-M core [-N system]]\n"); exit(1); } >Release-Note: >Audit-Trail: >Unformatted: