int do_load(){ s8 ret; u8 ch; u32 i=0; u8 id; u8 password[PASSWORD_LENGTH]; u8 username[MAX_NAME]; if (is_loaded){ vd_puts("FILE SYSTEM ALREADY LOADED\n"); return 0; } vd_puts("ENTER USER NAME ::") ; gets(username); username[--i] = 0; i=0; vd_puts("\nENTER PASSWORD ::"); while (i <= PASSWORD_LENGTH && ( ch = password[i++] = getch() ) != (u8)('\n') && ch != (u8)('\r'))vd_putchar('#'); password[--i] = 0; vd_puts("\n"); ret = loadfs(username,password); flpchange=0; if(ret == -1){ ERROR_NO=0; ret = loadfs(username,password); flpchange=0; if (ret == -1){ vd_puts( "CANNOT LOAD FILESYSTEM\n" ); errormessage(geterror()); return 1; } } is_loaded = 1; fl_clean(); return 0; }
void main(int argc, char **argv) { int ro; char *file, *mount; mount = "/n/brzr"; ro = 0; file = "/dev/flash/fs"; ARGBEGIN { case 'D': chatty9p++; break; case 'r': ro++; break; case 'n': nsects = argval(ARGF()); break; case 'z': sectsize = argval(ARGF()); break; case 'f': file = ARGF(); break; case 'm': mount = ARGF(); break; default: usage(); } ARGEND if(argc != 0) usage(); initdata(file, 0); sectbuff = emalloc9p(sectsize); einit(); loadfs(ro); serve(mount); exits(nil); }
int main() { char lstr[8][64]; char buffer[80]; char verb[80]; char wd[512]; int len; int prog; int selected_sbuffer = 0; while (1) { iwrites("wsh-"); fgetwd(wd); iwrites(wd); iwrites("> "); ireads(buffer, 80); len = sfindc(buffer, ' '); if (len < 0) len = slength(buffer); scopy(verb, buffer, len); if (!scompare(verb, "help")) { iwrites("\ncat: print file contents\ncd: change directories\necho: print a string\nhelp: display this message\nls: list files\npwd: print current working directory\nloads: load a string to be used with all commands which act upon strings\nprintf: write to a pre-existing file\nprints: print the currently loaded string\nrms: unload the currently loaded string\ncons: concatenate a string to the end of the currently loaded string\nloadfs: load the contents of a file into the String Buffer\nchsf: switch to the next String Buffer\nchsb: switch to the previous String Buffer\npsb: print the currently selected String Buffer\nreboot: reboot the operating system\n\n"); } else if (!scompare(verb, "ls")) { ls(); } else if (!scompare(verb, "cd")) { cd(buffer + len + 1); } else if (!scompare(verb, "cat")) { /* Mrew? */ cat(buffer + len + 1); } else if (!scompare(verb, "echo")){ echo(buffer + len + 1); } else if (!scompare(verb, "pwd")){ pwd(); } else if (!scompare(verb, "reboot")) { ireboot(); } else if (!scompare(verb, "printf")) { printf(buffer + len + 1, lstr[selected_sbuffer]); } else if (!scompare(verb, "loads")) { loads(buffer + len + 1, lstr[selected_sbuffer]); } else if (!scompare(verb, "prints")) { iwrites(lstr[selected_sbuffer]); iwrites("\n"); } else if (!scompare(verb, "rms")) { scopy(lstr[selected_sbuffer], "\0", 1); } else if (!scompare(verb, "loadfs")) { loadfs(buffer + len + 1, lstr[selected_sbuffer]); } else if (!scompare(verb, "cons")) { cons(buffer + len + 1, lstr[selected_sbuffer]); } else if (!scompare(verb, "chsf")) { selected_sbuffer = chsf(selected_sbuffer); } else if (!scompare(verb, "psb")) { psb(selected_sbuffer); } else if (!scompare(verb, "chsb")) { selected_sbuffer = chsb(selected_sbuffer); } /* else if (!scompare(verb, "mk")) { mk(buffer + len + 1); } */ else if (sfindc(verb, '/') == -1) { prog = fget("/bin/"); if (!prog) { iwrites("Error: unable to locate bin directory\n"); continue; } prog = ffind(prog, verb); if (!prog) { iwrites("Error: unrecognized command \""); iwrites(verb); iwrites("\"\n"); continue; } if (fgettype(prog) == 2) iexec(prog); else { iwrites("Error: file is not executable\n"); continue; } } else if (prog = fget(verb)) { if (fgettype(prog) == 2) iexec(prog); else { iwrites("Error: file is not executable\n"); continue; } } else { iwrites("Error: executable not found\n"); continue; } } }