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:
parent
dd468419f2
commit
fd8d404d52
15 changed files with 0 additions and 59 deletions
66
sys/src/cmd/touchfs.c
Normal file
66
sys/src/cmd/touchfs.c
Normal file
|
@ -0,0 +1,66 @@
|
|||
#include <u.h>
|
||||
#include <libc.h>
|
||||
#include <bio.h>
|
||||
|
||||
void
|
||||
Bpass(Biobuf *bin, Biobuf *bout, int n)
|
||||
{
|
||||
char buf[8192];
|
||||
int m;
|
||||
|
||||
while(n > 0) {
|
||||
m = sizeof buf;
|
||||
if(m > n)
|
||||
m = n;
|
||||
m = Bread(bin, buf, m);
|
||||
if(m <= 0) {
|
||||
fprint(2, "corrupt archive\n");
|
||||
exits("notdone");
|
||||
}
|
||||
Bwrite(bout, buf, m);
|
||||
n -= m;
|
||||
}
|
||||
assert(n == 0);
|
||||
}
|
||||
|
||||
void
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char *p, *f[10];
|
||||
Biobuf bin, bout;
|
||||
int nf;
|
||||
ulong d, size;
|
||||
|
||||
if(argc != 2) {
|
||||
fprint(2, "usage: cat mkfs-archive | touchfs date (in seconds)\n");
|
||||
exits("usage");
|
||||
}
|
||||
|
||||
d = strtoul(argv[1], 0, 0);
|
||||
|
||||
quotefmtinstall();
|
||||
Binit(&bin, 0, OREAD);
|
||||
Binit(&bout, 1, OWRITE);
|
||||
|
||||
while(p = Brdline(&bin, '\n')) {
|
||||
p[Blinelen(&bin)-1] = '\0';
|
||||
if(strcmp(p, "end of archive") == 0) {
|
||||
Bprint(&bout, "end of archive\n");
|
||||
exits(0);
|
||||
}
|
||||
|
||||
nf = tokenize(p, f, nelem(f));
|
||||
if(nf != 6) {
|
||||
fprint(2, "corrupt archive\n");
|
||||
exits("notdone");
|
||||
}
|
||||
|
||||
Bprint(&bout, "%q %q %q %q %lud %q\n",
|
||||
f[0], f[1], f[2], f[3], d, f[5]);
|
||||
|
||||
size = strtoul(f[5], 0, 0);
|
||||
Bpass(&bin, &bout, size);
|
||||
}
|
||||
fprint(2, "premature end of archive\n");
|
||||
exits("notdone");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue