#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)
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;
localconfinit();
conf.nwpath = conf.nfile*8;
- conf.nauth = conf.nfile/10;
conf.gidspace = conf.nuid*3;
cons.flags = 0;
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, 0220, p[0]);
close(p[0]);
/* use it as stdin */
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);
wpaths = malloc(conf.nwpath * sizeof(*wpaths));
uid = malloc(conf.nuid * sizeof(*uid));
gidspace = malloc(conf.gidspace * sizeof(*gidspace));
- authinit();
- print("iobufinit\n");
iobufinit();
arginit();
boottime = time(nil);
- print("sysinit\n");
sysinit();
-
srvinit();
+ installcmds();
+ cmd_exec("cfs");
+ cmd_exec("users");
+ cmd_exec("version");
+
/*
* post filedescriptors to /srv
*/
* processes to read the console
*/
consserve();
+
+ /* success */
+ exits(nil);
}
/*
cp->protocol = fsprotocol[i];
break;
}
- if(cp->protocol == nil){
+ if(cp->protocol == nil && (chatty > 1)){
print("no protocol for message\n");
- for(i = 0; i < 12; i++)
- print(" %2.2uX", mb->data[i]);
- print("\n");
+ hexdump(mb->data, 12);
}
} else
/* process the request, generate an answer and reply */
{
Timet nddate = nextime(t+MINUTE(100), DUMPTIME, WEEKMASK);
- if(!conf.nodump)
+ if(!conf.nodump && chatty)
print("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;
}