FreeBSD Bugzilla – Attachment 25403 Details for
Bug 43434
[patch] new option to dmesg(8) which allows to display or not old boot messages
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
current.patch
current.patch (text/plain), 3.07 KB, created by
dak
on 2002-09-27 19:40:01 UTC
(
hide
)
Description:
current.patch
Filename:
MIME Type:
Creator:
dak
Created:
2002-09-27 19:40:01 UTC
Size:
3.07 KB
patch
obsolete
>--- sbin/dmesg/dmesg.c Sun Aug 18 19:57:07 2002 >+++ sbin/dmesg/dmesg.c Sun Sep 15 20:12:42 2002 >@@ -66,12 +66,35 @@ > { NULL }, > }; > >+int getlastbootpos(char *buf, int len); > void usage(void) __dead2; > > #define KREAD(addr, var) \ > kvm_read(kd, addr, &var, sizeof(var)) != sizeof(var) > > int >+getlastbootpos(char *buf, int len) >+{ >+ int i; >+ char *ptr, *save; >+ >+ /* Skip NULL bytes */ >+ for(i = 0; (buf[i] == 0x0) && (i < len); i++); >+ >+ if (strlen(buf) == 0) >+ return(-1); >+ >+ while((ptr = (char *) strstr((buf +i), BOOT_TAG)) != NULL) { >+ save = (char *) ptr; >+ i += strlen(BOOT_TAG); /* Force strstr() to catch >+ * the next tag >+ */ >+ } >+ >+ return((int) ((int) (save + (strlen(BOOT_TAG))) - (int) buf)); >+} >+ >+int > main(int argc, char *argv[]) > { > int ch, newl, skip; >@@ -84,10 +107,12 @@ > int pri; > size_t buflen; > int bufpos; >+ int old = 0; >+ int lastboot = 0; > > (void) setlocale(LC_CTYPE, ""); > memf = nlistf = NULL; >- while ((ch = getopt(argc, argv, "aM:N:")) != -1) >+ while ((ch = getopt(argc, argv, "aM:N:o")) != -1) > switch(ch) { > case 'a': > all++; >@@ -98,6 +123,9 @@ > case 'N': > nlistf = optarg; > break; >+ case 'o': >+ old = 1; >+ break; > case '?': > default: > usage(); >@@ -151,11 +179,19 @@ > * we effectively start at the oldest data. > */ > p = bp + bufpos; >+ if (!old) { >+ lastboot = getlastbootpos(p, buflen); >+ if (lastboot != -1) >+ p = bp + lastboot; >+ } > ep = (bufpos == 0 ? bp + buflen : p); > newl = skip = 0; > do { > if (p == bp + buflen) > p = bp; >+ /* Skipping boot tag */ >+ if (!memcmp(p, BOOT_TAG, strlen(BOOT_TAG))) >+ p += strlen(BOOT_TAG); > ch = *p; > /* Skip "\n<.*>" syslog sequences. */ > if (skip) { >@@ -193,6 +229,6 @@ > void > usage(void) > { >- (void)fprintf(stderr, "usage: dmesg [-a] [-M core] [-N system]\n"); >+ (void)fprintf(stderr, "usage: dmesg [-a] [-M core] [-N system] [-o]\n"); > exit(1); > } >--- sbin/dmesg/dmesg.8 Sat Aug 31 21:15:54 2002 >+++ sbin/dmesg/dmesg.8 Sat Aug 31 20:57:27 2002 >@@ -43,6 +43,7 @@ > .Op Fl a > .Op Fl M Ar core > .Op Fl N Ar system >+.Op Fl o > .Sh DESCRIPTION > The > .Nm >@@ -73,6 +74,8 @@ > .It Fl N > Extract the name list from the specified system instead of the default, > which is the kernel image the system has booted from. >+.It Fl o >+Display all boot messages, not only the last. > .El > .Sh FILES > .Bl -tag -width ".Pa /var/run/dmesg.boot" -compact >--- sys/sys/msgbuf.h Sat Aug 31 21:07:05 2002 >+++ sys/sys/msgbuf.h Sat Aug 31 21:08:40 2002 >@@ -46,6 +46,10 @@ > char * msg_ptr; /* pointer to buffer */ > }; > >+#define BOOT_TAG "---<<BOOT>>---" /* used by dmesg util to know where a >+ * boot message starts. >+ */ >+ > #ifdef _KERNEL > extern int msgbuftrigger; > extern struct msgbuf *msgbufp; >--- sys/kern/subr_prf.c Sat Aug 31 21:00:35 2002 >+++ sys/kern/subr_prf.c Sat Aug 31 21:01:01 2002 >@@ -818,6 +818,9 @@ > msgbufp->msg_size = (char *)msgbufp - cp; > } > msgbufp->msg_ptr = cp; >+ memcpy((void *) (msgbufp->msg_ptr + msgbufp->msg_bufx), BOOT_TAG, >+ strlen(BOOT_TAG)); >+ msgbufp->msg_bufx += strlen(BOOT_TAG); > if (msgbufmapped && oldp != msgbufp) > msgbufcopy(oldp); > msgbufmapped = 1;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 43434
: 25403