Promote the old installer/livecd specific tools to normal tools under /sys/src/cmd. Where similar common tools already existed, I kept them.

This commit is contained in:
iru 2011-04-14 00:35:48 -03:00
parent dd468419f2
commit fd8d404d52
15 changed files with 0 additions and 59 deletions

View file

@ -1,59 +0,0 @@
#include <u.h>
#include <libc.h>
#include <bio.h>
char *argv0;
int
openlog(char *name)
{
int fd;
fd = open(name, OWRITE);
if(fd < 0){
fprint(2, "%s: can't open %s: %r\n", argv0, name);
return -1;
}
seek(fd, 0, 2);
return fd;
}
void
main(int argc, char **argv)
{
Biobuf in;
int fd;
char *p, *t;
char buf[8192];
argv0 = argv[0];
if(argc != 4){
fprint(2, "usage: %s console logfile prefix\n", argv0);
exits("usage");
}
fd = open(argv[1], OREAD);
if(fd < 0){
fprint(2, "%s: can't open %s: %r\n", argv0, argv[1]);
exits("open");
}
Binit(&in, fd, OREAD);
fd = openlog(argv[2]);
for(;;){
if(p = Brdline(&in, '\n')){
p[Blinelen(&in)-1] = 0;
if(fprint(fd, "%s: %s\n", argv[3], p) < 0){
close(fd);
fd = openlog(argv[2]);
fprint(fd, "%s: %s\n", t, p);
}
} else if(Blinelen(&in) == 0) // true eof
break;
else {
Bread(&in, buf, sizeof buf);
}
}
exits(0);
}