#include "stdinc.h" #include #include "9h.h" int Dflag; int mempcnt; /* for 9fsys.c */ char* none = "none"; char* foptname = "/none/such"; static void usage(void) { fprint(2, "usage: %s [-Dt] [-c cmd] [-f partition] [-m %%]\n", argv0); exits("usage"); } static void readCmdPart(char *file, char ***pcmd, int *pncmd) { char buf[1024+1], *f[1024]; char tbuf[1024]; int nf; int i, fd, n; char **cmd, *p; int ncmd; cmd = *pcmd; ncmd = *pncmd; if((fd = open(file, OREAD)) < 0) sysfatal("open %s: %r", file); if(seek(fd, 127*1024, 0) != 127*1024) sysfatal("seek %s 127kB: %r", file); n = readn(fd, buf, sizeof buf-1); if(n == 0) sysfatal("short read of %s at 127kB", file); if(n < 0) sysfatal("read %s: %r", file); buf[n] = 0; if(memcmp(buf, "fossil config\n", 6+1+6+1) != 0) sysfatal("bad config magic in %s", file); nf = getfields(buf+6+1+6+1, f, nelem(f), 1, "\n"); for(i=0; i= 100) usage(); break; case 't': tflag = 1; break; }ARGEND if(argc != 0) usage(); consInit(); cliInit(); msgInit(); conInit(); cmdInit(); fsysInit(); exclInit(); fidInit(); srvInit(); lstnInit(); usersInit(); for(i = 0; i < ncmd; i++) if(cliExec(cmd[i]) == 0) fprint(2, "%s: %R\n", cmd[i]); vtMemFree(cmd); if(tflag && consTTY() == 0) consPrint("%s\n", vtGetError()); vtDetach(); exits(0); }