| plan 9 kernel history: overview | file list | diff list |
2001/0527/boot/local.c (diff list | history)
| boot/local.c on 1992/0317 | ||
| 1992/0317 | #include <u.h> #include <libc.h> #include <../boot/boot.h> | |
| 2001/0527 | static char diskname[64]; | |
| 1992/0317 | static char *disk; | |
| 2000/1018 | static char **args; | |
| 1992/0317 | void configlocal(Method *mp) { | |
| 1994/0312 | char *p; int n; | |
| 1995/02021 | if(*sys == '/' || *sys == '#'){ /* * if the user specifies the disk in the boot cmd or * 'root is from' prompt, use it */ disk = sys; } else if(strncmp(argv0, "dksc(0,", 7) == 0){ /* * on many mips arg0 of the boot command specifies the * scsi logical unit number */ | |
| 1994/0312 | p = strchr(argv0, ','); n = strtoul(p+1, 0, 10); sprint(diskname, "#w%d/sd%dfs", n, n); disk = diskname; | |
| 1995/02021 | } else if(mp->arg){ /* * a default is supplied when the kernel is made */ disk = mp->arg; } else if(*bootdisk){ /* * an environment variable from a pc's plan9.ini or * from the mips nvram or generated by the kernel * is the last resort. */ disk = bootdisk; | |
| 1994/0312 | } | |
| 1995/02021 | /* if we've decided on one, pass it on to all programs */ | |
| 1994/0312 | if(disk) setenv("bootdisk", disk); | |
| 1995/02021 | ||
| 1992/0317 | USED(mp); } int authlocal(void) { return -1; } int connectlocal(void) { | |
| 2000/1018 | int i, p[2]; | |
| 2001/0527 | Dir *dir; char partition[64]; | |
| 1992/0902 | char *dev; | |
| 2000/1018 | char **arg, **argp; | |
| 2001/0527 | ulong mode; | |
| 1992/0317 | ||
| 2001/0527 | if(stat("/kfs", statbuf, sizeof statbuf) < 0) | |
| 1992/0317 | return -1; | |
| 1992/0902 | dev = disk ? disk : bootdisk; | |
| 2001/0527 | snprint(partition, sizeof partition, "%sfs", dev); dir = dirstat(partition); if(dir == nil){ | |
| 1992/0902 | strcpy(partition, dev); | |
| 2001/0527 | dir = dirstat(partition); if(dir == nil) | |
| 1992/0902 | return -1; } | |
| 2001/0527 | mode = dir->mode; free(dir); if(mode & DMDIR) | |
| 2000/0506 | return -1; | |
| 1992/0902 | ||
| 1999/0501 | print("kfs..."); | |
| 1992/0317 | if(bind("#c", "/dev", MREPL) < 0) fatal("bind #c"); if(bind("#p", "/proc", MREPL) < 0) fatal("bind #p"); if(pipe(p)<0) fatal("pipe"); switch(fork()){ case -1: fatal("fork"); case 0: | |
| 2000/1018 | arg = malloc((bargc+5)*sizeof(char*)); argp = arg; | |
| 1999/0501 | *argp++ = "kfs"; | |
| 1993/0403 | *argp++ = "-f"; *argp++ = partition; *argp++ = "-s"; | |
| 2000/1018 | for(i=1; i<bargc; i++) *argp++ = bargv[i]; | |
| 1993/0403 | *argp = 0; | |
| 2001/0527 | print("kfs"); for(argp=arg; *argp; argp++) print(" %s", *argp); print("\n"); | |
| 2000/1018 | dup(p[0], 0); dup(p[1], 1); close(p[0]); close(p[1]); exec("/kfs", arg); | |
| 1999/0501 | fatal("can't exec kfs"); | |
| 1992/0317 | default: break; } close(p[1]); return p[0]; } | |