|
|
1.1 ! root 1: #include <u.h> ! 2: #include <libc.h> ! 3: #include <../boot/boot.h> ! 4: ! 5: static char diskname[2*NAMELEN]; ! 6: static char *disk; ! 7: ! 8: /* ! 9: * This is complete black magic to guess what physical disk the file ! 10: * system is on. The reason for all the variation is because the ! 11: * info comes in totally different forms from each type of system. ! 12: */ ! 13: void ! 14: configlocal(Method *mp) ! 15: { ! 16: char *p; ! 17: int n; ! 18: ! 19: if(*sys == '/' || *sys == '#'){ ! 20: /* ! 21: * if the user specifies the disk in the boot cmd or ! 22: * 'root is from' prompt, use it ! 23: */ ! 24: disk = sys; ! 25: } else if(strncmp(argv0, "dksc(0,", 7) == 0){ ! 26: /* ! 27: * on many mips arg0 of the boot command specifies the ! 28: * scsi logical unit number ! 29: */ ! 30: p = strchr(argv0, ','); ! 31: n = strtoul(p+1, 0, 10); ! 32: sprint(diskname, "#w%d/sd%dfs", n, n); ! 33: disk = diskname; ! 34: } else if(mp->arg){ ! 35: /* ! 36: * a default is supplied when the kernel is made ! 37: */ ! 38: disk = mp->arg; ! 39: } else if(*bootdisk){ ! 40: /* ! 41: * an environment variable from a pc's plan9.ini or ! 42: * from the mips nvram or generated by the kernel ! 43: * is the last resort. ! 44: */ ! 45: disk = bootdisk; ! 46: } ! 47: ! 48: /* if we've decided on one, pass it on to all programs */ ! 49: if(disk) ! 50: setenv("bootdisk", disk); ! 51: ! 52: USED(mp); ! 53: } ! 54: ! 55: int ! 56: authlocal(void) ! 57: { ! 58: return -1; ! 59: } ! 60: ! 61: int ! 62: connectlocal(void) ! 63: { ! 64: int p[2]; ! 65: char d[DIRLEN]; ! 66: char partition[2*NAMELEN]; ! 67: char *args[16], **argp; ! 68: char *dfl; ! 69: ! 70: dfl = "/fs"; ! 71: ! 72: sprint(partition, "%sfs", disk); ! 73: if(stat(partition, d) < 0){ ! 74: strcpy(partition, disk); ! 75: if(stat(partition, d) < 0) { ! 76: return -1; ! 77: } ! 78: } ! 79: ! 80: print("fs..."); ! 81: if(bind("#c", "/dev", MREPL) < 0) ! 82: fatal("bind #c"); ! 83: if(bind("#p", "/proc", MREPL) < 0) ! 84: fatal("bind #p"); ! 85: if(pipe(p)<0) ! 86: fatal("pipe"); ! 87: switch(fork()){ ! 88: case -1: ! 89: fatal("fork"); ! 90: case 0: ! 91: dup(p[0], 0); ! 92: dup(p[1], 1); ! 93: close(p[0]); ! 94: close(p[1]); ! 95: argp = args; ! 96: *argp++ = "fs"; ! 97: *argp++ = "-f"; ! 98: *argp++ = partition; ! 99: *argp++ = "-s"; ! 100: *argp = 0; ! 101: exec(dfl, args); ! 102: fatal("can't exec fs"); ! 103: default: ! 104: break; ! 105: } ! 106: ! 107: close(p[1]); ! 108: return p[0]; ! 109: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.