cwfs: make /srv/cwfs.cmd redable to receive command output

before, cwfs would print everything to /dev/cons. this change
will redirect the output of commands to the /srv/cwfs.cmd pipe
so one can use:

con -C /srv/cwfs.cmd

and not have the fish for the output in /dev/kmesg.

use standard error (/dev/cons) for unsolicited messages as
there is not always a reader on the command file.
This commit is contained in:
cinap_lenrek 2012-07-13 15:09:39 +02:00
parent 53f5bdfd06
commit 8e11ff283f
18 changed files with 166 additions and 225 deletions

View file

@ -15,14 +15,14 @@ static void
f_nop(Chan *cp, Fcall*, Fcall*) f_nop(Chan *cp, Fcall*, Fcall*)
{ {
if(CHAT(cp)) if(CHAT(cp))
print("c_nop %d\n", cp->chan); fprint(2, "c_nop %d\n", cp->chan);
} }
static void static void
f_flush(Chan *cp, Fcall*, Fcall*) f_flush(Chan *cp, Fcall*, Fcall*)
{ {
if(CHAT(cp)) if(CHAT(cp))
print("c_flush %d\n", cp->chan); fprint(2, "c_flush %d\n", cp->chan);
runlock(&cp->reflock); runlock(&cp->reflock);
wlock(&cp->reflock); wlock(&cp->reflock);
wunlock(&cp->reflock); wunlock(&cp->reflock);
@ -53,7 +53,7 @@ f_session(Chan *cp, Fcall *in, Fcall *ou)
aip = (Authinfo*)cp->authinfo; aip = (Authinfo*)cp->authinfo;
if(CHAT(cp)) if(CHAT(cp))
print("c_session %d\n", cp->chan); fprint(2, "c_session %d\n", cp->chan);
memmove(aip->rchal, in->chal, sizeof(aip->rchal)); memmove(aip->rchal, in->chal, sizeof(aip->rchal));
mkchallenge(aip); mkchallenge(aip);
memmove(ou->chal, aip->chal, sizeof(ou->chal)); memmove(ou->chal, aip->chal, sizeof(ou->chal));
@ -90,21 +90,21 @@ authorize(Chan *cp, Fcall *in, Fcall *ou)
/* decrypt and unpack ticket */ /* decrypt and unpack ticket */
convM2T9p1(in->ticket, &t, nvr.machkey); convM2T9p1(in->ticket, &t, nvr.machkey);
if(t.num != AuthTs){ if(t.num != AuthTs){
print("9p1: bad AuthTs num\n"); fprint(2, "9p1: bad AuthTs num\n");
return 0; return 0;
} }
/* decrypt and unpack authenticator */ /* decrypt and unpack authenticator */
convM2A9p1(in->auth, &a, t.key); convM2A9p1(in->auth, &a, t.key);
if(a.num != AuthAc){ if(a.num != AuthAc){
print("9p1: bad AuthAc num\n"); fprint(2, "9p1: bad AuthAc num\n");
return 0; return 0;
} }
/* challenges must match */ /* challenges must match */
aip = (Authinfo*)cp->authinfo; aip = (Authinfo*)cp->authinfo;
if(memcmp(a.chal, aip->chal, sizeof(a.chal)) != 0){ if(memcmp(a.chal, aip->chal, sizeof(a.chal)) != 0){
print("9p1: bad challenge\n"); fprint(2, "9p1: bad challenge\n");
return 0; return 0;
} }
@ -118,7 +118,7 @@ authorize(Chan *cp, Fcall *in, Fcall *ou)
bit = 1<<x; bit = 1<<x;
if(x < 0 || x > 31 || (bit&aip->idvec)){ if(x < 0 || x > 31 || (bit&aip->idvec)){
unlock(&aip->idlock); unlock(&aip->idlock);
print("9p1: id out of range: idoff %ld idvec %lux id %ld\n", fprint(2, "9p1: id out of range: idoff %ld idvec %lux id %ld\n",
aip->idoffset, aip->idvec, a.id); aip->idoffset, aip->idvec, a.id);
return 0; return 0;
} }
@ -133,7 +133,7 @@ authorize(Chan *cp, Fcall *in, Fcall *ou)
/* ticket name and attach name must match */ /* ticket name and attach name must match */
if(memcmp(in->uname, t.cuid, sizeof(in->uname)) != 0){ if(memcmp(in->uname, t.cuid, sizeof(in->uname)) != 0){
print("9p1: names don't match\n"); fprint(2, "9p1: names don't match\n");
return 0; return 0;
} }
@ -196,10 +196,10 @@ f_attach(Chan *cp, Fcall *in, Fcall *ou)
Off raddr; Off raddr;
if(CHAT(cp)) { if(CHAT(cp)) {
print("c_attach %d\n", cp->chan); fprint(2, "c_attach %d\n", cp->chan);
print("\tfid = %d\n", in->fid); fprint(2, "\tfid = %d\n", in->fid);
print("\tuid = %s\n", in->uname); fprint(2, "\tuid = %s\n", in->uname);
print("\targ = %s\n", in->aname); fprint(2, "\targ = %s\n", in->aname);
} }
ou->qid = QID9P1(0,0); ou->qid = QID9P1(0,0);
@ -283,9 +283,9 @@ f_clone(Chan *cp, Fcall *in, Fcall *ou)
int fid, fid1; int fid, fid1;
if(CHAT(cp)) { if(CHAT(cp)) {
print("c_clone %d\n", cp->chan); fprint(2, "c_clone %d\n", cp->chan);
print("\told fid = %d\n", in->fid); fprint(2, "\told fid = %d\n", in->fid);
print("\tnew fid = %d\n", in->newfid); fprint(2, "\tnew fid = %d\n", in->newfid);
} }
fid = in->fid; fid = in->fid;
@ -343,9 +343,9 @@ f_walk(Chan *cp, Fcall *in, Fcall *ou)
Off addr, qpath; Off addr, qpath;
if(CHAT(cp)) { if(CHAT(cp)) {
print("c_walk %d\n", cp->chan); fprint(2, "c_walk %d\n", cp->chan);
print("\tfid = %d\n", in->fid); fprint(2, "\tfid = %d\n", in->fid);
print("\tname = %s\n", in->name); fprint(2, "\tname = %s\n", in->name);
} }
ou->fid = in->fid; ou->fid = in->fid;
@ -470,9 +470,9 @@ f_open(Chan *cp, Fcall *in, Fcall *ou)
int ro, fmod, wok; int ro, fmod, wok;
if(CHAT(cp)) { if(CHAT(cp)) {
print("c_open %d\n", cp->chan); fprint(2, "c_open %d\n", cp->chan);
print("\tfid = %d\n", in->fid); fprint(2, "\tfid = %d\n", in->fid);
print("\tmode = %o\n", in->mode); fprint(2, "\tmode = %o\n", in->mode);
} }
wok = 0; wok = 0;
@ -622,12 +622,12 @@ f_create(Chan *cp, Fcall *in, Fcall *ou)
Wpath *w; Wpath *w;
if(CHAT(cp)) { if(CHAT(cp)) {
print("c_create %d\n", cp->chan); fprint(2, "c_create %d\n", cp->chan);
print("\tfid = %d\n", in->fid); fprint(2, "\tfid = %d\n", in->fid);
print("\tname = %s\n", in->name); fprint(2, "\tname = %s\n", in->name);
print("\tperm = %lx+%lo\n", (in->perm>>28)&0xf, fprint(2, "\tperm = %lx+%lo\n", (in->perm>>28)&0xf,
in->perm&0777); in->perm&0777);
print("\tmode = %o\n", in->mode); fprint(2, "\tmode = %o\n", in->mode);
} }
wok = 0; wok = 0;
@ -818,10 +818,10 @@ f_read(Chan *cp, Fcall *in, Fcall *ou)
int nread, count, mask, n, o, slot; int nread, count, mask, n, o, slot;
if(CHAT(cp)) { if(CHAT(cp)) {
print("c_read %d\n", cp->chan); fprint(2, "c_read %d\n", cp->chan);
print("\tfid = %d\n", in->fid); fprint(2, "\tfid = %d\n", in->fid);
print("\toffset = %lld\n", (Wideoff)in->offset); fprint(2, "\toffset = %lld\n", (Wideoff)in->offset);
print("\tcount = %ld\n", in->count); fprint(2, "\tcount = %ld\n", in->count);
} }
p = 0; p = 0;
@ -983,7 +983,7 @@ dread:
goto out; goto out;
} }
if(convD2M9p1(d1, ou->data+nread) != n) if(convD2M9p1(d1, ou->data+nread) != n)
print("9p1: dirread convD2M1990\n"); fprint(2, "9p1: dirread convD2M1990\n");
nread += n; nread += n;
count -= n; count -= n;
} }
@ -1001,7 +1001,7 @@ out:
ou->fid = in->fid; ou->fid = in->fid;
ou->count = nread; ou->count = nread;
if(CHAT(cp)) if(CHAT(cp))
print("\tnread = %d\n", nread); fprint(2, "\tnread = %d\n", nread);
} }
static void static void
@ -1016,10 +1016,10 @@ f_write(Chan *cp, Fcall *in, Fcall *ou)
int count, nwrite, o, n; int count, nwrite, o, n;
if(CHAT(cp)) { if(CHAT(cp)) {
print("c_write %d\n", cp->chan); fprint(2, "c_write %d\n", cp->chan);
print("\tfid = %d\n", in->fid); fprint(2, "\tfid = %d\n", in->fid);
print("\toffset = %lld\n", (Wideoff)in->offset); fprint(2, "\toffset = %lld\n", (Wideoff)in->offset);
print("\tcount = %ld\n", in->count); fprint(2, "\tcount = %ld\n", in->count);
} }
offset = in->offset; offset = in->offset;
@ -1103,7 +1103,7 @@ f_write(Chan *cp, Fcall *in, Fcall *ou)
offset += n; offset += n;
} }
if(CHAT(cp)) if(CHAT(cp))
print("\tnwrite = %d\n", nwrite); fprint(2, "\tnwrite = %d\n", nwrite);
out: out:
if(p) if(p)
@ -1225,8 +1225,8 @@ f_clunk(Chan *cp, Fcall *in, Fcall *ou)
File *f; File *f;
if(CHAT(cp)) { if(CHAT(cp)) {
print("c_clunk %d\n", cp->chan); fprint(2, "c_clunk %d\n", cp->chan);
print("\tfid = %d\n", in->fid); fprint(2, "\tfid = %d\n", in->fid);
} }
f = filep(cp, in->fid, 0); f = filep(cp, in->fid, 0);
@ -1245,8 +1245,8 @@ f_remove(Chan *cp, Fcall *in, Fcall *ou)
File *f; File *f;
if(CHAT(cp)) { if(CHAT(cp)) {
print("c_remove %d\n", cp->chan); fprint(2, "c_remove %d\n", cp->chan);
print("\tfid = %d\n", in->fid); fprint(2, "\tfid = %d\n", in->fid);
} }
f = filep(cp, in->fid, 0); f = filep(cp, in->fid, 0);
@ -1267,8 +1267,8 @@ f_stat(Chan *cp, Fcall *in, Fcall *ou)
File *f; File *f;
if(CHAT(cp)) { if(CHAT(cp)) {
print("c_stat %d\n", cp->chan); fprint(2, "c_stat %d\n", cp->chan);
print("\tfid = %d\n", in->fid); fprint(2, "\tfid = %d\n", in->fid);
} }
p = 0; p = 0;
@ -1289,7 +1289,7 @@ f_stat(Chan *cp, Fcall *in, Fcall *ou)
if(d->qid.path == QPROOT) /* stat of root gives time */ if(d->qid.path == QPROOT) /* stat of root gives time */
d->atime = time(nil); d->atime = time(nil);
if(convD2M9p1(d, ou->stat) != DIRREC) if(convD2M9p1(d, ou->stat) != DIRREC)
print("9p1: stat convD2M\n"); fprint(2, "9p1: stat convD2M\n");
out: out:
if(p) if(p)
@ -1309,8 +1309,8 @@ f_wstat(Chan *cp, Fcall *in, Fcall *ou)
Off addr; Off addr;
if(CHAT(cp)) { if(CHAT(cp)) {
print("c_wstat %d\n", cp->chan); fprint(2, "c_wstat %d\n", cp->chan);
print("\tfid = %d\n", in->fid); fprint(2, "\tfid = %d\n", in->fid);
} }
p = 0; p = 0;
@ -1349,10 +1349,10 @@ f_wstat(Chan *cp, Fcall *in, Fcall *ou)
convM2D9p1(in->stat, &xd); convM2D9p1(in->stat, &xd);
if(CHAT(cp)) { if(CHAT(cp)) {
print("\td.name = %s\n", xd.name); fprint(2, "\td.name = %s\n", xd.name);
print("\td.uid = %d\n", xd.uid); fprint(2, "\td.uid = %d\n", xd.uid);
print("\td.gid = %d\n", xd.gid); fprint(2, "\td.gid = %d\n", xd.gid);
print("\td.mode = %o\n", xd.mode); fprint(2, "\td.mode = %o\n", xd.mode);
} }
/* /*
@ -1481,7 +1481,7 @@ f_clwalk(Chan *cp, Fcall *in, Fcall *ou)
int er, fid; int er, fid;
if(CHAT(cp)) if(CHAT(cp))
print("c_clwalk macro\n"); fprint(2, "c_clwalk macro\n");
f_clone(cp, in, ou); /* sets tag, fid */ f_clone(cp, in, ou); /* sets tag, fid */
if(ou->err) if(ou->err)
@ -1500,7 +1500,7 @@ f_clwalk(Chan *cp, Fcall *in, Fcall *ou)
ou->err = 0; ou->err = 0;
ou->fid = fid; ou->fid = fid;
if(CHAT(cp)) if(CHAT(cp))
print("\terror: %s\n", errstr9p[er]); fprint(2, "\terror: %s\n", errstr9p[er]);
} else if(er) { } else if(er) {
/* /*
* if any other error * if any other error
@ -1542,16 +1542,8 @@ error9p1(Chan* cp, Msgbuf* mb)
{ {
Msgbuf *mb1; Msgbuf *mb1;
print("type=%d count=%d\n", mb->data[0], mb->count); fprint(2, "type=%d count=%d\n", mb->data[0], mb->count);
print(" %.2x %.2x %.2x %.2x\n", hexdump(mb->data, 12);
mb->data[1]&0xff, mb->data[2]&0xff,
mb->data[3]&0xff, mb->data[4]&0xff);
print(" %.2x %.2x %.2x %.2x\n",
mb->data[5]&0xff, mb->data[6]&0xff,
mb->data[7]&0xff, mb->data[8]&0xff);
print(" %.2x %.2x %.2x %.2x\n",
mb->data[9]&0xff, mb->data[10]&0xff,
mb->data[11]&0xff, mb->data[12]&0xff);
mb1 = mballoc(3, cp, Mbreply4); mb1 = mballoc(3, cp, Mbreply4);
mb1->data[0] = Rnop; /* your nop was ok */ mb1->data[0] = Rnop; /* your nop was ok */
@ -1579,13 +1571,13 @@ serve9p1(Msgbuf* mb)
assert(cp != nil); assert(cp != nil);
if(cp->protocol == nil) if(cp->protocol == nil)
return 0; return 0;
print("9p1: bad M2S conversion\n"); fprint(2, "9p1: bad M2S conversion\n");
return error9p1(cp, mb); return error9p1(cp, mb);
} }
t = fi.type; t = fi.type;
if(t < 0 || t >= MAXSYSCALL || (t&1) || !call9p1[t]) { if(t < 0 || t >= MAXSYSCALL || (t&1) || !call9p1[t]) {
print("9p1: bad message type\n"); fprint(2, "9p1: bad message type\n");
return error9p1(cp, mb); return error9p1(cp, mb);
} }
@ -1611,16 +1603,16 @@ serve9p1(Msgbuf* mb)
if(fo.err) { if(fo.err) {
if(cons.flags&errorflag) if(cons.flags&errorflag)
print("\ttype %d: error: %s\n", t, errstr9p[fo.err]); fprint(2, "\ttype %d: error: %s\n", t, errstr9p[fo.err]);
if(CHAT(cp)) if(CHAT(cp))
print("\terror: %s\n", errstr9p[fo.err]); fprint(2, "\terror: %s\n", errstr9p[fo.err]);
fo.type = Rerror; fo.type = Rerror;
strncpy(fo.ename, errstr9p[fo.err], sizeof(fo.ename)); strncpy(fo.ename, errstr9p[fo.err], sizeof(fo.ename));
} }
n = convS2M9p1(&fo, mb1->data); n = convS2M9p1(&fo, mb1->data);
if(n == 0) { if(n == 0) {
print("9p1: bad S2M conversion\n"); fprint(2, "9p1: bad S2M conversion\n");
mbfree(mb1); mbfree(mb1);
return error9p1(cp, mb); return error9p1(cp, mb);
} }

View file

@ -31,7 +31,7 @@ convS2M9p1(Fcall *f, uchar *ap)
SHORT(tag); SHORT(tag);
switch(t) { switch(t) {
default: default:
print("convS2M9p1: bad type: %d\n", t); fprint(2, "convS2M9p1: bad type: %d\n", t);
return 0; return 0;
case Tnop: case Tnop:
@ -298,7 +298,7 @@ convM2S9p1(uchar *ap, Fcall *f, int n)
* only whine if it couldn't be a 9P2000 Tversion. * only whine if it couldn't be a 9P2000 Tversion.
*/ */
if(t != 19 || ap[4] != 100) if(t != 19 || ap[4] != 100)
print("convM2S9p1: bad type: %d\n", f->type); fprint(2, "convM2S9p1: bad type: %d\n", f->type);
return 0; return 0;
case Tnop: case Tnop:

View file

@ -204,7 +204,7 @@ authorize(Chan* chan, Fcall* f)
if(strcmp(f->uname, "none") == 0){ if(strcmp(f->uname, "none") == 0){
uid = strtouid(f->uname); uid = strtouid(f->uname);
if(db) if(db)
print("permission granted to none: uid %s = %d\n", fprint(2, "permission granted to none: uid %s = %d\n",
f->uname, uid); f->uname, uid);
return uid; return uid;
} }
@ -212,7 +212,7 @@ authorize(Chan* chan, Fcall* f)
if(noauth || wstatallow){ if(noauth || wstatallow){
uid = strtouid(f->uname); uid = strtouid(f->uname);
if(db) if(db)
print("permission granted by noauth uid %s = %d\n", fprint(2, "permission granted by noauth uid %s = %d\n",
f->uname, uid); f->uname, uid);
return uid; return uid;
} }
@ -220,7 +220,7 @@ authorize(Chan* chan, Fcall* f)
af = filep(chan, f->afid, 0); af = filep(chan, f->afid, 0);
if(af == nil){ if(af == nil){
if(db) if(db)
print("authorize: af == nil\n"); fprint(2, "authorize: af == nil\n");
return -1; return -1;
} }
@ -228,7 +228,7 @@ authorize(Chan* chan, Fcall* f)
authread(af, nil, 0); authread(af, nil, 0);
uid = af->uid; uid = af->uid;
if(db) if(db)
print("authorize: uid is %d\n", uid); fprint(2, "authorize: uid is %d\n", uid);
qunlock(af); qunlock(af);
return uid; return uid;
} }
@ -1707,18 +1707,17 @@ serve9p2(Msgbuf* mb)
* 1 return means i dealt with it, including error * 1 return means i dealt with it, including error
* replies. * replies.
*/ */
if(convM2S(mb->data, mb->count, &f) != mb->count) if(convM2S(mb->data, mb->count, &f) != mb->count){
{ fprint(2, "didn't like %d byte message\n", mb->count);
print("didn't like %d byte message\n", mb->count);
return 0; return 0;
} }
type = f.type; type = f.type;
if(type < Tversion || type >= Tmax || (type & 1) || type == Terror) if(type < Tversion || type >= Tmax || (type & 1) || type == Terror)
return 0; return 0;
chan = mb->chan; chan = mb->chan;
if(CHAT(chan)) if(CHAT(chan))
print("9p2: f %F\n", &f); fprint(2, "9p2: f %F\n", &f);
r.type = type+1; r.type = type+1;
r.tag = f.tag; r.tag = f.tag;
error = 0; error = 0;
@ -1786,7 +1785,7 @@ print("didn't like %d byte message\n", mb->count);
r.ename = errstr9p[error]; r.ename = errstr9p[error];
} }
if(CHAT(chan)) if(CHAT(chan))
print("9p2: r %F\n", &r); fprint(2, "9p2: r %F\n", &r);
rmb = mballoc(chan->msize, chan, Mbreply2); rmb = mballoc(chan->msize, chan, Mbreply2);
n = convS2M(&r, rmb->data, chan->msize); n = convS2M(&r, rmb->data, chan->msize);
@ -1812,7 +1811,7 @@ print("didn't like %d byte message\n", mb->count);
r.ename = ename; r.ename = ename;
n = convS2M(&r, rmb->data, chan->msize); n = convS2M(&r, rmb->data, chan->msize);
} }
print("%s\n", r.ename); fprint(2, "%s\n", r.ename);
if(n == 0){ if(n == 0){
/* /*
* What to do here, the failure notification failed? * What to do here, the failure notification failed?

View file

@ -423,11 +423,9 @@ fsck(Dentry *d)
} }
if(flags & Cpdir) { if(flags & Cpdir) {
print("%s\n", name); print("%s\n", name);
prflush();
} }
} else if(flags & Cpfile) { } else if(flags & Cpfile) {
print("%s\n", name); print("%s\n", name);
prflush();
} }
/* check qid */ /* check qid */

View file

@ -26,6 +26,9 @@ consserve(void)
break; break;
} }
/* switch console output to the cmd pipe */
dup(0, 1);
newproc(consserve1, 0, "con"); newproc(consserve1, 0, "con");
} }
@ -35,15 +38,10 @@ consserve1(void *)
{ {
char *conline; char *conline;
for (;;) { while(conline = Brdline(&bin, '\n')){
do {
if ((conline = Brdline(&bin, '\n')) != nil) {
conline[Blinelen(&bin)-1] = '\0'; conline[Blinelen(&bin)-1] = '\0';
print("%s: %s\n", service, conline);
cmd_exec(conline); cmd_exec(conline);
} }
} while (conline != nil);
}
} }
static int static int
@ -112,7 +110,6 @@ cmd_exec(char *arg)
for(i=0; s=command[i].arg0; i++) for(i=0; s=command[i].arg0; i++)
if(strcmp(argv[0], s) == 0) { if(strcmp(argv[0], s) == 0) {
(*command[i].func)(argc, argv); (*command[i].func)(argc, argv);
prflush();
return; return;
} }
print("cmd_exec: unknown command: %s\n", argv[0]); print("cmd_exec: unknown command: %s\n", argv[0]);
@ -319,7 +316,6 @@ cmd_who(int argc, char *argv[])
if(cp->whoprint) if(cp->whoprint)
cp->whoprint(cp); cp->whoprint(cp);
print("\n"); print("\n");
prflush();
} }
if(c > 0) if(c > 0)
print("%d chans not listed\n", c); print("%d chans not listed\n", c);
@ -353,7 +349,6 @@ cmd_sync(int, char *[])
wlock(&mainlock); /* sync */ wlock(&mainlock); /* sync */
sync("command"); sync("command");
wunlock(&mainlock); wunlock(&mainlock);
print("\n");
} }
static void static void
@ -371,7 +366,6 @@ cmd_help(int argc, char *argv[])
} }
found: found:
print("\t%s %s\n", arg, command[i].help); print("\t%s %s\n", arg, command[i].help);
prflush();
} }
} }
@ -696,16 +690,14 @@ void
cmd_noauth(int, char *[]) cmd_noauth(int, char *[])
{ {
noauth = !noauth; noauth = !noauth;
if(noauth) print("authentication %s\n", noauth ? "disabled" : "enabled");
print("authentication is DISABLED\n");
} }
void void
cmd_noattach(int, char *[]) cmd_noattach(int, char *[])
{ {
noattach = !noattach; noattach = !noattach;
if(noattach) print("attach %s\n", noattach ? "disabled" : "enabled");
print("attaches are DISABLED\n");
} }
void void
@ -731,7 +723,6 @@ cmd_files(int, char *[])
for(cp = chans; cp; cp = cp->next) for(cp = chans; cp; cp = cp->next)
if(cp->nfile) { if(cp->nfile) {
print("%3d: %5d\n", cp->chan, cp->nfile); print("%3d: %5d\n", cp->chan, cp->nfile);
prflush();
n += cp->nfile; n += cp->nfile;
} }
print("%ld out of %ld files used\n", n, conf.nfile); print("%ld out of %ld files used\n", n, conf.nfile);

View file

@ -9,7 +9,7 @@ fcall9p1(Chan *cp, Fcall *in, Fcall *ou)
rlock(&mainlock); rlock(&mainlock);
t = in->type; t = in->type;
if(t < 0 || t >= MAXSYSCALL || (t&1) || !call9p1[t]) { if(t < 0 || t >= MAXSYSCALL || (t&1) || !call9p1[t]) {
print("bad message type %d\n", t); fprint(2, "bad message type %d\n", t);
panic(""); panic("");
} }
ou->type = t+1; ou->type = t+1;
@ -20,7 +20,7 @@ fcall9p1(Chan *cp, Fcall *in, Fcall *ou)
runlock(&cp->reflock); runlock(&cp->reflock);
if(ou->err && CHAT(cp)) if(ou->err && CHAT(cp))
print("\terror: %s\n", errstr9p[ou->err]); fprint(2, "\terror: %s\n", errstr9p[ou->err]);
runlock(&mainlock); runlock(&mainlock);
} }
@ -205,8 +205,8 @@ f_fstat(Chan *cp, Fcall *in, Fcall *ou)
int i; int i;
if(CHAT(cp)) { if(CHAT(cp)) {
print("c_fstat %d\n", cp->chan); fprint(2, "c_fstat %d\n", cp->chan);
print("\tfid = %d\n", in->fid); fprint(2, "\tfid = %d\n", in->fid);
} }
p = 0; p = 0;
@ -246,8 +246,8 @@ f_clri(Chan *cp, Fcall *in, Fcall *ou)
File *f; File *f;
if(CHAT(cp)) { if(CHAT(cp)) {
print("c_clri %d\n", cp->chan); fprint(2, "c_clri %d\n", cp->chan);
print("\tfid = %d\n", in->fid); fprint(2, "\tfid = %d\n", in->fid);
} }
f = filep(cp, in->fid, 0); f = filep(cp, in->fid, 0);

View file

@ -293,7 +293,7 @@ dumpblock(Device *dev)
} }
if(cw->ncopy){ if(cw->ncopy){
if(chatty) if(chatty)
print("%lld blocks copied to worm\n", (Wideoff)cw->ncopy); fprint(2, "%lld blocks copied to worm\n", (Wideoff)cw->ncopy);
cw->ncopy = 0; cw->ncopy = 0;
} }
cw->nodump = 1; cw->nodump = 1;
@ -370,7 +370,7 @@ stop1:
stop: stop:
putbuf(p1); putbuf(p1);
putbuf(p); putbuf(p);
print("stopping dump!!\n"); fprint(2, "stopping dump!!\n");
cw->nodump = 1; cw->nodump = 1;
return 0; return 0;
} }
@ -425,7 +425,7 @@ cwinit(Device *dev)
m = h->wsize; m = h->wsize;
if(l != m) { if(l != m) {
if(chatty) if(chatty)
print("wdev changed size %lld to %lld\n", fprint(2, "wdev changed size %lld to %lld\n",
(Wideoff)m, (Wideoff)l); (Wideoff)m, (Wideoff)l);
h->wsize = l; h->wsize = l;
cb->flags |= Bmod; cb->flags |= Bmod;
@ -521,13 +521,13 @@ roread(Device *dev, Off b, void *c)
s = cwio(d, b, c, Oread); s = cwio(d, b, c, Oread);
if(s == Cdump || s == Cdump1 || s == Cread) { if(s == Cdump || s == Cdump1 || s == Cread) {
if(cons.flags & roflag) if(cons.flags & roflag)
print("roread: %Z %lld -> %Z(hit)\n", fprint(2, "roread: %Z %lld -> %Z(hit)\n",
dev, (Wideoff)b, d); dev, (Wideoff)b, d);
return 0; return 0;
} }
} }
if(cons.flags & roflag) if(cons.flags & roflag)
print("roread: %Z %lld -> %Z(miss)\n", fprint(2, "roread: %Z %lld -> %Z(miss)\n",
dev, (Wideoff)b, WDEV(d)); dev, (Wideoff)b, WDEV(d));
return devread(WDEV(d), b, c); return devread(WDEV(d), b, c);
} }
@ -726,7 +726,7 @@ cwio(Device *dev, Off addr, void *buf, int opcode)
break; break;
} }
if(chatty > 1) if(chatty > 1)
print("cwio: %Z %lld s=%s o=%s ns=%s\n", fprint(2, "cwio: %Z %lld s=%s o=%s ns=%s\n",
dev, (Wideoff)addr, cwnames[state], dev, (Wideoff)addr, cwnames[state],
cwnames[opcode], cwnames[opcode],
cwnames[c->state]); cwnames[c->state]);
@ -1163,7 +1163,7 @@ rewalk1(Cw *cw, Off addr, int slot, Wpath *up)
return addr; return addr;
} }
if(chatty > 1) if(chatty > 1)
print("rewalk1 %lld to %lld \"%s\"\n", fprint(2, "rewalk1 %lld to %lld \"%s\"\n",
(Wideoff)addr, (Wideoff)p1->addr, d->name); (Wideoff)addr, (Wideoff)p1->addr, d->name);
addr = p1->addr; addr = p1->addr;
p1->flags |= Bmod; p1->flags |= Bmod;
@ -1197,7 +1197,7 @@ rewalk2(Cw *cw, Off addr, int slot, Wpath *up)
return addr; return addr;
} }
if(chatty > 1) if(chatty > 1)
print("rewalk2 %lld to %lld \"%s\"\n", fprint(2, "rewalk2 %lld to %lld \"%s\"\n",
(Wideoff)addr, (Wideoff)p1->addr, d->name); (Wideoff)addr, (Wideoff)p1->addr, d->name);
addr = p1->addr; addr = p1->addr;
putbuf(p1); putbuf(p1);
@ -1309,7 +1309,7 @@ cwrecur(Cw *cw, Off addr, int tag, int tag1, long qp)
if(!isdirty(cw, p, addr, tag)) { if(!isdirty(cw, p, addr, tag)) {
if(!cw->all) { if(!cw->all) {
if(chatty > 1) if(chatty > 1)
print("cwrecur: %lld t=%s not dirty %s\n", fprint(2, "cwrecur: %lld t=%s not dirty %s\n",
(Wideoff)addr, tagnames[tag], cw->name); (Wideoff)addr, tagnames[tag], cw->name);
if(p) if(p)
putbuf(p); putbuf(p);
@ -1318,7 +1318,7 @@ cwrecur(Cw *cw, Off addr, int tag, int tag1, long qp)
shouldstop = 1; shouldstop = 1;
} }
if(chatty > 1) if(chatty > 1)
print("cwrecur: %lld t=%s %s\n", fprint(2, "cwrecur: %lld t=%s %s\n",
(Wideoff)addr, tagnames[tag], cw->name); (Wideoff)addr, tagnames[tag], cw->name);
if(cw->depth >= 100) { if(cw->depth >= 100) {
fprint(2, "dump depth too great %s\n", cw->name); fprint(2, "dump depth too great %s\n", cw->name);
@ -1489,14 +1489,14 @@ cfsdump(Filsys *fs)
cw->fsize = cwsize(cw->dev); cw->fsize = cwsize(cw->dev);
orba = cwraddr(cw->dev); orba = cwraddr(cw->dev);
if(chatty) if(chatty)
print("cwroot %lld", (Wideoff)orba); fprint(2, "cwroot %lld", (Wideoff)orba);
cons.noage = 1; cons.noage = 1;
cw->all = cw->allflag; cw->all = cw->allflag;
rba = cwrecur(cw, orba, Tsuper, 0, QPROOT); rba = cwrecur(cw, orba, Tsuper, 0, QPROOT);
if(rba == 0) if(rba == 0)
rba = orba; rba = orba;
if(chatty) if(chatty)
print("->%lld\n", (Wideoff)rba); fprint(2, "->%lld\n", (Wideoff)rba);
sync("after cw"); sync("after cw");
/* /*
@ -1606,7 +1606,7 @@ found:
cw->fsize = cwsize(cw->dev); cw->fsize = cwsize(cw->dev);
oroa = cwraddr(cw->rodev); /* probably redundant */ oroa = cwraddr(cw->rodev); /* probably redundant */
if(chatty) if(chatty)
print("roroot %lld", (Wideoff)oroa); fprint(2, "roroot %lld", (Wideoff)oroa);
cons.noage = 0; cons.noage = 0;
cw->all = 0; cw->all = 0;
@ -1614,7 +1614,7 @@ found:
if(roa == 0) if(roa == 0)
roa = oroa; roa = oroa;
if(chatty) if(chatty)
print("->%lld /%.4s/%s\n", (Wideoff)roa, tstr, tstr+4); fprint(2, "->%lld /%.4s/%s\n", (Wideoff)roa, tstr, tstr+4);
sync("after ro"); sync("after ro");
/* /*
@ -1622,7 +1622,7 @@ found:
*/ */
a = cwsaddr(cw->dev); a = cwsaddr(cw->dev);
if(chatty) if(chatty)
print("sblock %lld", (Wideoff)a); fprint(2, "sblock %lld", (Wideoff)a);
p = getbuf(cw->dev, a, Brd|Bmod|Bimm); p = getbuf(cw->dev, a, Brd|Bmod|Bimm);
s = (Superb*)p->iobuf; s = (Superb*)p->iobuf;
s->last = a; s->last = a;
@ -1636,7 +1636,7 @@ found:
cwio(cw->dev, sba, p->iobuf, Owrite); cwio(cw->dev, sba, p->iobuf, Owrite);
cwio(cw->dev, sba, 0, Odump); cwio(cw->dev, sba, 0, Odump);
if(chatty) if(chatty)
print("->%lld (->%lld)\n", (Wideoff)sba, (Wideoff)s->next); fprint(2, "->%lld (->%lld)\n", (Wideoff)sba, (Wideoff)s->next);
putbuf(p); putbuf(p);
@ -1654,8 +1654,8 @@ found:
sync("all done"); sync("all done");
if(chatty){ if(chatty){
print("%lld blocks queued for worm\n", (Wideoff)cw->ndump); fprint(2, "%lld blocks queued for worm\n", (Wideoff)cw->ndump);
print("%lld falsehits\n", (Wideoff)cw->falsehits); fprint(2, "%lld falsehits\n", (Wideoff)cw->falsehits);
} }
cw->nodump = 0; cw->nodump = 0;

View file

@ -56,7 +56,7 @@ rel2abs(Iobuf *p, Dentry *d, Off a, int tag, int putb, int uid)
Device *dev; Device *dev;
if(a < 0) { if(a < 0) {
print("rel2abs: neg offset\n"); fprint(2, "rel2abs: neg offset\n");
if(putb) if(putb)
putbuf(p); putbuf(p);
return 0; return 0;
@ -111,7 +111,7 @@ rel2abs(Iobuf *p, Dentry *d, Off a, int tag, int putb, int uid)
putbuf(p); putbuf(p);
/* quintuple-indirect blocks not implemented. */ /* quintuple-indirect blocks not implemented. */
print("rel2abs: no %d-deep indirect\n", NIBLOCK+1); fprint(2, "rel2abs: no %d-deep indirect\n", NIBLOCK+1);
return 0; return 0;
} }
@ -186,10 +186,10 @@ indfetch(Device* d, Off qpath, Off addr, Off a, int itag, int tag, int uid)
bp = getbuf(d, addr, Brd); bp = getbuf(d, addr, Brd);
if(!bp || checktag(bp, itag, qpath)) { if(!bp || checktag(bp, itag, qpath)) {
if(!bp) { if(!bp) {
print("ind fetch bp = 0\n"); fprint(2, "ind fetch bp = 0\n");
return 0; return 0;
} }
print("ind fetch tag\n"); fprint(2, "ind fetch tag\n");
putbuf(bp); putbuf(bp);
return 0; return 0;
} }

View file

@ -54,7 +54,7 @@ fwormread(Device *d, Off b, void *c)
Devsize l; Devsize l;
if(chatty > 1) if(chatty > 1)
print("fworm read %lld\n", (Wideoff)b); fprint(2, "fworm read %lld\n", (Wideoff)b);
fdev = FDEV(d); fdev = FDEV(d);
l = devsize(fdev); l = devsize(fdev);
l -= l/(BUFSIZE*8) + 1; l -= l/(BUFSIZE*8) + 1;
@ -83,7 +83,7 @@ fwormwrite(Device *d, Off b, void *c)
Devsize l; Devsize l;
if(chatty > 1) if(chatty > 1)
print("fworm write %lld\n", (Wideoff)b); fprint(2, "fworm write %lld\n", (Wideoff)b);
fdev = FDEV(d); fdev = FDEV(d);
l = devsize(fdev); l = devsize(fdev);
l -= l/(BUFSIZE*8) + 1; l -= l/(BUFSIZE*8) + 1;

View file

@ -12,7 +12,7 @@ getbuf(Device *d, Off addr, int flag)
Off h; Off h;
if(chatty > 1) if(chatty > 1)
print("getbuf %Z(%lld) f=%x\n", d, (Wideoff)addr, flag); fprint(2, "getbuf %Z(%lld) f=%x\n", d, (Wideoff)addr, flag);
h = addr + (Off)(uintptr)d*1009; h = addr + (Off)(uintptr)d*1009;
if(h < 0) if(h < 0)
h = ~h; h = ~h;
@ -174,7 +174,7 @@ sync(char *reason)
long i; long i;
if(chatty) if(chatty)
print("sync: %s\n", reason); fprint(2, "sync: %s\n", reason);
for(i=10*nhiob; i>0; i--) for(i=10*nhiob; i>0; i--)
if(!syncblock()) if(!syncblock())
return; return;

View file

@ -161,7 +161,7 @@ wormlabel(Device *d, Side *v)
panic("wrong ordinal in label"); panic("wrong ordinal in label");
} }
if(chatty) if(chatty)
print("label %Z ordinal %d\n", d, v->ord); fprint(2, "label %Z ordinal %d\n", d, v->ord);
qunlock(v); qunlock(v);
/* /*
* wormunit should return without calling us again, * wormunit should return without calling us again,
@ -212,7 +212,7 @@ wormunit(Device *d) /* d is l0 or r2 (e.g.) */
delay(100); delay(100);
} }
if(chatty) if(chatty)
print("\tload r%ld drive %Z\n", v-w->side, w->drive[drive]); fprint(2, "\tload r%ld drive %Z\n", v-w->side, w->drive[drive]);
if(mmove(w, w->mt0, v->elem, w->dt0+drive, v->rot)) { if(mmove(w, w->mt0, v->elem, w->dt0+drive, v->rot)) {
qunlock(w); qunlock(w);
goto sbad; goto sbad;
@ -265,7 +265,7 @@ wormunit(Device *d) /* d is l0 or r2 (e.g.) */
v->block = inqsize(dr->wren.sddata); v->block = inqsize(dr->wren.sddata);
if(v->block <= 0) { if(v->block <= 0) {
if(chatty) if(chatty)
print("\twormunit %Z block size %ld, setting to %d\n", fprint(2, "\twormunit %Z block size %ld, setting to %d\n",
d, v->block, Sectorsz); d, v->block, Sectorsz);
v->block = Sectorsz; v->block = Sectorsz;
} }
@ -278,11 +278,11 @@ wormunit(Device *d) /* d is l0 or r2 (e.g.) */
v->max = (v->nblock + 1) / v->mult; v->max = (v->nblock + 1) / v->mult;
if(chatty){ if(chatty){
print("\tworm %Z: drive %Z (juke drive %d)\n", fprint(2, "\tworm %Z: drive %Z (juke drive %d)\n",
d, w->drive[v->drive], v->drive); d, w->drive[v->drive], v->drive);
print("\t\t%,ld %ld-byte sectors, ", v->nblock, v->block); fprint(2, "\t\t%,ld %ld-byte sectors, ", v->nblock, v->block);
print("%,ld %d-byte blocks\n", v->max, RBUFSIZE); fprint(2, "%,ld %d-byte blocks\n", v->max, RBUFSIZE);
print("\t\t%ld multiplier\n", v->mult); fprint(2, "\t\t%ld multiplier\n", v->mult);
} }
if(d->type == Devlworm) if(d->type == Devlworm)
return wormlabel(d, v); return wormlabel(d, v);
@ -325,7 +325,7 @@ waitready(Juke *w, Device *d)
rv = 0; rv = 0;
for(e=0; e < 100; e++) { for(e=0; e < 100; e++) {
if(e == 10 && chatty) if(e == 10 && chatty)
print("waitready: waiting for %s to exist\n", datanm); fprint(2, "waitready: waiting for %s to exist\n", datanm);
if(access(datanm, AEXIST) >= 0){ if(access(datanm, AEXIST) >= 0){
rv = 1; rv = 1;
break; break;
@ -398,7 +398,7 @@ loop:
goto loop; goto loop;
} }
if(chatty) if(chatty)
print("\tunload r%ld drive %Z\n", fprint(2, "\tunload r%ld drive %Z\n",
v-w->side, w->drive[drive]); v-w->side, w->drive[drive]);
if(mmove(w, w->mt0, w->dt0+drive, v->elem, v->rot)) { if(mmove(w, w->mt0, w->dt0+drive, v->elem, v->rot)) {
qunlock(v); qunlock(v);
@ -472,7 +472,7 @@ devtojuke(Device *d, Device *top)
* but we're not supposed to get here. * but we're not supposed to get here.
*/ */
if(chatty) if(chatty)
print("devtojuke: (l)worm %Z of %Z encountered\n", d, top); fprint(2, "devtojuke: (l)worm %Z of %Z encountered\n", d, top);
/* FALL THROUGH */ /* FALL THROUGH */
case Devwren: case Devwren:
return nil; return nil;
@ -731,17 +731,17 @@ mmove(Juke *w, int trans, int from, int to, int rot)
cmd[10] = 1; cmd[10] = 1;
s = scsiio(w->juke, SCSInone, cmd, sizeof cmd, buf, 0); /* mmove */ s = scsiio(w->juke, SCSInone, cmd, sizeof cmd, buf, 0); /* mmove */
if(s) { if(s) {
print("scsio status #%x\n", s); fprint(2, "scsio status #%x\n", s);
print("move medium t=%d fr=%d to=%d rot=%d\n", fprint(2, "move medium t=%d fr=%d to=%d rot=%d\n",
trans, from, to, rot); trans, from, to, rot);
// panic("mmove"); // panic("mmove");
if(recur == 0) { if(recur == 0) {
recur = 1; recur = 1;
print("element from=%d\n", from); fprint(2, "element from=%d\n", from);
element(w, from); element(w, from);
print("element to=%d\n", to); fprint(2, "element to=%d\n", to);
element(w, to); element(w, to);
print("element trans=%d\n", trans); fprint(2, "element trans=%d\n", trans);
element(w, trans); element(w, trans);
recur = 0; recur = 0;
} }
@ -787,12 +787,11 @@ geometry(Juke *w)
w->rot = buf[4+2] & 1; w->rot = buf[4+2] & 1;
print("\tmt %d %d\n", w->mt0, w->nmt); fprint(2, "\tmt %d %d\n", w->mt0, w->nmt);
print("\tse %d %d\n", w->se0, w->nse); fprint(2, "\tse %d %d\n", w->se0, w->nse);
print("\tie %d %d\n", w->ie0, w->nie); fprint(2, "\tie %d %d\n", w->ie0, w->nie);
print("\tdt %d %d\n", w->dt0, w->ndt); fprint(2, "\tdt %d %d\n", w->dt0, w->ndt);
print("\trot %d\n", w->rot); fprint(2, "\trot %d\n", w->rot);
prflush();
} }
/* /*
@ -862,7 +861,7 @@ element(Juke *w, int e)
if(s < 0 || s >= w->nie) if(s < 0 || s >= w->nie)
goto bad; goto bad;
if(chatty) if(chatty)
print("import/export %d #%.2x %d.%d\n", s, fprint(2, "import/export %d #%.2x %d.%d\n", s,
buf[8+8+2], buf[8+8+2],
(buf[8+8+10]<<8) | buf[8+8+11], (buf[8+8+10]<<8) | buf[8+8+11],
(buf[8+8+9]>>6) & 1); (buf[8+8+9]>>6) & 1);
@ -872,7 +871,7 @@ element(Juke *w, int e)
if(s < 0 || s >= w->ndt) if(s < 0 || s >= w->ndt)
goto bad; goto bad;
if(chatty) if(chatty)
print("data transfer %d #%.2x %d.%d\n", s, fprint(2, "data transfer %d #%.2x %d.%d\n", s,
buf[8+8+2], buf[8+8+2],
(buf[8+8+10]<<8) | buf[8+8+11], (buf[8+8+10]<<8) | buf[8+8+11],
(buf[8+8+9]>>6) & 1); (buf[8+8+9]>>6) & 1);
@ -893,7 +892,7 @@ element(Juke *w, int e)
goto bad; goto bad;
} }
if(chatty) if(chatty)
print("r%d in drive %d\n", t, s); fprint(2, "r%d in drive %d\n", t, s);
if(mmove(w, w->mt0, w->dt0+s, w->se0+t,(buf[8+8+9]>>6) & 1)){ if(mmove(w, w->mt0, w->dt0+s, w->se0+t,(buf[8+8+9]>>6) & 1)){
fprint(2, "mmove initial unload\n"); fprint(2, "mmove initial unload\n");
goto bad; goto bad;
@ -1174,7 +1173,7 @@ querychanger(Device *xdev)
jukelist = w; jukelist = w;
if(chatty) if(chatty)
print("alloc juke %Z\n", xdev); fprint(2, "alloc juke %Z\n", xdev);
qlock(w); qlock(w);
qunlock(w); qunlock(w);
@ -1208,7 +1207,7 @@ querychanger(Device *xdev)
w->ndrive = w->ndt; w->ndrive = w->ndt;
if(w->ndrive > MAXDRIVE) { if(w->ndrive > MAXDRIVE) {
if(chatty) if(chatty)
print("ndrives truncated to %d\n", MAXDRIVE); fprint(2, "ndrives truncated to %d\n", MAXDRIVE);
w->ndrive = MAXDRIVE; w->ndrive = MAXDRIVE;
} }
@ -1320,7 +1319,7 @@ wormprobe(void)
if(v->status == Sstart && t > v->time) { if(v->status == Sstart && t > v->time) {
drive = v->drive; drive = v->drive;
if(chatty) if(chatty)
print("\ttime r%ld drive %Z\n", fprint(2, "\ttime r%ld drive %Z\n",
v-w->side, w->drive[drive]); v-w->side, w->drive[drive]);
mmove(w, w->mt0, w->dt0+drive, v->elem, v->rot); mmove(w, w->mt0, w->dt0+drive, v->elem, v->rot);
v->status = Sunload; v->status = Sunload;

View file

@ -15,38 +15,6 @@ machinit(void)
active.exiting = 0; active.exiting = 0;
} }
/*
* Put a string on the console.
*/
void
puts(char *s, int n)
{
print("%.*s", n, s);
}
void
prflush(void)
{
}
/*
* Print a string on the console.
*/
void
putstrn(char *str, int n)
{
puts(str, n);
}
/*
* get a character from the console
*/
int
getc(void)
{
return Bgetrune(&bin);
}
void void
panic(char *fmt, ...) panic(char *fmt, ...)
{ {
@ -191,7 +159,7 @@ postservice(void)
if(pipe(p) < 0) if(pipe(p) < 0)
panic("can't make a pipe"); panic("can't make a pipe");
snprint(buf, sizeof(buf), "#s/%s.cmd", service); snprint(buf, sizeof(buf), "#s/%s.cmd", service);
srvfd(buf, 0220, p[0]); srvfd(buf, 0660, p[0]);
close(p[0]); close(p[0]);
/* use it as stdin */ /* use it as stdin */
@ -508,7 +476,7 @@ serve(void *)
break; break;
} }
if(cp->protocol == nil && (chatty > 1)){ if(cp->protocol == nil && (chatty > 1)){
print("no protocol for message\n"); fprint(2, "no protocol for message\n");
hexdump(mb->data, 12); hexdump(mb->data, 12);
} }
} else } else
@ -528,7 +496,7 @@ exit(void)
active.exiting = 1; active.exiting = 1;
unlock(&active); unlock(&active);
print("halted at %T.\n", time(nil)); fprint(2, "halted at %T.\n", time(nil));
postnote(PNGROUP, getpid(), "die"); postnote(PNGROUP, getpid(), "die");
exits(nil); exits(nil);
} }
@ -548,7 +516,7 @@ nextdump(Timet t)
Timet nddate = nextime(t+MINUTE(100), DUMPTIME, WEEKMASK); Timet nddate = nextime(t+MINUTE(100), DUMPTIME, WEEKMASK);
if(!conf.nodump && chatty) if(!conf.nodump && chatty)
print("next dump at %T\n", nddate); fprint(2, "next dump at %T\n", nddate);
return nddate; return nddate;
} }
@ -583,7 +551,7 @@ wormcopy(void *)
ntoytime = time(nil) + HOUR(1); ntoytime = time(nil) + HOUR(1);
else if(t > nddate) { else if(t > nddate) {
if(!conf.nodump) { if(!conf.nodump) {
print("automatic dump %T\n", t); fprint(2, "automatic dump %T\n", t);
for(fs=filsys; fs->name; fs++) for(fs=filsys; fs->name; fs++)
if(fs->dev->type == Devcw) if(fs->dev->type == Devcw)
cfsdump(fs); cfsdump(fs);

View file

@ -57,7 +57,7 @@ mcatread(Device *d, Off b, void *c)
return devread(x, b-l, c); return devread(x, b-l, c);
l += m; l += m;
} }
print("mcatread past end: %Z block %lld, %lld beyond end\n", fprint(2, "mcatread past end: %Z block %lld, %lld beyond end\n",
d, (Wideoff)b, (Wideoff)l); d, (Wideoff)b, (Wideoff)l);
return 1; return 1;
} }
@ -79,7 +79,7 @@ mcatwrite(Device *d, Off b, void *c)
return devwrite(x, b-l, c); return devwrite(x, b-l, c);
l += m; l += m;
} }
print("mcatwrite past end: %Z block %lld, %lld beyond end\n", fprint(2, "mcatwrite past end: %Z block %lld, %lld beyond end\n",
d, (Wideoff)b, (Wideoff)l); d, (Wideoff)b, (Wideoff)l);
return 1; return 1;
} }
@ -176,7 +176,7 @@ partread(Device *d, Off b, void *c)
size = l*100; size = l*100;
if(b < size) if(b < size)
return devread(d->part.d, base+b, c); return devread(d->part.d, base+b, c);
print("partread past end: %Z blk %lld size %lld\n", fprint(2, "partread past end: %Z blk %lld size %lld\n",
d, (Wideoff)b, (Wideoff)size); d, (Wideoff)b, (Wideoff)size);
return 1; return 1;
} }
@ -193,7 +193,7 @@ partwrite(Device *d, Off b, void *c)
size = l*100; size = l*100;
if(b < size) if(b < size)
return devwrite(d->part.d, base+b, c); return devwrite(d->part.d, base+b, c);
print("partwrite past end: %Z blk %lld size %lld\n", fprint(2, "partwrite past end: %Z blk %lld size %lld\n",
d, (Wideoff)b, (Wideoff)size); d, (Wideoff)b, (Wideoff)size);
return 1; return 1;
} }
@ -239,7 +239,7 @@ mirrread(Device *d, Off b, void *c)
Device *x; Device *x;
if (d->cat.first == nil) { if (d->cat.first == nil) {
print("mirrread: empty mirror %Z\n", d); fprint(2, "mirrread: empty mirror %Z\n", d);
return 1; return 1;
} }
for(x=d->cat.first; x; x=x->link) { for(x=d->cat.first; x; x=x->link) {
@ -249,7 +249,7 @@ mirrread(Device *d, Off b, void *c)
return 0; return 0;
} }
// DANGER WILL ROBINSON // DANGER WILL ROBINSON
print("mirrread: all mirrors of %Z block %lld are bad\n", fprint(2, "mirrread: all mirrors of %Z block %lld are bad\n",
d, (Wideoff)b); d, (Wideoff)b);
return 1; return 1;
} }
@ -268,7 +268,7 @@ ewrite(Device *x, Off b, void *c)
if(x->size == 0) if(x->size == 0)
x->size = devsize(x); x->size = devsize(x);
if (devwrite(x, b, c) != 0) { if (devwrite(x, b, c) != 0) {
print("mirrwrite: error at %Z block %lld\n", x, (Wideoff)b); fprint(2, "mirrwrite: error at %Z block %lld\n", x, (Wideoff)b);
return 1; return 1;
} }
return 0; return 0;
@ -289,7 +289,7 @@ int
mirrwrite(Device *d, Off b, void *c) mirrwrite(Device *d, Off b, void *c)
{ {
if (d->cat.first == nil) { if (d->cat.first == nil) {
print("mirrwrite: empty mirror %Z\n", d); fprint(2, "mirrwrite: empty mirror %Z\n", d);
return 1; return 1;
} }
return wrmirrs1st(d->cat.first, b, c); return wrmirrs1st(d->cat.first, b, c);

View file

@ -54,8 +54,6 @@ neti(void *v)
Network *net; Network *net;
net = v; net = v;
if(chatty)
print("net%di\n", net->ctlrno);
for(;;) { for(;;) {
if((lisfd = listen(net->anndir, net->lisdir)) < 0){ if((lisfd = listen(net->anndir, net->lisdir)) < 0){
fprint(2, "listen %s failed: %r\n", net->anndir); fprint(2, "listen %s failed: %r\n", net->anndir);

View file

@ -90,7 +90,6 @@ int fwormread(Device*, Off, void*);
int fwormwrite(Device*, Off, void*); int fwormwrite(Device*, Off, void*);
Iobuf* getbuf(Device*, Off, int); Iobuf* getbuf(Device*, Off, int);
char* getwrd(char*, char*); char* getwrd(char*, char*);
int getc(void);
Dentry* getdir(Iobuf*, int); Dentry* getdir(Iobuf*, int);
Chan* getlcp(uchar*, long); Chan* getlcp(uchar*, long);
Off getraddr(Device*); Off getraddr(Device*);
@ -163,13 +162,11 @@ Devsize partsize(Device*);
int partwrite(Device*, Off, void*); int partwrite(Device*, Off, void*);
void prdate(void); void prdate(void);
void preread(Device*, Off); void preread(Device*, Off);
void prflush(void);
int prime(vlong); int prime(vlong);
void printinit(void); void printinit(void);
void procinit(void); void procinit(void);
void procsetname(char *fmt, ...); void procsetname(char *fmt, ...);
void putbuf(Iobuf*); void putbuf(Iobuf*);
void putstrn(char *str, int n);
Off qidpathgen(Device*); Off qidpathgen(Device*);
void qlock(QLock*); void qlock(QLock*);
void* querychanger(Device *); void* querychanger(Device *);
@ -196,7 +193,6 @@ int serve9p1(Msgbuf*);
int serve9p2(Msgbuf*); int serve9p2(Msgbuf*);
void settag(Iobuf*, int, long); void settag(Iobuf*, int, long);
void settime(Timet); void settime(Timet);
void startprint(void);
int strtouid(char*); int strtouid(char*);
Off superaddr(Device*); Off superaddr(Device*);
void superream(Device*, Off); void superream(Device*, Off);

View file

@ -279,14 +279,14 @@ scsireqsense(Target* tp, char lun, int* nbytes, int quiet)
buggery: buggery:
if(quiet == 0){ if(quiet == 0){
s = key[sense[2]&0x0F]; s = key[sense[2]&0x0F];
print("%s: reqsense: '%s' code #%2.2ux #%2.2ux\n", fprint(2, "%s: reqsense: '%s' code #%2.2ux #%2.2ux\n",
tp->id, s, sense[12], sense[13]); tp->id, s, sense[12], sense[13]);
print("%s: byte 2: #%2.2ux, bytes 15-17: #%2.2ux #%2.2ux #%2.2ux\n", fprint(2, "%s: byte 2: #%2.2ux, bytes 15-17: #%2.2ux #%2.2ux #%2.2ux\n",
tp->id, sense[2], sense[15], sense[16], sense[17]); tp->id, sense[2], sense[15], sense[16], sense[17]);
print("lastcmd (%d): ", lastcmdsz); fprint(2, "lastcmd (%d): ", lastcmdsz);
for(n = 0; n < lastcmdsz; n++) for(n = 0; n < lastcmdsz; n++)
print(" #%2.2ux", lastcmd[n]); fprint(2, " #%2.2ux", lastcmd[n]);
print("\n"); fprint(2, "\n");
} }
return STcheck; return STcheck;
@ -321,7 +321,7 @@ scsiprobe(Device* d)
again: again:
s = scsitest(tp, d->wren.lun); s = scsitest(tp, d->wren.lun);
if(s < STok){ if(s < STok){
print("%s: test, status %d\n", tp->id, s); fprint(2, "%s: test, status %d\n", tp->id, s);
return; return;
} }
@ -350,7 +350,7 @@ again:
if(sense[12] == 0x3A) if(sense[12] == 0x3A)
break; break;
if(sense[12] == 0x04 && sense[13] == 0x02){ if(sense[12] == 0x04 && sense[13] == 0x02){
print("%s: starting...\n", tp->id); fprint(2, "%s: starting...\n", tp->id);
if(scsistart(tp, d->wren.lun, 1) == STok) if(scsistart(tp, d->wren.lun, 1) == STok)
break; break;
s = scsireqsense(tp, d->wren.lun, &nbytes, 0); s = scsireqsense(tp, d->wren.lun, &nbytes, 0);
@ -358,7 +358,7 @@ again:
} }
/*FALLTHROUGH*/ /*FALLTHROUGH*/
default: default:
print("%s: unavailable, status %d\n", tp->id, s); fprint(2, "%s: unavailable, status %d\n", tp->id, s);
return; return;
} }
@ -368,10 +368,10 @@ again:
*/ */
s = scsiinquiry(tp, d->wren.lun, &nbytes); s = scsiinquiry(tp, d->wren.lun, &nbytes);
if(s != STok) { if(s != STok) {
print("%s: inquiry failed, status %d\n", tp->id, s); fprint(2, "%s: inquiry failed, status %d\n", tp->id, s);
return; return;
} }
print("%s: %s\n", tp->id, (char*)tp->inquiry+8); fprint(2, "%s: %s\n", tp->id, (char*)tp->inquiry+8);
tp->ok = 1; tp->ok = 1;
} }
@ -408,7 +408,7 @@ scsiio(Device* d, int rw, uchar* cmd, int cbytes, void* data, int dbytes)
break; break;
} }
if(e) if(e)
print("%s: retry %d cmd #%x\n", tp->id, e, cmd[0]); fprint(2, "%s: retry %d cmd #%x\n", tp->id, e, cmd[0]);
return s; return s;
} }

View file

@ -36,7 +36,7 @@ chanhangup(Chan *chan, char *msg)
if(chan == cons.chan || srv == nil || srv->chan != chan) if(chan == cons.chan || srv == nil || srv->chan != chan)
return; return;
if(msg[0] && chatty) if(msg[0] && chatty)
print("hangup %s: %s\n", chan->whochan, msg); fprint(2, "hangup %s: %s\n", chan->whochan, msg);
if(fd2path(srv->fd, buf, sizeof(buf)) == 0){ if(fd2path(srv->fd, buf, sizeof(buf)) == 0){
if(p = strrchr(buf, '/')){ if(p = strrchr(buf, '/')){
strecpy(p, buf+sizeof(buf), "/ctl"); strecpy(p, buf+sizeof(buf), "/ctl");
@ -61,7 +61,7 @@ srvput(Srv *srv)
chan = srv->chan; chan = srv->chan;
fileinit(chan); fileinit(chan);
if(chatty) if(chatty)
print("%s closed\n", chan->whochan); fprint(2, "%s closed\n", chan->whochan);
lock(&freechans); lock(&freechans);
srv->chan = freechans.hd; srv->chan = freechans.hd;
freechans.hd = chan; freechans.hd = chan;

View file

@ -836,7 +836,7 @@ mbfree(Msgbuf *mb)
if (mb->magic != Mbmagic) if (mb->magic != Mbmagic)
panic("mbfree: bad magic 0x%lux", mb->magic); panic("mbfree: bad magic 0x%lux", mb->magic);
if(mb->flags & BTRACE) if(mb->flags & BTRACE)
print("mbfree: BTRACE cat=%d flags=%ux, caller %#p\n", fprint(2, "mbfree: BTRACE cat=%d flags=%ux, caller %#p\n",
mb->category, mb->flags, getcallerpc(&mb)); mb->category, mb->flags, getcallerpc(&mb));
if(mb->flags & FREE) if(mb->flags & FREE)
@ -909,12 +909,12 @@ hexdump(void *a, int n)
sprint(s2, " %.2ux", p[i]); sprint(s2, " %.2ux", p[i]);
strcat(s1, s2); strcat(s1, s2);
if((i&7) == 7) { if((i&7) == 7) {
print("%s\n", s1); fprint(2, "%s\n", s1);
s1[0] = 0; s1[0] = 0;
} }
} }
if(s1[0]) if(s1[0])
print("%s\n", s1); fprint(2, "%s\n", s1);
} }
void* void*