## diffname power/boot.c 1990/0227 ## diff -e /dev/null /n/bootesdump/1990/0227/sys/src/9/mips/boot.c 0a #include #include #include Fcall hdr; char buf[100]; char srv[100]; void error(char *); typedef struct address { char *name; char *cmd; } Address; Address addr[] = { { "ross", "connect 020701005eff" }, { "bootes", "connect 080069020205" }, { "helix", "connect 080069020427" }, { "spindle", "connect 0800690202df" }, { "r70", "connect 08002b04265d" }, { "bitbootes", "bitconnect" }, { 0 } }; #define DEFUSER "bootes" char * lookup(char *arg) { Address *a; if(strcmp(arg, "?")==0 || strcmp(arg, "help")==0){ for(a = addr; a->name; a++) print("%s\n", a->name); return 0; } for(a = addr; a->name; a++){ if(strcmp(a->name, arg) == 0) return a->cmd; } return 0; } main(int argc, char *argv[]) { int cfd, fd, n, fu, f; char buf[NAMELEN]; char *scmd; open("#c/cons", 0); open("#c/cons", 1); open("#c/cons", 1); /* * get server */ do{ do{ print("server[%s]: ", addr[0].name); n = read(0, srv, sizeof srv); }while(n==0); if(n < 0) error("can't read #c/cons; please reboot"); if(n == 1) strcpy(srv, addr[0].name); else srv[n-1] = 0; scmd = lookup(srv); }while(scmd == 0); /* * get user. if the user typed cr to the server question, skip * the user question and just use the default. */ if(n != 1){ do{ print("user[%s]: ", DEFUSER); n = read(0, buf, sizeof buf); }while(n==0); if(n < 0) error("can't read #c/cons; please reboot"); if(n == 1) strcpy(buf, DEFUSER); else buf[n-1] = 0; }else strcpy(buf, DEFUSER); fu = create("#c/user", 1, 0600); if(fu < 0) error("#c/user"); n = strlen(buf); if(write(fu, buf, n) != n) error("user write"); close(fu); if(strcmp(scmd, "bitconnect") == 0){ fd = open("#b/bit", ORDWR); if(fd < 0) error("opening #b/bit"); goto Mesg; } /* * grab a lance channel, make it recognize ether type 0x900, * and push the nonet ethernet multiplexor onto it. */ cfd = open("#l/1/ctl", 2); if(cfd < 0) error("opening #l/1/ctl"); if(write(cfd, "connect 0x900", sizeof("connect 0x900")-1)<0) error("connect 0x900"); if(write(cfd, "push noether", sizeof("push noether")-1)<0) error("push noether"); /* * grab a nonet channel and call up the ross file server */ fd = open("#n/1/data", 2); if(fd < 0) error("opening #n/1/data"); cfd = open("#n/1/ctl", 2); if(cfd < 0) error("opening #n/1/ctl"); if(write(cfd, scmd, strlen(scmd))<0) error(scmd); Mesg: print("nop..."); hdr.type = Tnop; n = convS2M(&hdr, buf); if(write(fd, buf, n) != n) error("write nop"); n = read(fd, buf, sizeof buf); if(n <= 0) error("read nop"); if(convM2S(buf, &hdr, n) == 0) { print("n = %d; buf = %.2x %.2x %.2x %.2x\n", n, buf[0], buf[1], buf[2], buf[3]); error("format nop"); } if(hdr.type != Rnop) error("not Rnop"); print("session..."); hdr.type = Tsession; hdr.lang = 'v'; n = convS2M(&hdr, buf); if(write(fd, buf, n) != n) error("write session"); n = read(fd, buf, sizeof buf); if(n <= 0) error("read session"); if(convM2S(buf, &hdr, n) == 0) error("format session"); if(hdr.type != Rsession) error("not Rsession"); if(hdr.err){ print("error %d;", hdr.err); error("remote error"); } print("post..."); sprint(buf, "#s/%s", srv); f = create(buf, 1, 0666); if(f < 0) error("create"); sprint(buf, "%d", fd); if(write(f, buf, strlen(buf)) != strlen(buf)) error("write"); close(f); sprint(buf, "#s/%s", srv); f = create("#s/boot", 1, 0666); if(f < 0) error("create"); sprint(buf, "%d", fd); if(write(f, buf, strlen(buf)) != strlen(buf)) error("write"); close(f); print("mount..."); if(bind("/", "/", MREPL) < 0) error("bind"); if(mount(fd, "/", MAFTER|MCREATE, "") < 0) error("mount"); print("success\n"); execl("/mips/init", "init", 0); error("/mips/init"); } void error(char *s) { char buf[64]; errstr(0, buf); fprint(2, "boot: %s: %s\n", s, buf); exits(0); } . ## diffname power/boot.c 1990/0324 ## diff -e /n/bootesdump/1990/0227/sys/src/9/mips/boot.c /n/bootesdump/1990/0324/sys/src/9/mips/boot.c 103c error("opening #3/bit3"); . 101c fd = open("#3/bit3", ORDWR); . 24d 18a { "bitbootes", "bitconnect" }, . ## diffname power/boot.c 1990/0427 ## diff -e /n/bootesdump/1990/0324/sys/src/9/mips/boot.c /n/bootesdump/1990/0427/sys/src/9/mips/boot.c 201a } /* * lookup the address for a system */ char * lookup(char *arg) { Address *a; if(strcmp(arg, "?")==0 || strcmp(arg, "help")==0){ for(a = addr; a->name; a++) print("%s\n", a->name); return 0; } for(a = addr; a->name; a++){ if(strcmp(a->name, arg) == 0) return a->cmd; } return 0; } /* * prompt and get input */ int outin(char *prompt, char *def, char *buf, int len) { int n; do{ print("%s[%s]: ", prompt, def); n = read(0, buf, len); }while(n==0); if(n < 0) error("can't read #c/cons; please reboot"); if(n == 1) strcpy(buf, def); else buf[n-1] = 0; return n; . 194a prerror(char *s) { char buf[64]; errstr(0, buf); fprint(2, "boot: %s: %s\n", s, buf); } /* * print error and exit */ void . 193a /* * print error */ . 183c . 175d 167c sprint(buf, "#s/%s", sys); . 163c prerror("remote error"); return; . 155,160c if(n <= 0){ prerror("read session"); return; } if(convM2S(buf, &hdr, n) == 0){ prerror("format session"); return; } if(hdr.type != Rsession){ prerror("not Rsession"); return; } . 152,153c if(write(fd, buf, n) != n){ prerror("write session"); return; } . 145,146c if(hdr.type != Rnop){ prerror("not Rnop"); return; } . 143c prerror("format nop"); return; . 138,139c if(n <= 0){ prerror("read nop"); return; } . 135,136c if(write(fd, buf, n) != n){ print("n = %d\n", n); prerror("write nop"); return; } . 126,129c if(cfd < 0){ prerror("opening #n/1/ctl"); return; } if(write(cfd, scmd, strlen(scmd))<0){ prerror(scmd); return; } . 123,124c if(fd < 0) { prerror("opening #n/1/data"); return; } . 111,117c efd = open("#l/1/ctl", 2); if(efd < 0){ prerror("opening #l/1/ctl"); return; } if(write(efd, "connect 0x900", sizeof("connect 0x900")-1)<0){ prerror("connect 0x900"); return; } if(write(efd, "push noether", sizeof("push noether")-1)<0){ prerror("push noether"); return; } . 102,103c if(fd < 0){ prerror("opening #3/bit3"); return; } . 78,99d 75,76c * for the bit, we skip all the ether goo . 57,72c print("Connecting to server %s\n", sys); . 53,55c if(!ask) scmd = lookup(sys); else { outin("server", sys, sbuf, sizeof(sbuf)); sys = sbuf; scmd = lookup(sys); } if(scmd == 0){ fprint(2, "boot: %s unknown\n", sys); return; } . 49,51c int n, f; . 47c void boot(int ask) . 44c boot(manual); for(;;){ if(fd > 0) close(fd); if(cfd > 0) close(cfd); if(efd > 0) close(efd); fd = cfd = efd = 0; boot(1); } . 40,42c sys = DEFSYS; bootfile = DEFFILE; switch(argc){ case 1: bootfile = argv[0]; break; case 2: bootfile = argv[0]; sys = argv[1]; break; . 35,38c open("#c/cons", 0); open("#c/cons", 1); open("#c/cons", 1); print("boot.c staring\n"); argv++; argc--; while(argc > 0){ if(argv[0][0] == '-'){ if(argv[0][1] == 'm') manual = 1; argc--; argv++; } else break; . 33c int i; int manual=0; . 30,31c /* * usage: 9b [-a] [server] [file] * * default server is `bitbootes', default file is `/sys/src/9/mips/9' */ main(int argc, char *argv[]) . 28c /* * predeclared */ char *lookup(char *); int outin(char *, char *, char *, int); void prerror(char *); void error(char *); void boot(int); . 11a int fd; int cfd; int efd; . 10c char sbuf[2*NAMELEN]; char buf[4*1024]; . 7,8c char *sys; char *scmd; char *bootfile; . 5a #define DEFSYS "bitbootes" #define DEFFILE "/mips/9" . ## diffname power/boot.c 1990/0430 ## diff -e /n/bootesdump/1990/0427/sys/src/9/mips/boot.c /n/bootesdump/1990/0430/sys/src/9/mips/boot.c 61d ## diffname power/boot.c 1990/0504 ## diff -e /n/bootesdump/1990/0430/sys/src/9/mips/boot.c /n/bootesdump/1990/0504/sys/src/9/mips/boot.c 242c close(fd); if(ask) execl("/mips/init", "init", 0); else execl("/mips/init", "init", "-m", 0); . 117,118d 60a i = create("#e/sysname", 1, 0666); if(i < 0) error("sysname"); if(write(i, argv[0], strlen(argv[0])) <= 0) error("sysname"); close(i); . 50c * default server is `bitbootes', default file is `/mips/9' . 21d ## diffname power/boot.c 1990/06111 ## diff -e /n/bootesdump/1990/0504/sys/src/9/mips/boot.c /n/bootesdump/1990/06111/sys/src/9/mips/boot.c 250a else execl("/mips/init", "init", 0); . 248,249d ## diffname power/boot.c 1990/0704 ## diff -e /n/bootesdump/1990/06111/sys/src/9/mips/boot.c /n/bootesdump/1990/0704/sys/src/9/mips/boot.c 162c prerror("opening #n/2/ctl"); . 160c cfd = open("#n/2/ctl", 2); . 157c prerror("opening #n/2/data"); . 155c fd = open("#n/2/data", 2); . ## diffname power/boot.c 1990/0721 ## diff -e /n/bootesdump/1990/0704/sys/src/9/mips/boot.c /n/bootesdump/1990/0721/sys/src/9/mips/boot.c 294c return a; . 282c Address * . 223c sprint(buf, "#s/%s", a->srvname); . 160c cfd = open("#nnonet/2/ctl", 2); . 155c fd = open("#nnonet/2/data", 2); . 150a if(write(efd, "config nonet", sizeof("config nonet")-1)<0){ prerror("config nonet"); return; } . 120a scmd = a->cmd; . 117c a = lookup(sys); if(a == 0){ . 115d 110,112c if(ask){ . 108a Address *a; . 40c Address* lookup(char *); . 28,33c { "bitbootes", "bitconnect", "bit!bootes" }, { "ross", "connect 020701005eff", "nonet!ross" }, { "bootes", "connect 080069020205", "nonet!bootes" }, { "helix", "connect 080069020427", "nonet!helix" }, { "spindle", "connect 0800690202df", "nonet!spindle" }, { "r70", "connect 08002b04265d", "nonet!r70" }, . 24a char *srvname; . ## diffname power/boot.c 1990/0722 ## diff -e /n/bootesdump/1990/0721/sys/src/9/mips/boot.c /n/bootesdump/1990/0722/sys/src/9/mips/boot.c 167c prerror("opening #nnonet/2/ctl"); . 162c prerror("opening #nnonet/2/data"); . ## diffname power/boot.c 1990/11211 ## diff -e /n/bootesdump/1990/0722/sys/src/9/mips/boot.c /n/bootesdump/1990/11211/sys/src/9/mips/boot.c 279c errstr(buf); . 267c errstr(buf); . 255,256c execl("/mips/Ninit", "Ninit", 0); error("/mips/Ninit"); . 253c execl("/mips/Ninit", "Ninit", "-m", 0); . 247c if(mount(fd, "/", MAFTER|MCREATE, "", "") < 0) . 225a if(hdr.type != Rsession){ prerror("not Rsession"); return; } . 221,223c if(hdr.type == Rerror){ fprint(2, "boot: error %s\n", hdr.ename); . 217,218c if(hdr.tag != ~0){ prerror("tag not ~0"); . 202c hdr.tag = ~0; . 198a if(hdr.tag != ~0){ prerror("tag not ~0"); return; } . 177a hdr.tag = ~0; . 3d ## diffname power/boot.c 1990/1122 ## diff -e /n/bootesdump/1990/11211/sys/src/9/mips/boot.c /n/bootesdump/1990/1122/sys/src/9/mips/boot.c 262,263c execl("/mips/init", "init", 0); error("/mips/init"); . 260c execl("/mips/init", "init", "-m", 0); . ## diffname power/boot.c 1990/1127 ## diff -e /n/bootesdump/1990/1122/sys/src/9/mips/boot.c /n/bootesdump/1990/1127/sys/src/9/mips/boot.c 289,308d 235c sprint(buf, "#s/%s", srvname); . 188a if(n == 2) goto reread; . 183a reread: . 174d 169,170c sprint(cmd, "connect %s", arg); if(write(cfd, cmd, strlen(cmd))<0){ close(cfd); close(fd); cfd = fd = -1; prerror(cmd); return -1; } return fd; } void boot(int ask) { int n, f, tries; char *srvname; if(ask){ outin("server", sys, sbuf, sizeof(sbuf)); sys = sbuf; } for(tries = 0; tries < 5; tries++){ fd = -1; if(strncmp(sys, "bit!", 4) == 0) fd = bitdial(srvname = &sys[4]); else if(strncmp(sys, "dk!", 3) == 0) fd = dkdial(srvname = &sys[3]); else if(strncmp(sys, "nonet!", 5) == 0) fd = nonetdial(srvname = &sys[5]); else fd = nonetdial(srvname = sys); if(fd >= 0) break; print("can't connect, retrying...\n"); sleep(1000); } if(fd < 0){ print("can't connect\n"); . 166,167c close(fd); fd = -1; prerror("opening #kdk/5/ctl"); return -1; . 164c cfd = open("#kdk/5/ctl", 2); . 161,162c prerror("opening #kdk/5/data"); return -1; . 159c fd = open("#kdk/5/data", 2); . 157c * grab a datakit channel and call up the file server . 151,153c return fd; } int dkdial(char *arg) { int fd; char cmd[64]; static int mounted; if(!mounted){ /* * grab the hsvme and configure it for a datakit */ efd = open("#h/ctl", 2); if(efd < 0){ prerror("opening #h/ctl"); return -1; } if(write(efd, "push dkmux", sizeof("push dkmux")-1)<0){ close(efd); prerror("push dkmux"); return -1; } if(write(efd, "config 4 256 restart dk", sizeof("config 4 256 restart dk")-1)<0){ close(efd); prerror("config 4 256 restart dk"); return -1; } mounted = 1; sleep(2000); /* wait for things to settle down */ . 147,149c if(write(cfd, a->cmd, strlen(a->cmd))<0){ close(cfd); close(fd); fd = cfd = -1; prerror(a->cmd); return -1; . 143,145c cfd = open("#nnonet/2/ctl", 2); if(cfd < 0){ close(fd); fd = -1; prerror("opening #nnonet/2/ctl"); return -1; . 138,141c fd = open("#nnonet/2/data", 2); if(fd < 0) { prerror("opening #nnonet/2/data"); return -1; . 135,136c * grab a nonet channel and call up the file server . 131c if(write(efd, "connect 0x900", sizeof("connect 0x900")-1)<0){ close(efd); prerror("connect 0x900"); return -1; } if(write(efd, "push noether", sizeof("push noether")-1)<0){ close(efd); prerror("push noether"); return -1; } if(write(efd, "config nonet", sizeof("config nonet")-1)<0){ close(efd); prerror("config nonet"); return -1; } mounted = 1; . 122,129c if(!mounted){ /* * grab a lance channel, make it recognize ether type 0x900, * and push the nonet ethernet multiplexor onto it. */ efd = open("#l/1/ctl", 2); if(efd < 0){ prerror("opening #l/1/ctl"); return -1; . 120d 115,118c if(a->name == 0){ print("can't convert nonet address to ether address\n"); return -1; . 111,113c for(a = addr; a->name; a++){ if(strcmp(a->name, arg) == 0) break; . 109a static int mounted; . 108c return open("#3/bit3", ORDWR); } int nonetdial(char *arg) { int efd, cfd, fd; . 105,106c int bitdial(char *arg) . 98,100c fd = cfd = 0; . 44a int dkdial(char *); int nonetdial(char *); int bitdial(char *); . 40d 28,33c { "ross", "connect 020701005eff" }, { "bootes", "connect 080069020205" }, { "helix", "connect 080069020427" }, { "spindle", "connect 0800690202df" }, { "r70", "connect 08002b04265d" }, . 24d 5c #define DEFSYS "bit!bootes" . ## diffname power/boot.c 1990/1202 ## diff -e /n/bootesdump/1990/1127/sys/src/9/mips/boot.c /n/bootesdump/1990/1202/sys/src/9/mips/boot.c 401a strcpy(def, buf); } . 398,400c if(n != 1){ . 390a char buf[256]; . 388c int outin(char *prompt, char *def, int len) . 251,252c else if(strncmp(sys, "nonet!", 6) == 0) fd = nonetdial(srvname = &sys[6]); . 241,242c outin("server", sys, sizeof(sys)); . 87,88c strcpy(bootfile, argv[0]); strcpy(sys, argv[1]); . 84c strcpy(bootfile, argv[0]); . 80,81c strcpy(sys, DEFSYS); strcpy(bootfile, DEFFILE); . 63c if(write(i, argv[0], strlen(argv[0])) != strlen(argv[0])) . 38c int outin(char *, char *, int); . 14a char bootfile[5*NAMELEN]; char sys[NAMELEN]; . 13d 11d 9d ## diffname power/boot.c 1991/0108 ## diff -e /n/bootesdump/1990/1202/sys/src/9/mips/boot.c /n/bootesdump/1991/0108/sys/src/9/mips/boot.c 348a if(net){ char buf[128]; fd = create("#e/bootnet", 1, 0666); if(fd >= 0){ if(write(fd, net, strlen(net)) != strlen(net)) error("writing bootnet"); close(fd); sprint(buf, "/net/%s", net); if(bind(netdev, buf, MREPL) < 0) error("binding bootnet"); } } . 229a net = "dk"; netdev = "#kdk"; . 173a net = "nonet"; netdev = "#nnonet"; . 7a char *net; char *netdev; . ## diffname power/boot.c 1991/01151 ## diff -e /n/bootesdump/1991/0108/sys/src/9/mips/boot.c /n/bootesdump/1991/01151/sys/src/9/mips/boot.c 355d 353a /* * set the time from the access time of the root of the file server, * accessible as /.. */ print("time..."); if(stat("/..", dirbuf) < 0) error("stat"); convM2D(dirbuf, &dir); f = open("#c/time", OWRITE); sprint(dirbuf, "%ld", dir.atime); write(f, dirbuf, strlen(dirbuf)); close(f); . 244a Dir dir; char dirbuf[DIRLEN]; . ## diffname power/boot.c 1991/0131 ## diff -e /n/bootesdump/1991/01151/sys/src/9/mips/boot.c /n/bootesdump/1991/0131/sys/src/9/mips/boot.c 373,383c char buf[64]; sprint(buf, "/lib/netaddr.%s", net); print("binding %s onto /lib/netaddr.net\n", buf); bind(buf, "/lib/netaddr.net", MREPL); . 371a if(netdev){ char buf[64]; sprint(buf, "/net/%s", net); bind(netdev, buf, MREPL); bind(netdev, "/net/net", MREPL); } . ## diffname power/boot.c 1991/0304 ## diff -e /n/bootesdump/1991/0201/sys/src/9/mips/boot.c /n/bootesdump/1991/0304/sys/src/9/power/boot.c 332a if(!preamble(fd)) return; . 330a return 0; } return 1; } void boot(int ask) { int n, f, tries; char *srvname; Dir dir; char dirbuf[DIRLEN]; if(ask){ outin("server", sys, sizeof(sys)); } for(tries = 0; tries < 5; tries++){ fd = -1; if(strncmp(sys, "bit!", 4) == 0) fd = bitdial(srvname = &sys[4]); if(strncmp(sys, "hot!", 4) == 0) fd = hotdial(srvname = &sys[4]); else if(strncmp(sys, "dk!", 3) == 0) fd = dkdial(srvname = &sys[3]); else if(strncmp(sys, "nonet!", 6) == 0) fd = nonetdial(srvname = &sys[6]); else fd = nonetdial(srvname = sys); if(fd >= 0) break; print("can't connect, retrying...\n"); sleep(1000); } if(fd < 0){ print("can't connect\n"); . 327c return 0; . 323c return 0; . 319c return 0; . 315c return 0; . 310c return 0; . 301c return 0; . 297c return 0; . 293c return 0; . 285c return 0; . 279c return 0; . 271a int preamble(int fd) { int n; . 267,270c /* * parent: wait, then sleep a while */ wait(&m); if(m.msg[0]) error(m.msg); fprint(2, "sleep 3 seconds\n"); sleep(3*1000); fprint(2, "go for it....\n"); return open("#H/hotrod", ORDWR); } . 251,265c /* * use /dev; it's local */ if(mount(fd, "/dev", MREPL, "", "") < 0) error("mount"); switch(fork()){ case 0: /* * child: get hotrodboot running */ execl("/dev/mips/bin/hotrodboot", "hotrodboot", "/dev/hobbit/hot", 0); error("execl hotrodboot"); case -1: error("fork"); . 248,249c /* * The killer: gotta get a hotrodboot running, so dial up * on datakit and load it. */ fd = dkdial(arg); if(fd < 0) return -1; if(!preamble(fd)){ close(fd); return -1; . 243,246c int fd; char srvdir[100]; Waitmsg m; . 240,241c int hotdial(char *arg) . 46a int preamble(int); . ## diffname power/boot.c 1991/0315 ## diff -e /n/bootesdump/1991/0304/sys/src/9/power/boot.c /n/bootesdump/1991/0315/sys/src/9/power/boot.c 373c else if(strncmp(sys, "hot!", 4) == 0) . ## diffname power/boot.c 1991/0327 ## diff -e /n/bootesdump/1991/0315/sys/src/9/power/boot.c /n/bootesdump/1991/0327/sys/src/9/power/boot.c 30c { "bootes", "connect 0800690203f3" }, . ## diffname power/boot.c 1991/0418 ## diff -e /n/bootesdump/1991/0327/sys/src/9/power/boot.c /n/bootesdump/1991/0418/sys/src/9/power/boot.c 447,448c } else { switch(fork()){ case -1: print("can't start connection server\n"); break; case 0: execl("/mips/init", "init", "-d", "/bin/cs", 0); error("/mips/bin/cs"); break; default: execl("/mips/init", "init", 0); } } . 445c if(ask){ . ## diffname power/boot.c 1991/0430 ## diff -e /n/bootesdump/1991/0418/sys/src/9/power/boot.c /n/bootesdump/1991/0430/sys/src/9/power/boot.c 68a i = create("#e/terminal", 1, 0666); if(i < 0) error("terminal"); if(write(i, "sgi power 4D", strlen("sgi power 4D")) < 0) error("terminal"); close(i); . ## diffname power/boot.c 1991/0507 ## diff -e /n/bootesdump/1991/0430/sys/src/9/power/boot.c /n/bootesdump/1991/0507/sys/src/9/power/boot.c 454,464c execl("/mips/init", "init", 0); . ## diffname power/boot.c 1991/0509 ## diff -e /n/bootesdump/1991/0507/sys/src/9/power/boot.c /n/bootesdump/1991/0509/sys/src/9/power/boot.c 33a { "fornax", "connect 00007701d2ba" }, . ## diffname power/boot.c 1991/0719 ## diff -e /n/bootesdump/1991/0509/sys/src/9/power/boot.c /n/bootesdump/1991/0719/sys/src/9/power/boot.c 374d 372c if(ask) . ## diffname power/boot.c 1991/0806 ## diff -e /n/bootesdump/1991/0719/sys/src/9/power/boot.c /n/bootesdump/1991/0806/sys/src/9/power/boot.c 488d ## diffname power/boot.c 1991/0820 ## diff -e /n/bootesdump/1991/0806/sys/src/9/power/boot.c /n/bootesdump/1991/0820/sys/src/9/power/boot.c 349,350c if(hdr.tag != NOTAG){ prerror("tag not NOTAG"); . 334c hdr.tag = NOTAG; . 327,328c if(hdr.tag != NOTAG){ prerror("tag not NOTAG"); . 302c hdr.tag = NOTAG; . ## diffname power/boot.c 1991/1011 ## diff -e /n/bootesdump/1991/0820/sys/src/9/power/boot.c /n/bootesdump/1991/1011/sys/src/9/power/boot.c 503a } void srvcreate(char *name, int fd) { char *srvname; int f; srvname = strrchr(name, '/'); if(srvname) srvname++; else srvname = name; sprint(buf, "#s/%s", srvname); f = create(buf, 1, 0666); if(f < 0) error("create"); sprint(buf, "%d", fd); if(write(f, buf, strlen(buf)) != strlen(buf)) error("write"); close(f); } void settime(void) { char dirbuf[DIRLEN]; Dir dir; int f; print("time..."); /* * set the time from the access time of the root * of the file server */ f = open("#s/boot", ORDWR); if(f < 0) return; if(mount(f, "/n/boot", MREPL, "", "") < 0){ close(f); return; } close(f); if(stat("/n/boot", dirbuf) < 0) error("stat"); convM2D(dirbuf, &dir); sprint(dirbuf, "%ld", dir.atime); unmount(0, "/n/boot"); f = open("#c/time", OWRITE); write(f, dirbuf, strlen(dirbuf)); close(f); . 423,434c settime(); . 400,415c srvcreate("boot", fd); srvcreate("bootes", fd); . 369,370d 48a void srvcreate(char*, int); void settime(void); . ## diffname power/boot.c 1991/1101 ## diff -e /n/bootesdump/1991/1011/sys/src/9/power/boot.c /n/bootesdump/1991/1101/sys/src/9/power/boot.c 429c execl("/mips/init", "init", "-c", 0); . 427c execl("/mips/init", "init", "-mc", 0); . 295,296d 230c cfd = open("#kdk/5/ctl", ORDWR); . 225c fd = open("#kdk/5/data", ORDWR); . 203c efd = open("#h/ctl", ORDWR); . 173c cfd = open("#nnonet/2/ctl", ORDWR); . 168c fd = open("#nnonet/2/data", ORDWR); . 142c efd = open("#l/1/ctl", ORDWR); . 66,78d 62,64c open("#c/cons", OREAD); open("#c/cons", OWRITE); open("#c/cons", OWRITE); . ## diffname power/boot.c 1991/1108 ## diff -e /n/bootesdump/1991/1101/sys/src/9/power/boot.c /n/bootesdump/1991/1108/sys/src/9/power/boot.c 401,402c if(strcmp(netdev, "#k")==0) bind(netdev, "/net", MBEFORE); else bind(netdev, buf, MREPL); bind(buf, "/net/net", MREPL); . 233c netdev = "#k"; . 221c prerror("opening #k/dk/5/ctl"); . 217c cfd = open("#k/dk/5/ctl", ORDWR); . 214c prerror("opening #k/dk/5/data"); . 212c fd = open("#k/dk/5/data", ORDWR); . ## diffname power/boot.c 1991/1114 ## diff -e /n/bootesdump/1991/1108/sys/src/9/power/boot.c /n/bootesdump/1991/1114/sys/src/9/power/boot.c 506c if(mount(f, "/n/boot", MREPL, "", "", -1) < 0){ . 391c if(mount(fd, "/", MAFTER|MCREATE, "", "", -1) < 0) . 258c if(mount(fd, "/dev", MREPL, "", "", -1) < 0) . 131c prerror("opening #l/ether/0/ctl"); . 129c efd = open("#l/ether/0/ctl", ORDWR); . ## diffname power/boot.c 1991/1127 ## diff -e /n/bootesdump/1991/1114/sys/src/9/power/boot.c /n/bootesdump/1991/1127/sys/src/9/power/boot.c 99a } void setpasswd(void) { char key[7]; int fd; fd = open("#r/nvram", OREAD); if(fd < 0){ prerror("can't open nvram"); return; } if(seek(fd, 1024+900, 0) < 0 || read(fd, key, 7) != 7){ close(fd); prerror("can't read key from nvram"); return; } close(fd); fd = open("#c/key", OWRITE); if(fd < 0){ prerror("can't open key"); return; } if(write(fd, key, 7) != 7) prerror("can't write key"); close(fd); . 90a setpasswd(); . 50a void setpasswd(void); . ## diffname power/boot.c 1991/1218 ## diff -e /n/bootesdump/1991/1127/sys/src/9/power/boot.c /n/bootesdump/1991/1218/sys/src/9/power/boot.c 400c fd = nonetdial(sys); . 398c fd = nonetdial(&sys[6]); . 396c fd = dkdial(&sys[3]); . 394c fd = hotdial(&sys[4]); . 392c fd = bitdial(&sys[4]); . 384d 257d 249d 199d 192d 133a USED(arg); . ## diffname power/boot.c 1992/0110 ## diff -e /n/bootesdump/1991/1218/sys/src/9/power/boot.c /n/bootesdump/1992/0110/sys/src/9/power/boot.c 543a } void key(void) { char password[20], key[7]; int prompt, fd; prompt = setkey; fd = open("#r/nvram", ORDWR); if(fd < 0){ prompt = 1; prerror("can't open nvram"); } if(prompt){ do if(passwd(password, sizeof password) < 0){ prerror("can't read cons"); return; } while(!passtokey(key, password, strlen(password))); }else if(seek(fd, 1024+900, 0) < 0 || read(fd, key, 7) != 7){ close(fd); prerror("can't read key from nvram"); } if(setkey && seek(fd, 1024+900, 0) < 0 || write(fd, key, 7) != 7){ close(fd); prerror("can't write key to nvram"); } close(fd); fd = open("#c/key", OWRITE); if(fd < 0) prerror("can't open key"); else if(write(fd, key, 7) != 7) prerror("can't write key"); close(fd); } int passwd(char *p, int len) { char c; int i, n, fd; fd = open("#c/consctl", OWRITE); if(fd < 0) return -1; write(fd, "rawon", 5); Prompt: print("password: "); n = 0; for(;;){ do{ i = read(0, &c, 1); if(i < 0){ close(fd); return -1; } }while(i == 0); switch(c){ case '\n': p[n] = '\0'; close(fd); print("\n"); return 0; case '\b': if(n > 0) n--; break; case 'u' - 'a' + 1: /* cntrl-u */ print("\n"); goto Prompt; default: if(n < len - 1) p[n++] = c; break; } } } int passtokey(char *key, char *p, int n) { uchar t[10]; int c; memset(t, ' ', sizeof t); if(n > 10 || n < 5) return 0; strncpy((char*)t, p, n); if(n >= 9){ c = p[8] & 0xf; if(n == 10) c += p[9] << 4; for(n = 0; n < 8; n++) if(c & (1 << n)) t[n] -= ' '; } for(n = 0; n < 7; n++) key[n] = (t[n] >> n) + (t[n+1] << (8 - (n+1))); return 1; . 104,130d 92c key(); . 73a else if(argv[0][1] == 'k') setkey = 1; . 57a void . 54c * usage: 9b [-mp] [server] [file] . 51c void key(void); int passwd(char*, int); int passtokey(char*, char*, int); . 29d 20a int setkey; . 17a int printcol; /* so we can use the kernel's small print */ . ## diffname power/boot.c 1992/0111 ## diff -e /n/bootesdump/1992/0110/sys/src/9/power/boot.c /n/bootesdump/1992/0111/sys/src/9/power/boot.c 612a if(n > 10) n = 10; . 611c if(n < 5) . ## diffname power/boot.c 1992/0121 ## diff -e /n/bootesdump/1992/0111/sys/src/9/power/boot.c /n/bootesdump/1992/0121/sys/src/9/power/boot.c 511c if(mount(f, "/n/boot", MREPL, "", "") < 0){ . 396c if(mount(fd, "/", MAFTER|MCREATE, "", "") < 0) . 264c if(mount(fd, "/dev", MREPL, "", "") < 0) . ## diffname power/boot.c 1992/0219 ## diff -e /n/bootesdump/1992/0121/sys/src/9/power/boot.c /n/bootesdump/1992/0219/sys/src/9/power/boot.c 402,417d 394,395d 373,376d 238,239d 119,187d 48d 25,39d 8,10d ## diffname power/boot.c 1992/0302 ## diff -e /n/bootesdump/1992/0219/sys/src/9/power/boot.c /n/bootesdump/1992/0302/sys/src/9/power/boot.c 159a return open("#H/hotrod", ORDWR); . ## diffname power/boot.c 1992/0306 ## diff -e /n/bootesdump/1992/0302/sys/src/9/power/boot.c /n/bootesdump/1992/0306/sys/src/9/power/boot.c 281c else if(strncmp(sys, "cyc!", 4) == 0) . 161,197d 156,159c USED(arg); . 5c #define DEFSYS "cyc!bootes" . ## diffname power/boot.c 1992/0318 ## diff -e /n/bootesdump/1992/0306/sys/src/9/power/boot.c /n/bootesdump/1992/0318/sys/src/9/power/boot.c 399c if(setkey && (seek(fd, 1024+900, 0) < 0 || write(fd, key, 7) != 7)){ . ## diffname power/boot.c 1992/0319 # deleted ## diff -e /n/bootesdump/1992/0318/sys/src/9/power/boot.c /n/bootesdump/1992/0319/sys/src/9/power/boot.c 1,477d