| plan 9 kernel history: overview | file list | diff list |
1991/0507/gnot/boot.c (diff list | history)
| 1990/03091/sys/src/9/gnot/boot.c:12,17 – 1990/0310/sys/src/9/gnot/boot.c:12,18 (short | long) | ||
| 1990/03091 | { int cfd, fd, n, fu, f; char buf[NAMELEN]; | |
| 1990/0310 | int p[2]; | |
| 1990/03091 | open("#c/cons", OREAD); open("#c/cons", OWRITE); | |
| 1990/03091/sys/src/9/gnot/boot.c:25,32 – 1990/0310/sys/src/9/gnot/boot.c:26,38 | ||
| 1990/03091 | error("can't read #c/cons; please reboot"); buf[n-1] = 0; print("hello %s!\n", buf); | |
| 1990/0310 | if(pipe(p) == -1) error("pipe"); if(write(p[1], "hohoHO!", 8) != 8) error("write"); if(read(p[0], buf, 8) != 8) error("read"); print("%s\n", buf); | |
| 1990/03091 | for(;;); } | |
| 1990/0310/sys/src/9/gnot/boot.c:6,12 – 1990/0312/sys/src/9/gnot/boot.c:6,13 (short | long) | ||
| 1990/03091 | Fcall hdr; char buf[100]; | |
| 1990/0312 | void error(char*); void sendmsg(int, char*); | |
| 1990/03091 | main(int argc, char *argv[]) { | |
| 1990/0310/sys/src/9/gnot/boot.c:18,39 – 1990/0312/sys/src/9/gnot/boot.c:19,141 | ||
| 1990/03091 | open("#c/cons", OWRITE); open("#c/cons", OWRITE); | |
| 1990/0312 | fd = open("#c/user", 0); if(fd < 0) error("#c/user"); n = read(fd, buf, sizeof buf-1); | |
| 1990/03091 | if(n < 0) | |
| 1990/0312 | error("can't read #c/user; please reboot"); buf[n] = 0; | |
| 1990/03091 | print("hello %s!\n", buf); | |
| 1990/0310 |
| |
| 1990/0312 | close(fd); /* * grab the incon, * push the dk multiplexor onto it, * and use line 1 as the signalling channel. */ cfd = open("#i/ctl", 2); if(cfd < 0) error("opening #i/ctl"); sendmsg(cfd, "push dkmux"); sendmsg(cfd, "config 1 16"); print("dkmux configured\n"); /* * open a datakit channel and call ken via r70, leave the * incon ctl channel open */ fd = open("#k/2/data", 2); if(fd < 0) error("opening #k/2/data"); cfd = open("#k/2/ctl", 2); if(cfd < 0) error("opening #k/2/ctl"); print("#k/2/ctl open\n"); sendmsg(cfd, "connect r70.nonet!bootes!fs"); print("connected to r70.nonet!bootes!fs\n"); close(cfd); /* for(;;){ print("ding\n"); sleep(10000); } /**/ /* * talk to the file server */ 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", "bootes"); f = create(buf, 1, 0666); if(f < 0) error("create"); sprint(buf, "%d", fd); if(write(f, buf, strlen(buf)) != strlen(buf)) | |
| 1990/0310 | error("write"); | |
| 1990/03091 |
| |
| 1990/0312 | close(f); sprint(buf, "#s/%s", "bootes"); 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("/68020/init", "init", 0); error("/68020/init"); } void sendmsg(int fd, char *msg) { int n; n = strlen(msg); if(write(fd, msg, n) != n) error(msg); | |
| 1990/03091 | } void | |
| 1990/0312/sys/src/9/gnot/boot.c:19,34 – 1990/0315/sys/src/9/gnot/boot.c:19,24 (short | long) | ||
| 1990/03091 | open("#c/cons", OWRITE); open("#c/cons", OWRITE); | |
| 1990/0312 |
| |
| 1990/03091 |
| |
| 1990/0312 |
| |
| 1990/03091 |
| |
| 1990/0312 |
| |
| 1990/0312/sys/src/9/gnot/boot.c:39,45 – 1990/0315/sys/src/9/gnot/boot.c:29,34 | ||
| 1990/0312 | error("opening #i/ctl"); sendmsg(cfd, "push dkmux"); sendmsg(cfd, "config 1 16"); | |
| 1990/0312/sys/src/9/gnot/boot.c:51,67 – 1990/0315/sys/src/9/gnot/boot.c:40,48 | ||
| 1990/0312 | cfd = open("#k/2/ctl", 2); if(cfd < 0) error("opening #k/2/ctl"); | |
| 1990/0315/sys/src/9/gnot/boot.c:40,47 – 1990/0322/sys/src/9/gnot/boot.c:40,47 (short | long) | ||
| 1990/0312 | cfd = open("#k/2/ctl", 2); if(cfd < 0) error("opening #k/2/ctl"); | |
| 1990/0322 | sendmsg(cfd, "connect helix.bootfs"); print("connected to helix.bootfs\n"); | |
| 1990/0312 | close(cfd); /* | |
| 1990/0322/sys/src/9/gnot/boot.c:31,36 – 1990/05312/sys/src/9/gnot/boot.c:31,51 (short | long) | ||
| 1990/0312 | sendmsg(cfd, "config 1 16"); /* | |
| 1990/05312 | * fork a process to hold the incon channel open */ switch(fork()){ case -1: break; case 0: for(;;) sleep(60*1000); exit(0); default: close(cfd); break; } /* | |
| 1990/0312 | * open a datakit channel and call ken via r70, leave the * incon ctl channel open */ | |
| 1990/05312/sys/src/9/gnot/boot.c:5,10 – 1990/0613/sys/src/9/gnot/boot.c:5,11 (short | long) | ||
| 1990/03091 | Fcall hdr; char buf[100]; | |
| 1990/0613 | char bootline[64]; | |
| 1990/03091 | ||
| 1990/0312 | void error(char*); void sendmsg(int, char*); | |
| 1990/05312/sys/src/9/gnot/boot.c:19,24 – 1990/0613/sys/src/9/gnot/boot.c:20,31 | ||
| 1990/03091 | open("#c/cons", OWRITE); open("#c/cons", OWRITE); | |
| 1990/0613 | fd = open("#e/bootline", OREAD); if(fd >= 0){ read(fd, bootline, sizeof bootline); close(fd); } | |
| 1990/0312 | /* * grab the incon, * push the dk multiplexor onto it, | |
| 1990/05312/sys/src/9/gnot/boot.c:120,126 – 1990/0613/sys/src/9/gnot/boot.c:127,136 | ||
| 1990/0312 | if(mount(fd, "/", MAFTER|MCREATE, "") < 0) error("mount"); print("success\n"); | |
| 1990/0613 | if(strchr(bootline, ' ')) execl("/68020/init", "init", "-m", 0); else execl("/68020/init", "init", 0); | |
| 1990/0312 | error("/68020/init"); } | |
| 1990/0613/sys/src/9/gnot/boot.c:35,41 – 1990/0707/sys/src/9/gnot/boot.c:35,41 (short | long) | ||
| 1990/0312 | if(cfd < 0) error("opening #i/ctl"); sendmsg(cfd, "push dkmux"); | |
| 1990/0707 | sendmsg(cfd, "config 1 16 norestart"); | |
| 1990/0312 | /* | |
| 1990/05312 | * fork a process to hold the incon channel open | |
| 1990/0707/sys/src/9/gnot/boot.c:6,11 – 1990/0917/sys/src/9/gnot/boot.c:6,12 (short | long) | ||
| 1990/03091 | Fcall hdr; char buf[100]; | |
| 1990/0613 | char bootline[64]; | |
| 1990/0917 | char bootdevice; | |
| 1990/03091 | ||
| 1990/0312 | void error(char*); void sendmsg(int, char*); | |
| 1990/0707/sys/src/9/gnot/boot.c:26,44 – 1990/0917/sys/src/9/gnot/boot.c:27,70 | ||
| 1990/0613 | close(fd); } | |
| 1990/0917 | fd = open("#e/bootdevice", OREAD); if(fd >= 0){ read(fd, &bootdevice, 1); close(fd); } switch(bootdevice){ case 'a': /* * grab the rs232 line, * make it 19200 baud, * push the async protocol onto it, */ cfd = open("#c/rs232ctl", 2); if(cfd < 0) error("opening #c/rs232ctl"); sendmsg(cfd, "B19200"); sendmsg(cfd, "push async"); break; default: /* * grab the incon, */ cfd = open("#i/ctl", 2); if(cfd < 0) error("opening #i/ctl"); break; } | |
| 1990/0312 | /* | |
| 1990/0917 | * push the dk multiplexor onto the communications link, | |
| 1990/0312 | * and use line 1 as the signalling channel. */ | |
| 1990/0707 | sendmsg(cfd, "config 1 16 norestart"); | |
| 1990/0312 | /* | |
| 1990/05312 |
| |
| 1990/0917 | * fork a process to hold the device channel open | |
| 1990/05312 | */ switch(fork()){ case -1: | |
| 1990/0707/sys/src/9/gnot/boot.c:53,59 – 1990/0917/sys/src/9/gnot/boot.c:79,85 | ||
| 1990/05312 | } /* | |
| 1990/0312 |
| |
| 1990/0917 | * open a datakit channel and call ken, leave the | |
| 1990/0312 | * incon ctl channel open */ fd = open("#k/2/data", 2); | |
| 1990/0707/sys/src/9/gnot/boot.c:62,68 – 1990/0917/sys/src/9/gnot/boot.c:88,94 | ||
| 1990/0312 | cfd = open("#k/2/ctl", 2); if(cfd < 0) error("opening #k/2/ctl"); | |
| 1990/0322 |
| |
| 1990/0917 | sendmsg(cfd, "connect nfs"); | |
| 1990/0322 | print("connected to helix.bootfs\n"); | |
| 1990/0312 | close(cfd); | |
| 1990/0917/sys/src/9/gnot/boot.c:7,12 – 1990/0918/sys/src/9/gnot/boot.c:7,13 (short | long) | ||
| 1990/03091 | char buf[100]; | |
| 1990/0613 | char bootline[64]; | |
| 1990/0917 | char bootdevice; | |
| 1990/0918 | char bootserver[64]; | |
| 1990/03091 | ||
| 1990/0312 | void error(char*); void sendmsg(int, char*); | |
| 1990/0917/sys/src/9/gnot/boot.c:14,20 – 1990/0918/sys/src/9/gnot/boot.c:15,21 | ||
| 1990/03091 | main(int argc, char *argv[]) { int cfd, fd, n, fu, f; | |
| 1990/0918 | char buf[256]; | |
| 1990/0310 | int p[2]; | |
| 1990/03091 | open("#c/cons", OREAD); | |
| 1990/0917/sys/src/9/gnot/boot.c:26,37 – 1990/0918/sys/src/9/gnot/boot.c:27,43 | ||
| 1990/0613 | read(fd, bootline, sizeof bootline); close(fd); } | |
| 1990/0917 | fd = open("#e/bootdevice", OREAD); if(fd >= 0){ read(fd, &bootdevice, 1); close(fd); } | |
| 1990/0918 | fd = open("#e/bootserver", OREAD); if(fd >= 0){ read(fd, bootserver, 64); close(fd); } else strcpy(bootserver, "nfs"); | |
| 1990/0917 | switch(bootdevice){ case 'a': | |
| 1990/0917/sys/src/9/gnot/boot.c:88,95 – 1990/0918/sys/src/9/gnot/boot.c:94,102 | ||
| 1990/0312 | cfd = open("#k/2/ctl", 2); if(cfd < 0) error("opening #k/2/ctl"); | |
| 1990/0917 |
| |
| 1990/0322 |
| |
| 1990/0918 | sprint(buf, "connect %s", bootserver); sendmsg(cfd, buf); print("connected to %s\n", bootserver); | |
| 1990/0312 | close(cfd); /* | |
| 1990/0917/sys/src/9/gnot/boot.c:101,106 – 1990/0918/sys/src/9/gnot/boot.c:108,115 | ||
| 1990/0312 | if(write(fd, buf, n) != n) error("write nop"); n = read(fd, buf, sizeof buf); | |
| 1990/0918 | if(n==2 && buf[0]=='O' && buf[1]=='K') n = read(fd, buf, sizeof buf); | |
| 1990/0312 | if(n <= 0) error("read nop"); if(convM2S(buf, &hdr, n) == 0) { | |
| 1990/0918/sys/src/9/gnot/boot.c:40,45 – 1990/0925/sys/src/9/gnot/boot.c:40,57 (short | long) | ||
| 1990/0918 | strcpy(bootserver, "nfs"); | |
| 1990/0917 | switch(bootdevice){ | |
| 1990/0925 | case 'A': /* * grab the rs232 line, * make it 9600 baud, * push the async protocol onto it, */ cfd = open("#c/rs232ctl", 2); if(cfd < 0) error("opening #c/rs232ctl"); sendmsg(cfd, "B9600"); sendmsg(cfd, "push async"); break; | |
| 1990/0917 | case 'a': /* * grab the rs232 line, | |
| 1990/0925/sys/src/9/gnot/boot.c:1,8 – 1990/11211/sys/src/9/gnot/boot.c:1,7 (short | long) | ||
| 1990/03091 | #include <u.h> #include <libc.h> | |
| 1990/11211 | #include <fcall.h> | |
| 1990/03091 |
| |
| 1990/0613 | char bootline[64]; | |
| 1990/0925/sys/src/9/gnot/boot.c:14,20 – 1990/11211/sys/src/9/gnot/boot.c:13,19 | ||
| 1990/03091 | main(int argc, char *argv[]) { | |
| 1990/11211 | int cfd, fd, n, fu, f, i; | |
| 1990/0918 | char buf[256]; | |
| 1990/0310 | int p[2]; | |
| 1990/03091 | ||
| 1990/0925/sys/src/9/gnot/boot.c:100,113 – 1990/11211/sys/src/9/gnot/boot.c:99,121 | ||
| 1990/0917 | * open a datakit channel and call ken, leave the | |
| 1990/0312 | * incon ctl channel open */ | |
| 1990/0918 |
| |
| 1990/11211 | for(i = 0; ; i++){ fd = open("#k/2/data", 2); if(fd < 0) error("opening #k/2/data"); cfd = open("#k/2/ctl", 2); if(cfd < 0) error("opening #k/2/ctl"); sprint(buf, "connect %s", bootserver); n = strlen(buf); if(write(cfd, buf, n) == n) break; if(i == 5) error("dialing"); print("error dialing, retrying ...\n"); close(fd); close(cfd); } | |
| 1990/0918 | print("connected to %s\n", bootserver); | |
| 1990/0312 | close(cfd); | |
| 1990/0925/sys/src/9/gnot/boot.c:116,121 – 1990/11211/sys/src/9/gnot/boot.c:124,130 | ||
| 1990/0312 | */ print("nop..."); hdr.type = Tnop; | |
| 1990/11211 | hdr.tag = ~0; | |
| 1990/0312 | n = convS2M(&hdr, buf); if(write(fd, buf, n) != n) error("write nop"); | |
| 1990/0925/sys/src/9/gnot/boot.c:134,140 – 1990/11211/sys/src/9/gnot/boot.c:143,149 | ||
| 1990/0312 | print("session..."); hdr.type = Tsession; | |
| 1990/11211 | hdr.tag = ~0; | |
| 1990/0312 | n = convS2M(&hdr, buf); if(write(fd, buf, n) != n) error("write session"); | |
| 1990/0925/sys/src/9/gnot/boot.c:143,154 – 1990/11211/sys/src/9/gnot/boot.c:152,163 | ||
| 1990/0312 | error("read session"); if(convM2S(buf, &hdr, n) == 0) error("format session"); | |
| 1990/11211 | if(hdr.type == Rerror){ print("error %s;", hdr.ename); error(hdr.ename); } | |
| 1990/0312 | if(hdr.type != Rsession) error("not Rsession"); | |
| 1990/0925/sys/src/9/gnot/boot.c:171,183 – 1990/11211/sys/src/9/gnot/boot.c:180,192 | ||
| 1990/0312 | print("mount..."); if(bind("/", "/", MREPL) < 0) error("bind"); | |
| 1990/11211 | if(mount(fd, "/", MAFTER|MCREATE, "", "") < 0) | |
| 1990/0312 | error("mount"); print("success\n"); | |
| 1990/0613 | if(strchr(bootline, ' ')) | |
| 1990/11211 | execl("/68020/Ninit", "Ninit", "-m", 0); | |
| 1990/0613 | else | |
| 1990/11211 | execl("/68020/Ninit", "Ninit", 0); | |
| 1990/0312 | error("/68020/init"); } | |
| 1990/0925/sys/src/9/gnot/boot.c:196,202 – 1990/11211/sys/src/9/gnot/boot.c:205,211 | ||
| 1990/03091 | { char buf[64]; | |
| 1990/11211 | errstr(buf); | |
| 1990/03091 | fprint(2, "boot: %s: %s\n", s, buf); exits(0); } | |
| 1990/11211/sys/src/9/gnot/boot.c:184,192 – 1990/1122/sys/src/9/gnot/boot.c:184,192 (short | long) | ||
| 1990/0312 | error("mount"); print("success\n"); | |
| 1990/0613 | if(strchr(bootline, ' ')) | |
| 1990/11211 |
| |
| 1990/1122 | execl("/68020/init", "init", "-m", 0); | |
| 1990/0613 | else | |
| 1990/11211 |
| |
| 1990/1122 | execl("/68020/init", "init", 0); | |
| 1990/0312 | error("/68020/init"); } | |
| 1990/1122/sys/src/9/gnot/boot.c:183,188 – 1991/0108/sys/src/9/gnot/boot.c:183,198 (short | long) | ||
| 1990/11211 | if(mount(fd, "/", MAFTER|MCREATE, "", "") < 0) | |
| 1990/0312 | error("mount"); print("success\n"); | |
| 1991/0108 | f = create("#e/bootnet", 1, 0666); if(f >= 0){ if(write(f, "dk", 2) != 2) error("writing bootnet"); close(f); if(bind("#kdk", "/net/dk", MREPL) < 0) error("binding bootnet"); } | |
| 1990/0613 | if(strchr(bootline, ' ')) | |
| 1990/1122 | execl("/68020/init", "init", "-m", 0); | |
| 1990/0613 | else | |
| 1991/0108/sys/src/9/gnot/boot.c:52,57 – 1991/0115/sys/src/9/gnot/boot.c:52,58 (short | long) | ||
| 1990/0925 | sendmsg(cfd, "push async"); break; | |
| 1990/0917 | case 'a': | |
| 1991/0115 | case 's': | |
| 1990/0917 | /* * grab the rs232 line, * make it 19200 baud, | |
| 1991/0115/sys/src/9/gnot/boot.c:16,21 – 1991/01151/sys/src/9/gnot/boot.c:16,22 (short | long) | ||
| 1990/11211 | int cfd, fd, n, fu, f, i; | |
| 1990/0918 | char buf[256]; | |
| 1990/0310 | int p[2]; | |
| 1991/01151 | Dir dir; | |
| 1990/03091 | open("#c/cons", OREAD); open("#c/cons", OWRITE); | |
| 1991/0115/sys/src/9/gnot/boot.c:183,188 – 1991/01151/sys/src/9/gnot/boot.c:184,203 | ||
| 1990/0312 | error("bind"); | |
| 1990/11211 | if(mount(fd, "/", MAFTER|MCREATE, "", "") < 0) | |
| 1990/0312 | error("mount"); | |
| 1991/01151 | /* * set the time from the access time of the root of the file server, * accessible as /.. */ print("time..."); if(stat("/..", buf) < 0) error("stat"); convM2D(buf, &dir); f = open("#c/time", OWRITE); sprint(buf, "%ld", dir.atime); write(f, buf, strlen(buf)); close(f); | |
| 1990/0312 | print("success\n"); | |
| 1991/0108 | f = create("#e/bootnet", 1, 0666); | |
| 1991/01151/sys/src/9/gnot/boot.c:200,213 – 1991/0131/sys/src/9/gnot/boot.c:200,207 (short | long) | ||
| 1991/01151 | ||
| 1990/0312 | print("success\n"); | |
| 1991/0108 |
| |
| 1991/0131 | bind("#k", "/net/net", MREPL); bind("#k", "/net/dk", MREPL); | |
| 1991/0108 | ||
| 1990/0613 | if(strchr(bootline, ' ')) | |
| 1990/1122 | execl("/68020/init", "init", "-m", 0); | |
| 1991/0131/sys/src/9/gnot/boot.c:10,21 – 1991/0214/sys/src/9/gnot/boot.c:10,26 (short | long) | ||
| 1990/03091 | ||
| 1990/0312 | void error(char*); void sendmsg(int, char*); | |
| 1991/0214 | void bootparams(void); void dkconfig(void); int dkdial(void); void nop(int); void session(int); int cache(int); | |
| 1990/03091 | main(int argc, char *argv[]) { | |
| 1990/11211 |
| |
| 1991/0214 | int fd, f; | |
| 1990/0918 | char buf[256]; | |
| 1990/0310 |
| |
| 1991/01151 | Dir dir; | |
| 1990/03091 | open("#c/cons", OREAD); | |
| 1991/0131/sys/src/9/gnot/boot.c:22,44 – 1991/0214/sys/src/9/gnot/boot.c:27,102 | ||
| 1990/03091 | open("#c/cons", OWRITE); open("#c/cons", OWRITE); | |
| 1990/0613 |
| |
| 1990/0917 |
| |
| 1990/0918 |
| |
| 1991/0214 | bootparams(); dkconfig(); fd = dkdial(); nop(fd); session(fd); fd = cache(fd); | |
| 1990/0917 | ||
| 1991/0214 | /* * make a /srv/boot and a /srv/bootes */ print("post..."); sprint(buf, "#s/%s", "bootes"); 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", "bootes"); 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); /* * mount file server root after #/ root */ if(bind("/", "/", MREPL) < 0) error("bind"); print("mount..."); if(mount(fd, "/", MAFTER|MCREATE, "", "") < 0) error("mount"); /* * set the time from the access time of the root of the file server, * accessible as /.. */ print("time..."); if(stat("/..", buf) < 0) error("stat"); convM2D(buf, &dir); f = open("#c/time", OWRITE); sprint(buf, "%ld", dir.atime); write(f, buf, strlen(buf)); close(f); print("success\n"); bind("#k", "/net/net", MREPL); bind("#k", "/net/dk", MREPL); if(strchr(bootline, ' ')) execl("/68020/init", "init", "-m", 0); else execl("/68020/init", "init", 0); error("/68020/init"); } /* * open the network device, push on the needed multiplexors */ void dkconfig(void) { int cfd; | |
| 1990/0917 | switch(bootdevice){ | |
| 1990/0925 | case 'A': /* | |
| 1991/0131/sys/src/9/gnot/boot.c:84,89 – 1991/0214/sys/src/9/gnot/boot.c:142,148 | ||
| 1990/0312 | /* | |
| 1990/0917 | * fork a process to hold the device channel open | |
| 1991/0214 | * forever | |
| 1990/05312 | */ switch(fork()){ case -1: | |
| 1991/0131/sys/src/9/gnot/boot.c:96,106 – 1991/0214/sys/src/9/gnot/boot.c:155,173 | ||
| 1990/05312 | close(cfd); break; } | |
| 1991/0214 | } | |
| 1990/05312 |
| |
| 1990/0917 |
| |
| 1990/0312 |
| |
| 1991/0214 | /* * open a datakit channel and call ken, return an fd to the * connection. */ int dkdial(void) { int fd, cfd; int i; long n; | |
| 1990/11211 | for(i = 0; ; i++){ fd = open("#k/2/data", 2); if(fd < 0) | |
| 1991/0131/sys/src/9/gnot/boot.c:114,129 – 1991/0214/sys/src/9/gnot/boot.c:181,230 | ||
| 1990/11211 | break; if(i == 5) error("dialing"); | |
| 1991/0214 | print("error dialing %s, retrying ...\n", bootserver); | |
| 1990/11211 | close(fd); close(cfd); } | |
| 1990/0918 | print("connected to %s\n", bootserver); | |
| 1990/0312 | close(cfd); | |
| 1991/0214 | return fd; } | |
| 1990/0312 |
| |
| 1991/0214 | /* * read arguments passed by kernel as * environment variables - YECH! */ void bootparams(void) { int f; f = open("#e/bootline", OREAD); if(f >= 0){ read(f, bootline, sizeof bootline); close(f); } f = open("#e/bootdevice", OREAD); if(f >= 0){ read(f, &bootdevice, 1); close(f); } f = open("#e/bootserver", OREAD); if(f >= 0){ read(f, bootserver, 64); close(f); } else strcpy(bootserver, "nfs"); } /* * send nop to file server */ void nop(int fd) { long n; | |
| 1990/0312 | print("nop..."); hdr.type = Tnop; | |
| 1990/11211 | hdr.tag = ~0; | |
| 1991/0131/sys/src/9/gnot/boot.c:142,148 – 1991/0214/sys/src/9/gnot/boot.c:243,258 | ||
| 1990/0312 | } if(hdr.type != Rnop) error("not Rnop"); | |
| 1991/0214 | } | |
| 1990/0312 | ||
| 1991/0214 | /* * send nop to file server */ void session(int fd) { long n; | |
| 1990/0312 | print("session..."); hdr.type = Tsession; | |
| 1990/11211 | hdr.tag = ~0; | |
| 1991/0131/sys/src/9/gnot/boot.c:160,213 – 1991/0214/sys/src/9/gnot/boot.c:270,321 | ||
| 1990/11211 | } | |
| 1990/0312 | if(hdr.type != Rsession) error("not Rsession"); | |
| 1991/0214 | } | |
| 1990/0312 |
| |
| 1990/0310 |
| |
| 1990/0312 |
| |
| 1990/11211 |
| |
| 1990/0312 |
| |
| 1991/0214 | /* * see if we have a cache file system server in the kernel, * and use it if we do */ int cache(int fd) { int f; ulong i; int p[2]; | |
| 1991/01151 | /* | |
| 1991/0214 | * if there's no /cfs, just return the fd to the * file server | |
| 1991/01151 | */ | |
| 1990/0312 |
| |
| 1991/0214 | f = open("/cfs", OREAD); if(f < 0) return fd; print("cfs..."); | |
| 1991/0108 | ||
| 1991/0131 |
| |
| 1991/0108 | ||
| 1990/0613 |
| |
| 1990/1122 |
| |
| 1990/0613 |
| |
| 1990/1122 |
| |
| 1990/0312 |
| |
| 1991/0214 | /* * if we have a cfs, give it the file server as fd 0 * and requests on fd 1 */ if(pipe(p)<0) error("pipe"); switch(fork()){ case -1: error("fork"); case 0: close(p[1]); dup(fd, 0); close(fd); dup(p[0], 1); close(p[0]); execl("/cfs", "bootcfs", "-s", 0); break; default: close(p[0]); close(fd); fd = p[1]; break; } return fd; | |
| 1990/0312 | } void | |
| 1991/0214/sys/src/9/gnot/boot.c:7,12 – 1991/0314/sys/src/9/gnot/boot.c:7,14 (short | long) | ||
| 1990/0613 | char bootline[64]; | |
| 1990/0917 | char bootdevice; | |
| 1990/0918 | char bootserver[64]; | |
| 1991/0314 | int format; int manual; | |
| 1990/03091 | ||
| 1990/0312 | void error(char*); void sendmsg(int, char*); | |
| 1991/0214/sys/src/9/gnot/boot.c:82,88 – 1991/0314/sys/src/9/gnot/boot.c:84,90 | ||
| 1991/0214 | bind("#k", "/net/net", MREPL); bind("#k", "/net/dk", MREPL); | |
| 1991/0314 | if(manual) | |
| 1991/0214 | execl("/68020/init", "init", "-m", 0); else execl("/68020/init", "init", 0); | |
| 1991/0214/sys/src/9/gnot/boot.c:198,208 – 1991/0314/sys/src/9/gnot/boot.c:200,227 | ||
| 1991/0214 | bootparams(void) { int f; | |
| 1991/0314 | char *cp; | |
| 1991/0214 | ||
| 1991/0314 | format = 0; manual = 0; | |
| 1991/0214 | f = open("#e/bootline", OREAD); if(f >= 0){ | |
| 1991/0314 | read(f, bootline, sizeof(bootline)-1); | |
| 1991/0214 | close(f); | |
| 1991/0314 | cp = bootline; while(cp = strchr(cp, ' ')){ if(*++cp != '-') continue; while(*cp && *cp!=' ') switch(*cp++){ case 'f': format = 1; break; case 'm': manual = 1; break; } } | |
| 1991/0214 | } f = open("#e/bootdevice", OREAD); if(f >= 0){ | |
| 1991/0214/sys/src/9/gnot/boot.c:307,313 – 1991/0314/sys/src/9/gnot/boot.c:326,335 | ||
| 1991/0214 | close(fd); dup(p[0], 1); close(p[0]); | |
| 1991/0314 | if(format) execl("/cfs", "bootcfs", "-fs", 0); else execl("/cfs", "bootcfs", "-s", 0); | |
| 1991/0214 | break; default: close(p[0]); | |
| 1991/0314/sys/src/9/gnot/boot.c:86,93 – 1991/0418/sys/src/9/gnot/boot.c:86,104 (short | long) | ||
| 1991/0214 | ||
| 1991/0314 | if(manual) | |
| 1991/0214 | execl("/68020/init", "init", "-m", 0); | |
| 1991/0418 | else { switch(fork()){ case -1: print("can't start connection server\n"); break; case 0: execl("/68020/init", "init", "-d", "/bin/cs", 0); error("/68020/bin/cs"); break; default: execl("/68020/init", "init", 0); } } | |
| 1991/0214 | error("/68020/init"); } | |
| 1991/0418/sys/src/9/gnot/boot.c:21,27 – 1991/0430/sys/src/9/gnot/boot.c:21,27 (short | long) | ||
| 1990/03091 | main(int argc, char *argv[]) { | |
| 1991/0214 |
| |
| 1991/0430 | int fd, f, i; | |
| 1990/0918 | char buf[256]; | |
| 1991/01151 | Dir dir; | |
| 1990/03091 | ||
| 1991/0418/sys/src/9/gnot/boot.c:28,33 – 1991/0430/sys/src/9/gnot/boot.c:28,46 | ||
| 1990/03091 | open("#c/cons", OREAD); open("#c/cons", OWRITE); open("#c/cons", OWRITE); | |
| 1991/0430 | i = create("#e/sysname", 1, 0666); if(i < 0) error("sysname"); if(write(i, argv[0], strlen(argv[0])) != strlen(argv[0])) error("sysname"); close(i); i = create("#e/terminal", 1, 0666); if(i < 0) error("terminal"); if(write(i, "at&t gnot 1", strlen("at&t gnot 1")) < 0) error("terminal"); close(i); | |
| 1990/03091 | ||
| 1991/0214 | bootparams(); dkconfig(); | |
| 1991/0430/sys/src/9/gnot/boot.c:100,116 – 1991/0507/sys/src/9/gnot/boot.c:100,106 (short | long) | ||
| 1991/0314 | if(manual) | |
| 1991/0214 | execl("/68020/init", "init", "-m", 0); | |
| 1991/0418 | else { | |
| 1991/0507 | execl("/68020/init", "init", 0); | |
| 1991/0418 | } | |
| 1991/0214 | error("/68020/init"); } | |
| 1991/0507/sys/src/9/gnot/boot.c:120,128 – 1991/0606/sys/src/9/gnot/boot.c:120,128 (short | long) | ||
| 1990/0925 | * make it 9600 baud, * push the async protocol onto it, */ | |
| 1991/0606 | cfd = open("#t/tty0ctl", 2); | |
| 1990/0925 | if(cfd < 0) | |
| 1991/0606 | error("opening #t/tty0ctl"); | |
| 1990/0925 | sendmsg(cfd, "B9600"); sendmsg(cfd, "push async"); break; | |
| 1991/0507/sys/src/9/gnot/boot.c:133,141 – 1991/0606/sys/src/9/gnot/boot.c:133,141 | ||
| 1990/0917 | * make it 19200 baud, * push the async protocol onto it, */ | |
| 1991/0606 | cfd = open("#t/tty0ctl", 2); | |
| 1990/0917 | if(cfd < 0) | |
| 1991/0606 | error("opening #t/tty0ctl"); | |
| 1990/0917 | sendmsg(cfd, "B19200"); sendmsg(cfd, "push async"); break; | |
| 1991/0606/sys/src/9/gnot/boot.c:260,266 – 1991/0820/sys/src/9/gnot/boot.c:260,266 (short | long) | ||
| 1991/0214 | ||
| 1990/0312 | print("nop..."); hdr.type = Tnop; | |
| 1990/11211 |
| |
| 1991/0820 | hdr.tag = NOTAG; | |
| 1990/0312 | n = convS2M(&hdr, buf); if(write(fd, buf, n) != n) error("write nop"); | |
| 1991/0606/sys/src/9/gnot/boot.c:288,294 – 1991/0820/sys/src/9/gnot/boot.c:288,294 | ||
| 1991/0214 | ||
| 1990/0312 | print("session..."); hdr.type = Tsession; | |
| 1990/11211 |
| |
| 1991/0820 | hdr.tag = NOTAG; | |
| 1990/0312 | n = convS2M(&hdr, buf); if(write(fd, buf, n) != n) error("write session"); | |
| 1991/0820/sys/src/9/gnot/boot.c:2,160 – 1991/0906/sys/src/9/gnot/boot.c:2,303 (short | long) | ||
| 1990/03091 | #include <libc.h> | |
| 1990/11211 | #include <fcall.h> | |
| 1990/03091 | ||
| 1991/0906 | #define DEFSYS "Nfs" enum { CtrlD = 4, Cr = 13, }; char *net; char *netdev; | |
| 1990/03091 | Fcall hdr; | |
| 1991/0906 | char *scmd; char bootdevice; int authenticated; | |
| 1990/0613 | char bootline[64]; | |
| 1990/0917 |
| |
| 1990/0918 |
| |
| 1991/0314 |
| |
| 1991/0906 | char password[32]; char username[32]; char sys[NAMELEN]; char buf[4*1024]; | |
| 1990/03091 | ||
| 1990/0312 |
| |
| 1991/0906 | int format; int manual; /* * predeclared */ | |
| 1991/0214 | void bootparams(void); | |
| 1991/0906 | int outin(char *, char *, int); void prerror(char *); void error(char *); int dkdial(char *); | |
| 1991/0214 | void nop(int); void session(int); int cache(int); | |
| 1991/0906 | void sendmsg(int, char *); void connect(int); void kill(int); void passwd(void); int authenticate(int); void termtype(char*); void userpasswd(void); int fileserver(void); int inconctl(void); int asyncctl(char*); void dkconfig(int); void boot(int); | |
| 1990/03091 | ||
| 1991/0906 | /* * Ethernet type stations boot over ether or use dk via RS232. */ | |
| 1990/03091 | main(int argc, char *argv[]) { | |
| 1991/0430 |
| |
| 1990/0918 |
| |
| 1991/01151 |
| |
| 1991/0906 | int cfd; int fd; | |
| 1990/03091 | ||
| 1991/0906 | ||
| 1990/03091 | open("#c/cons", OREAD); open("#c/cons", OWRITE); open("#c/cons", OWRITE); | |
| 1991/0906 | sleep(1000); | |
| 1991/0430 |
| |
| 1990/03091 | ||
| 1991/0906 | /* * get parameters passed by boot rom to kernel */ | |
| 1991/0214 | bootparams(); | |
| 1991/0906 | termtype("at&t gnot 1"); | |
| 1990/0917 | ||
| 1991/0214 | /* | |
| 1991/0906 | * user/passwd pair if the boot rom didn't * authenticate | |
| 1991/0214 | */ | |
| 1991/0906 | if(!authenticated){ strcpy(username, "none"); userpasswd(); } | |
| 1991/0214 | /* | |
| 1991/0906 | * get the control channel for the network * device | |
| 1991/0214 | */ | |
| 1991/0906 | switch(fileserver()){ case 'a': cfd = asyncctl("B19200"); break; case 'A': cfd = asyncctl("B9600"); break; case 'i': default: cfd = inconctl(); break; } | |
| 1991/0214 | /* | |
| 1991/0906 | * start up the datakit and connect to * file server | |
| 1991/0214 | */ | |
| 1991/0906 | dkconfig(cfd); for(;;){ fd = dkdial(sys); if(fd >= 0) break; print("can't connect, retrying...\n"); sleep(1000); } | |
| 1991/0214 |
| |
| 1991/0906 | /* * set up the file system connection */ boot(fd); | |
| 1991/0214 | ||
| 1991/0906 | /* * go to init */ | |
| 1991/0314 | if(manual) | |
| 1991/0214 | execl("/68020/init", "init", "-m", 0); | |
| 1991/0418 |
| |
| 1991/0906 | else | |
| 1991/0507 | execl("/68020/init", "init", 0); | |
| 1991/0418 |
| |
| 1991/0214 | error("/68020/init"); } /* | |
| 1991/0906 | * read arguments passed by kernel as * environment variables - YECH! | |
| 1991/0214 | */ void | |
| 1991/0906 | bootparams(void) | |
| 1991/0214 | { | |
| 1991/0906 | int f; char *cp; | |
| 1991/0214 | ||
| 1990/0917 |
| |
| 1990/0925 |
| |
| 1991/0606 |
| |
| 1990/0925 |
| |
| 1991/0606 |
| |
| 1990/0925 |
| |
| 1990/0917 |
| |
| 1991/0115 |
| |
| 1990/0917 |
| |
| 1991/0606 |
| |
| 1990/0917 |
| |
| 1991/0606 |
| |
| 1990/0917 |
| |
| 1991/0906 | format = 0; manual = 0; f = open("#e/bootline", OREAD); if(f >= 0){ read(f, bootline, sizeof(bootline)-1); close(f); cp = bootline; while(cp = strchr(cp, ' ')){ if(*++cp != '-') continue; while(*cp && *cp!=' ') switch(*cp++){ case 'f': format = 1; break; case 'm': manual = 1; break; } } | |
| 1990/0917 | } | |
| 1991/0906 | f = open("#e/bootdevice", OREAD); if(f >= 0){ read(f, &bootdevice, 1); close(f); } f = open("#e/bootserver", OREAD); if(f >= 0){ read(f, sys, sizeof(sys)); close(f); } else strcpy(sys, DEFSYS); | |
| 1990/0917 | ||
| 1990/0312 | /* | |
| 1990/0917 |
| |
| 1990/0312 |
| |
| 1991/0906 | * perhaps a stupid assumption | |
| 1990/0312 | */ | |
| 1991/0906 | if(bootdevice == 'i') authenticated = 1; } /* * set flavor of terminal */ void termtype(char *t) { int fd; fd = create("#e/terminal", 1, 0666); if(fd < 0) error("terminal"); if(write(fd, t, strlen(t)) < 0) error("terminal"); close(fd); } /* * get user and password if the * boot rom didn't authenticate */ void userpasswd(void) { int fd; outin("user", username, sizeof(username)); passwd(); /* * set user id */ fd = open("#c/user", OWRITE|OTRUNC); if(fd >= 0){ write(fd, username, strlen(username)); close(fd); } } #define FS "(9)600 serial, (1)9200 serial, (i)incon" /* * if we've booted off the disk, figure out where to get the * file service from */ int fileserver(void) { char reply[4]; if(bootdevice != 's') return bootdevice; for(;;){ strcpy(reply, "9"); strcpy(sys, DEFSYS); outin(FS, reply, sizeof(reply)); switch(reply[0]){ case 'i': outin("server", sys, sizeof(sys)); return 'i'; case 'l': return 'l'; case '1': outin("server", sys, sizeof(sys)); return 'a'; case '9': outin("server", sys, sizeof(sys)); return 'A'; } } } /* * get the incon control channel */ int inconctl(void) { int cfd; cfd = open("#i/ctl", ORDWR); if(cfd < 0) error("opening #i/ctl"); return cfd; } /* * get the serial control channel and let the * user connect to the TSM8 */ int asyncctl(char *baud) { int cfd, dfd; char reply[4]; cfd = open("#t/tty0ctl", ORDWR); if(cfd < 0) error("opening #t/tty0ctl"); sendmsg(cfd, baud); dfd = open("#t/tty0", ORDWR); if(dfd < 0) error("opening #t/tty0"); connect(dfd); close(dfd); sendmsg(cfd, "push async"); return cfd; } /* * configure the datakit */ void dkconfig(int cfd) { | |
| 1990/0312 | sendmsg(cfd, "push dkmux"); | |
| 1990/0707 |
| |
| 1991/0906 | if(authenticated) sendmsg(cfd, "config 1 16 norestart"); else sendmsg(cfd, "config 1 16 restart"); | |
| 1990/0312 | /* | |
| 1990/0917 | * fork a process to hold the device channel open | |
| 1991/0820/sys/src/9/gnot/boot.c:173,253 – 1991/0906/sys/src/9/gnot/boot.c:316,460 | ||
| 1990/05312 | } | |
| 1991/0214 | } | |
| 1990/05312 | ||
| 1991/0214 |
| |
| 1991/0906 | dkdial(char *arg) | |
| 1991/0214 | { int fd, cfd; int i; long n; | |
| 1991/0906 | sprint(buf, "connect %s", arg); n = strlen(buf); | |
| 1990/11211 | for(i = 0; ; i++){ | |
| 1991/0906 | fd = open("#k/2/data", ORDWR); | |
| 1990/11211 | if(fd < 0) error("opening #k/2/data"); | |
| 1991/0906 | cfd = open("#k/2/ctl", ORDWR); | |
| 1990/11211 | if(cfd < 0) error("opening #k/2/ctl"); | |
| 1991/0906 | if(write(cfd, buf, n)==n && authenticate(fd)==0) | |
| 1990/11211 | break; if(i == 5) | |
| 1991/0214 |
| |
| 1991/0906 | return -1; | |
| 1990/11211 | close(fd); close(cfd); | |
| 1991/0906 | sleep(500); | |
| 1990/11211 | } | |
| 1990/0918 |
| |
| 1991/0906 | print("connected to %s\n", arg); sendmsg(cfd, "init"); | |
| 1990/0312 | close(cfd); | |
| 1991/0214 |
| |
| 1991/0906 | net = "dk"; netdev = "#k"; return fd; | |
| 1991/0214 | } | |
| 1990/0312 | ||
| 1991/0906 | void boot(int fd) { int n, f; char *srvname; Dir dir; char dirbuf[DIRLEN]; srvname = strrchr(sys, '/'); if(srvname) srvname++; else srvname = sys; nop(fd); session(fd); fd = cache(fd); /* * stick handles to the file system * into /srv */ print("post..."); 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); 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); /* * make the root a union */ print("mount..."); if(bind("/", "/", MREPL) < 0) error("bind"); if(mount(fd, "/", MAFTER|MCREATE, "", "") < 0) error("mount"); /* * 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); print("success\n"); /* * put a generic network device into the namespace */ if(netdev){ char buf[64]; sprint(buf, "/net/%s", net); bind(netdev, buf, MREPL); bind(netdev, "/net/net", MREPL); } if(net){ char buf[64]; sprint(buf, "/lib/netaddr.%s", net); print("binding %s onto /lib/netaddr.net\n", buf); bind(buf, "/lib/netaddr.net", MREPL); } } | |
| 1991/0214 | /* | |
| 1991/0906 | * authenticate with r70 | |
| 1991/0214 | */ | |
| 1991/0906 | int authenticate(int fd) | |
| 1991/0214 | { | |
| 1991/0314 |
| |
| 1991/0906 | int n; | |
| 1991/0214 | ||
| 1991/0314 |
| |
| 1991/0214 |
| |
| 1991/0314 |
| |
| 1991/0214 |
| |
| 1991/0314 |
| |
| 1991/0906 | for(;;) { n = read(fd, buf, sizeof(buf)); if(n != 2){ passwd(); return -1; | |
| 1991/0314 | } | |
| 1991/0906 | buf[2] = '\0'; if(strcmp(buf, "OK") == 0) return 0; else if(strcmp(buf, "CH") == 0) { sprint(buf, "%s\n%s\n", username, password); write(fd, buf, strlen(buf)); } else if(strcmp(buf, "NO") == 0) { passwd(); sprint(buf, "%s\n%s\n", username, password); write(fd, buf, strlen(buf)); } | |
| 1991/0214 | } | |
| 1991/0820/sys/src/9/gnot/boot.c:270,276 – 1991/0906/sys/src/9/gnot/boot.c:477,483 | ||
| 1990/0312 | if(n <= 0) error("read nop"); if(convM2S(buf, &hdr, n) == 0) { | |
| 1991/0906 | print("n = %d; buf = %#.2x %#.2x %#.2x %#.2x\n", | |
| 1990/0312 | n, buf[0], buf[1], buf[2], buf[3]); error("format nop"); } | |
| 1991/0820/sys/src/9/gnot/boot.c:279,285 – 1991/0906/sys/src/9/gnot/boot.c:486,492 | ||
| 1991/0214 | } | |
| 1990/0312 | ||
| 1991/0214 | /* | |
| 1991/0906 | * send session to file server | |
| 1991/0214 | */ void session(int fd) | |
| 1991/0820/sys/src/9/gnot/boot.c:312,328 – 1991/0906/sys/src/9/gnot/boot.c:519,536 | ||
| 1991/0214 | int cache(int fd) { | |
| 1991/0906 | Dir d; | |
| 1991/01151 | /* | |
| 1991/0214 | * if there's no /cfs, just return the fd to the * file server | |
| 1991/01151 | */ | |
| 1991/0214 |
| |
| 1991/0906 | if(dirstat("/cfs", &d) < 0) | |
| 1991/0214 | return fd; | |
| 1991/0906 | if(dirstat("#r/hd0cache", &d) < 0) return fd; | |
| 1991/0214 | print("cfs..."); | |
| 1991/0108 | ||
| 1991/0214 | /* | |
| 1991/0820/sys/src/9/gnot/boot.c:341,349 – 1991/0906/sys/src/9/gnot/boot.c:549,557 | ||
| 1991/0214 | dup(p[0], 1); close(p[0]); | |
| 1991/0314 | if(format) | |
| 1991/0906 | execl("/cfs", "bootcfs", "-fs", "-p", "#r/hd0cache", 0); | |
| 1991/0314 | else | |
| 1991/0906 | execl("/cfs", "bootcfs", "-s", "-p", "#r/hd0cache", 0); | |
| 1991/0214 | break; default: close(p[0]); | |
| 1991/0820/sys/src/9/gnot/boot.c:364,370 – 1991/0906/sys/src/9/gnot/boot.c:572,593 | ||
| 1990/0312 | error(msg); | |
| 1990/03091 | } | |
| 1991/0906 | /* * print error */ | |
| 1990/03091 | void | |
| 1991/0906 | prerror(char *s) { char buf[64]; errstr(buf); fprint(2, "boot: %s: %s\n", s, buf); } /* * print error and exit */ void | |
| 1990/03091 | error(char *s) { char buf[64]; | |
| 1991/0820/sys/src/9/gnot/boot.c:372,375 – 1991/0906/sys/src/9/gnot/boot.c:595,719 | ||
| 1990/11211 | errstr(buf); | |
| 1990/03091 | fprint(2, "boot: %s: %s\n", s, buf); exits(0); | |
| 1991/0906 | } /* * prompt and get input */ int outin(char *prompt, char *def, int len) { int n; char buf[256]; 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){ buf[n-1] = 0; strcpy(def, buf); } return n; } void connect(int fd) { char xbuf[128]; int i, pid, n, rcons; print("[ctrl-d to attach fs]\n"); switch(pid = fork()) { case -1: error("fork failed"); case 0: for(;;) { n = read(fd, xbuf, sizeof(xbuf)); if(n < 0) { errstr(xbuf); print("[remote read error (%s)]\n", xbuf); for(;;); } for(i = 0; i < n; i++) if(xbuf[i] == Cr) xbuf[i] = ' '; write(1, xbuf, n); } default: rcons = open("#c/rcons", OREAD); if(rcons < 0) error("opening rcons"); for(;;) { read(rcons, xbuf, 1); switch(xbuf[0]) { case CtrlD: kill(pid); close(rcons); return; default: n = write(fd, xbuf, 1); if(n < 0) { errstr(xbuf); kill(pid); close(rcons); print("[remote write error (%s)]\n", xbuf); } } } } } void kill(int pid) { char xbuf[32]; int f; sprint(xbuf, "/proc/%d/note", pid); f = open(xbuf, OWRITE); write(f, "die", 3); close(f); } void passwd(void) { Dir d; char c; int i, n, fd, p[2]; fd = open("#c/rcons", OREAD); if(fd < 0) error("can't open #c/rcons; please reboot"); Prompt: print("password: "); n = 0; do{ do{ i = read(fd, &c, 1); if(i < 0) error("can't read #c/rcons; please reboot"); }while(i == 0); switch(c){ case '\n': break; case '\b': if(n > 0) n--; break; case 'u' - 'a' + 1: /* cntrl-u */ print("\n"); goto Prompt; default: password[n++] = c; break; } }while(c != '\n' && n < sizeof(password)); password[n] = '\0'; close(fd); print("\n"); | |
| 1990/03091 | } | |
| 1991/0906/sys/src/9/gnot/boot.c:19,26 – 1991/0907/sys/src/9/gnot/boot.c:19,27 (short | long) | ||
| 1991/0906 | int authenticated; | |
| 1990/0613 | char bootline[64]; | |
| 1991/0906 |
| |
| 1991/0907 | char bootuser[NAMELEN]; char password[NAMELEN]; char username[NAMELEN]; | |
| 1991/0906 | char sys[NAMELEN]; char buf[4*1024]; | |
| 1990/03091 | ||
| 1991/0906/sys/src/9/gnot/boot.c:44,50 – 1991/0907/sys/src/9/gnot/boot.c:45,51 | ||
| 1991/0906 | void passwd(void); int authenticate(int); void termtype(char*); | |
| 1991/0907 | void setuser(char*); | |
| 1991/0906 | int fileserver(void); int inconctl(void); int asyncctl(char*); | |
| 1991/0906/sys/src/9/gnot/boot.c:77,84 – 1991/0907/sys/src/9/gnot/boot.c:78,89 | ||
| 1991/0214 | */ | |
| 1991/0906 | if(!authenticated){ strcpy(username, "none"); | |
| 1991/0907 | outin("user", username, sizeof(username)); passwd(); } else { strcpy(username, bootuser); | |
| 1991/0906 | } | |
| 1991/0907 | setuser(username); | |
| 1991/0214 | /* | |
| 1991/0906 | * get the control channel for the network | |
| 1991/0906/sys/src/9/gnot/boot.c:161,166 – 1991/0907/sys/src/9/gnot/boot.c:166,176 | ||
| 1991/0906 | read(f, &bootdevice, 1); close(f); } | |
| 1991/0907 | f = open("#e/bootuser", OREAD); if(f >= 0){ read(f, &bootuser, sizeof(bootuser)); close(f); } | |
| 1991/0906 | f = open("#e/bootserver", OREAD); if(f >= 0){ read(f, sys, sizeof(sys)); | |
| 1991/0906/sys/src/9/gnot/boot.c:196,207 – 1991/0907/sys/src/9/gnot/boot.c:206,214 | ||
| 1991/0906 | * boot rom didn't authenticate */ void | |
| 1991/0907 | setuser(char *name) | |
| 1991/0906 | { int fd; | |
| Too many diffs (26 > 25). Stopping. | ||