8d6397d9bf79dc5cca48367acc2ebf0392180a1c
* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
static char sccsid
[] = "@(#)dmesg.c 5.7 (Berkeley) %G%";
* Suck up system messages
* print and update incremental history
register char *mp
, *omp
, *mstart
;
int samef
, sawnl
, ignore
= 0;
if (argc
>1 && argv
[1][0] == '-') {
of
= open(_PATH_MSGBUF
, O_RDWR
| O_CREAT
, 0644);
done("Can't open msgbuf file\n");
read(of
, (char *)&omesg
, sizeof(omesg
));
nlist(argc
>2? argv
[2]:_PATH_UNIX
, nl
);
done("Can't get kernel namelist\n");
if ((mem
= open((argc
>1? argv
[1]: _PATH_KMEM
), 0)) < 0)
done("Can't read kernel memory\n");
lseek(mem
, (long)nl
[0].n_value
, 0);
read(mem
, &msgbuf
, sizeof (msgbuf
));
if (msgbuf
.msg_magic
!= MSG_MAGIC
)
done("Magic number wrong (namelist mismatch?)\n");
if (msgbuf
.msg_bufx
>= MSG_BSIZE
)
if (omesg
.msg_bufx
>= MSG_BSIZE
)
mstart
= &msgbuf
.msg_bufc
[omesg
.msg_bufx
];
omp
= &omesg
.msg_bufc
[msgbuf
.msg_bufx
];
mp
= msgbufp
= &msgbuf
.msg_bufc
[msgbuf
.msg_bufx
];
if (mp
>= &msgbuf
.msg_bufc
[MSG_BSIZE
])
if (omp
>= &omesg
.msg_bufc
[MSG_BSIZE
])
if (samef
&& omesg
.msg_bufx
== msgbuf
.msg_bufx
)
if (*mp
&& (*mp
& 0200) == 0 && !ignore
)
if (ignore
&& *mp
== '>')
if (mp
>= &msgbuf
.msg_bufc
[MSG_BSIZE
])
write(of
, (char *)&msgbuf
, sizeof(msgbuf
));
printf("\n%.12s\n", ctime(&tbuf
)+4);