SVR3 console message capturing
Larry Philps
larry at hcr.UUCP
Mon Aug 22 23:39:42 AEST 1988
In article <184 at thebes.Thalatta.COM> gregoire at thebes.UUCP writes:
>
>I am running Bell Tech System V/386, release 3 on a Bell Tech 386.
>
>I am looking for a way of capturing console error messages (notices,
>warnings and panics) to a file (or at least a printer) such as
>the way BSD and XENIX do with dmesg. I have scoured the Bell Tech
>System Admin manuals and cannot find a clue as to whether there is
>an existing way to do this. The dmesg command cannot be found.
>
>In-Real-Life: Keith Gregoire, Thalatta Corporation, (+1 206 455 9838)
>Domain: gregoire at Thalatta.COM Path: uw-beaver!uw-entropy!thebes!gregoire
On some versions of 386 UNIX, most particularily 386/ix from ISC, there is a
"osm" pseudo device that can be configured into the kernel. osm stands for
Operating System Messages, and it does just what you want. Look in your config
directory and see if you have it. If so, create /dev/osm (usally major 17,
minor 0) then run "cat -u > filename" on it to copy the messages to a file.
If it turns out that you don't have it, write one yourself. The kernel printf
code saves all messages it prints in a global circular character array called
"putbuf", the variable "putbufsz" gives the number of characters in this array,
and the variable "putbufndx" gives the location at which the next character
will be put into the array. The printf code also does a wakeup(putbuf)
whenever new characters are put into the array. Makes for an easy 50 line
driver to access the information you want.
Here is a short user program I wrote ages ago when I was trying to figure out
how putbuf was used. Actually, you could probably hack this into something
close to what you want instead of writing a driver.
----------
#include <stdio.h>
#include "sys/types.h"
#include "nlist.h"
#define PUTBUF 0
#define PUTBUFSZ 1
#define PUTBUFNDX 2
struct nlist nl[] = {
#ifdef vax
{ "_putbuf" },
{ "_putbufsz" },
{ "_putbufndx" },
#else
{ "putbuf" },
{ "putbufsz" },
{ "putbufndx" },
#endif
{ 0 },
};
#define BUFFERSIZE 10000
char buf[BUFFERSIZE];
char *malloc();
main()
{
int i, j;
int memfd, putbufndx, putbufsz;
char *putbuf;
if ((memfd = open("/dev/kmem", 0)) < 0) {
perror("/dev/kmem");
exit(1);
}
nlist("/unix", nl);
if (nl[0].n_value == 0) {
fprintf(stderr, "nlist failed\n");
exit(2);
}
#ifdef vax
nl[0].n_value = ((int)nl[0].n_value & 0x3fffffff);
nl[1].n_value = ((int)nl[1].n_value & 0x3fffffff);
nl[2].n_value = ((int)nl[2].n_value & 0x3fffffff);
#endif
Lseek("putbufsz", memfd, (long)nl[PUTBUFSZ].n_value, 0);
Read("putbufsz", memfd, (char *)&putbufsz, sizeof(putbufsz));
printf("putbufsz %d\n", putbufsz);
if (putbufsz >= BUFFERSIZE) {
fprintf (stderr, "putbufsz(%d) >= BUFFERSIZE(%d)\n",
putbufsz, BUFFERSIZE);
exit(4);
}
Lseek("putbufndx", memfd, (long)nl[PUTBUFNDX].n_value, 0);
Read("putbufndx", memfd, (char *)&putbufndx, sizeof(putbufndx));
printf("putbufndx %d\n", putbufndx);
if ((putbuf = malloc(putbufsz)) < 0) {
perror("sbrk");
exit(5);
}
Lseek("putbuf", memfd, (long)nl[PUTBUF].n_value, 0);
Read("putbuf", memfd, (char *)putbuf, putbufsz);
putbufndx = (putbufndx + 1) % putbufsz;
putbuf[putbufndx] = '\0';
i = (putbufndx + 1) % putbufsz;
while (i != putbufndx && putbuf[i] == '\0')
i = (i + 1) % putbufsz;
j = 0;
while (i != putbufndx) {
buf[j] = putbuf[i];
i = (i + 1) % putbufsz;
j++;
}
buf[j] = '\0';
printf("putbuf:\n%s\n", buf);
return(0);
}
Lseek(s, fd, offset, set)
char *s;
int fd, offset, set;
{
if (lseek(fd, offset, set) == -1) {
sprintf(buf, "%s: lseek (%d, 0x%x, %d)", s, fd, offset, set);
perror (buf);
exit (1);
}
}
Read(s, fd, addr, n)
char *s;
int fd, addr, n;
{
int i;
if ((i = read(fd, addr, n)) == -1) {
sprintf(buf, "%s: read(%d, 0x%x, %d)", s, fd, addr, n);
perror (buf);
exit (2);
}
if (i != n) {
fprintf(stderr, "%s: read(%d, 0x%x, %d) returned %d\n",
s, fd, addr, n, i);
exit (3);
}
}
----------
Larry Philps HCR Corporation
130 Bloor St. West, 10th floor Toronto, Ontario. M5S 1N5
(416) 922-1937 {utzoo,utcsri,decvax,ihnp4}!hcr!larry
More information about the Comp.unix.microport
mailing list