>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     [email protected]:/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:
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"

Reply via email to