#include "io.h"
#include "9p1.h"
-extern int oldcachefmt;
-
Map *devmap;
-int sfd, rfd;
Biobuf bin;
+int chatty = 0;
+int sfd = -1;
void
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, ...)
{
n = vseprint(buf, buf + sizeof buf, fmt, arg) - buf;
va_end(arg);
buf[n] = '\0';
- print("panic: %s\n", buf);
+ fprint(2, "panic: %s\n", buf);
exit();
}
if (bp == nil)
sysfatal("can't read %s", mapfile);
devmap = nil;
- while ((ln = Brdline(bp, '\n')) != nil) {
+ while((ln = Brdline(bp, '\n')) != nil) {
ln[Blinelen(bp)-1] = '\0';
- if (*ln == '\0' || *ln == '#')
+ if(*ln == '\0' || *ln == '#')
continue;
nf = tokenize(ln, fields, nelem(fields));
- if (nf != 2)
+ if(nf != 2)
continue;
if(testconfig(fields[0]) != 0) {
print("bad `from' device %s in %s\n",
map->to = strdup(fields[1]);
map->fdev = iconfig(fields[0]);
map->tdev = nil;
- if (access(map->to, AEXIST) < 0) {
+ if(access(map->to, AEXIST) < 0) {
/*
* map->to isn't an existing file, so it had better be
* a config string for a device.
{
conf.nmach = 1;
- conf.mem = meminit();
-
conf.nuid = 1000;
conf.nserve = 15; /* tunable */
conf.nfile = 30000;
if(service[0] == 0)
panic("no service name");
- if(sfd < 0){
- if(pipe(p) < 0)
- panic("can't make a pipe");
- sfd = p[0];
- rfd = p[1];
+ /* serve 9p for -s */
+ if(sfd >= 0){
+ srvchan(sfd, "stdio");
+ sfd = -1;
}
/* post 9p service */
- snprint(buf, sizeof(buf), "#s/%s", service);
- srvfd(buf, 0666, sfd);
- close(sfd);
- srvchan(rfd, buf);
-
if(pipe(p) < 0)
panic("can't make a pipe");
+ snprint(buf, sizeof(buf), "#s/%s", service);
+ srvfd(buf, 0666, p[0]);
+ close(p[0]);
+ srvchan(p[1], buf);
/* post cmd service */
+ if(pipe(p) < 0)
+ panic("can't make a pipe");
snprint(buf, sizeof(buf), "#s/%s.cmd", service);
- srvfd(buf, 0222, p[0]);
+ srvfd(buf, 0660, p[0]);
close(p[0]);
/* use it as stdin */
}
/*
- * compute BUFSIZE*(NDBLOCK+INDPERBUF+INDPERBUFâ\81²+INDPERBUFâ\81³+INDPERBUFâ\81´)
+ * compute BUFSIZE*(NDBLOCK+INDPERBUF+INDPERBUF²+INDPERBUF³+INDPERBUFâ\81´)
* while watching for overflow; in that case, return 0.
*/
}
enum {
- INDPERBUF = ((uvlong)INDPERBUF *INDPERBUF),
- INDPERBUF⁴ = ((uvlong)INDPERBUFâ\81²*INDPERBUFâ\81²),
+ INDPERBUF² = ((uvlong)INDPERBUF*INDPERBUF),
+ INDPERBUF⁴ = ((uvlong)INDPERBUF²*INDPERBUF²),
};
static void
max = offlim - 1;
print("max file size = %,llud\n", (Wideoff)max);
}
- if (INDPERBUFâ\81²/INDPERBUF != INDPERBUF)
- print("overflow computing INDPERBUFâ\81²\n");
- if (INDPERBUF⁴/INDPERBUFâ\81² != INDPERBUFâ\81²)
+ if (INDPERBUF²/INDPERBUF != INDPERBUF)
+ print("overflow computing INDPERBUF²\n");
+ if (INDPERBUF⁴/INDPERBUF² != INDPERBUF²)
print("overflow computing INDPERBUF⁴\n");
print("\tINDPERBUF = %d, INDPERBUF^4 = %,lld, ", INDPERBUF,
(Wideoff)INDPERBUF⁴);
rfork(RFNOTEG);
formatinit();
machinit();
- conf.confdev = "/dev/sdC0/cwfs";
-
- rfd = sfd = -1;
+ conf.confdev = "/dev/sdC0/fscache";
+ conf.newcache = 0;
ARGBEGIN{
case 'a': /* announce on this net */
strcpy(service, EARGF(usage()));
break;
case 's':
- sfd = dup(0, -1);
- rfd = dup(1, -1);
+ dup(0, -1);
+ sfd = dup(1, -1);
close(0);
if(open("/dev/cons", OREAD) < 0)
open("#c/cons", OREAD);
open("#c/cons", OWRITE);
break;
case 'C': /* use new, faster cache layout */
- oldcachefmt = 0;
+ conf.newcache = 1;
break;
case 'c':
conf.configfirst++;
case 'm': /* name device-map file */
conf.devmap = EARGF(usage());
break;
+ case 'd':
+ chatty++;
+ break;
default:
usage();
break;
Binit(&bin, 0, OREAD);
confinit();
- print("\nPlan 9 %d-bit cached-worm file server with %d-deep indir blks\n",
- sizeof(Off)*8 - 1, NIBLOCK);
- printsizes();
+ if(chatty){
+ print("\nPlan 9 %d-bit cached-worm file server with %d-deep indir blks\n",
+ sizeof(Off)*8 - 1, NIBLOCK);
+ printsizes();
+ }
- qlock(&reflock);
- qunlock(&reflock);
serveq = newqueue(1000, "9P service"); /* tunable */
raheadq = newqueue(1000, "readahead"); /* tunable */
uid = malloc(conf.nuid * sizeof(*uid));
gidspace = malloc(conf.gidspace * sizeof(*gidspace));
- print("iobufinit\n");
iobufinit();
arginit();
boottime = time(nil);
- print("sysinit\n");
sysinit();
-
srvinit();
/*
*/
postservice();
+ /*
+ * processes to read the console
+ */
+ consserve();
+
/*
* Ethernet i/o processes
*/
*/
newproc(synccopy, 0, "scp");
- /*
- * processes to read the console
- */
- consserve();
-
/* success */
exits(nil);
}
Msgbuf *mb;
for (;;) {
- qlock(&reflock);
/* read 9P request from a network input process */
mb = fs_recv(serveq, 0);
assert(mb->magic == Mbmagic);
if (cp == nil)
panic("serve: nil mb->chan");
rlock(&cp->reflock);
- qunlock(&reflock);
rlock(&mainlock);
cp->protocol = fsprotocol[i];
break;
}
- if(cp->protocol == nil){
- print("no protocol for message\n");
- for(i = 0; i < 12; i++)
- print(" %2.2uX", mb->data[i]);
- print("\n");
+ if(cp->protocol == nil && (chatty > 1)){
+ fprint(2, "no protocol for message\n");
+ hexdump(mb->data, 12);
}
} else
/* process the request, generate an answer and reply */
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);
}
{
Timet nddate = nextime(t+MINUTE(100), DUMPTIME, WEEKMASK);
- if(!conf.nodump)
- print("next dump at %T\n", nddate);
+ if(!conf.nodump && chatty)
+ fprint(2, "next dump at %T\n", nddate);
return nddate;
}
}
dt = time(nil) - t;
if(dt < 0 || dt > MINUTE(100)) {
- if(dt < 0)
- print("time went back\n");
- else
- print("time jumped ahead\n");
dorecalc = 1;
continue;
}
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);