mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
7455f5ea42
Also add a /bin/dmesg program for convenience.
31 lines
665 B
C++
31 lines
665 B
C++
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <fcntl.h>
|
|
#include <assert.h>
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
(void) argc;
|
|
(void) argv;
|
|
int fd = open("/proc/dmesg", O_RDONLY);
|
|
if (fd < 0) {
|
|
perror("open /proc/dmesg");
|
|
return 1;
|
|
}
|
|
for (;;) {
|
|
char buffer[BUFSIZ];
|
|
ssize_t nread = read(fd, buffer, sizeof(buffer));
|
|
if (nread < 0) {
|
|
perror("read");
|
|
return 1;
|
|
}
|
|
if (nread == 0) {
|
|
break;
|
|
}
|
|
ssize_t nwritten = write(1, buffer, nread);
|
|
assert(nwritten == nread);
|
|
}
|
|
int rc = close(fd);
|
|
assert(rc == 0);
|
|
return 0;
|
|
}
|