ref: 271a7db1cd9afb4cf841101188199c3a0d0f4c62
dir: /main.c/
#include "u.h" #include "lib.h" #include "kern/dat.h" #include "kern/fns.h" #include "user.h" #include "drawcpu.h" #include "ip.h" #include "authsrv.h" char *argv0; char *authserver = ""; char *dbgfile = "./debug.log"; void sizebug(void) { /* * Needed by various parts of the code. * This is a huge bug. */ assert(sizeof(char)==1); assert(sizeof(short)==2); assert(sizeof(ushort)==2); assert(sizeof(int)==4); assert(sizeof(uint)==4); assert(sizeof(long)==4); assert(sizeof(ulong)==4); assert(sizeof(vlong)==8); assert(sizeof(uvlong)==8); } // TODO: remove libgui, or at least revamp as cpubody goes away void cpubody(void) {} char* estrdup(char *s) { s = strdup(s); if(s == nil) sysfatal("out of memory"); return s; } int main(int argc, char **argv) { int fd; char s[1024]; extern ulong kerndate; kerndate = seconds(); eve = getuser(); if(eve == nil) eve = "drawcpu"; sizebug(); osinit(); procinit0(); printinit(); chandevreset(); chandevinit(); quotefmtinstall(); if(bind("#c", "/dev", MBEFORE) < 0) panic("bind #c: %r"); if(bind("#e", "/env", MREPL|MCREATE) < 0) panic("bind #e: %r"); if(bind("#I", "/net", MBEFORE) < 0) panic("bind #I: %r"); if(bind("#U", "/root", MREPL) < 0) panic("bind #U: %r"); bind("#A", "/dev", MAFTER); bind("#N", "/dev", MAFTER); bind("#C", "/", MAFTER); if(bind("/root", "/", MAFTER) < 0) panic("bind /root: %r"); if((fd = open("/dev/cons", OREAD)) < 0) panic("open stdin: %r"); if(read(fd, s, sizeof s) <= 0) panic("read: %r"); close(fd); char *cmd[] = { "/bin/rc", "-c", s }; printf("%s %s %s\n", cmd[0], cmd[1], cmd[2]); runcommand(3, cmd); _exit(0); }