diff options
author | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-07-13 15:09:39 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-07-13 15:09:39 +0200 |
commit | 8e11ff283f1e7c36b23e6e52c2ab0ca12a7713f9 (patch) | |
tree | 21ae354f7121d196046b6b9c36a18232afb38e43 /sys/src/cmd/cwfs/main.c | |
parent | 53f5bdfd06cce8093de005b8d706b752d3567cfa (diff) |
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.
Diffstat (limited to 'sys/src/cmd/cwfs/main.c')
-rw-r--r-- | sys/src/cmd/cwfs/main.c | 42 |
1 files changed, 5 insertions, 37 deletions
diff --git a/sys/src/cmd/cwfs/main.c b/sys/src/cmd/cwfs/main.c index a3c8d49f7..8f6f2a8e5 100644 --- a/sys/src/cmd/cwfs/main.c +++ b/sys/src/cmd/cwfs/main.c @@ -15,38 +15,6 @@ machinit(void) 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 panic(char *fmt, ...) { @@ -191,7 +159,7 @@ postservice(void) if(pipe(p) < 0) panic("can't make a pipe"); snprint(buf, sizeof(buf), "#s/%s.cmd", service); - srvfd(buf, 0220, p[0]); + srvfd(buf, 0660, p[0]); close(p[0]); /* use it as stdin */ @@ -508,7 +476,7 @@ serve(void *) break; } if(cp->protocol == nil && (chatty > 1)){ - print("no protocol for message\n"); + fprint(2, "no protocol for message\n"); hexdump(mb->data, 12); } } else @@ -528,7 +496,7 @@ exit(void) active.exiting = 1; unlock(&active); - print("halted at %T.\n", time(nil)); + fprint(2, "halted at %T.\n", time(nil)); postnote(PNGROUP, getpid(), "die"); exits(nil); } @@ -548,7 +516,7 @@ nextdump(Timet t) Timet nddate = nextime(t+MINUTE(100), DUMPTIME, WEEKMASK); if(!conf.nodump && chatty) - print("next dump at %T\n", nddate); + fprint(2, "next dump at %T\n", nddate); return nddate; } @@ -583,7 +551,7 @@ wormcopy(void *) ntoytime = time(nil) + HOUR(1); else if(t > nddate) { if(!conf.nodump) { - print("automatic dump %T\n", t); + fprint(2, "automatic dump %T\n", t); for(fs=filsys; fs->name; fs++) if(fs->dev->type == Devcw) cfsdump(fs); |