X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FApplications%2Finit_src%2Fmain.c;h=ff347960799b881337d69d7dd0850e38a61fb374;hb=91a13665236dfe9f0c053eb49d8ab60a6476f9ad;hp=0dbbff1493c81db3ce5813f62160ae8ea158f341;hpb=b9bf2c8b90b846a8cf11b57071765f24dd37fd4f;p=tpg%2Facess2.git diff --git a/Usermode/Applications/init_src/main.c b/Usermode/Applications/init_src/main.c index 0dbbff14..ff347960 100644 --- a/Usermode/Applications/init_src/main.c +++ b/Usermode/Applications/init_src/main.c @@ -216,7 +216,7 @@ int ProcessInittab(const char *Path) line_num ++; int rv; - if( (rv = fscanf(fp, "%64s%*[ \t]", &cmdbuf)) != 1 ) { + if( (rv = fscanf(fp, "%64s%*[ \t]", cmdbuf)) != 1 ) { _SysDebug("fscanf rv %i != exp 1", rv); break; } @@ -252,13 +252,12 @@ int ProcessInittab(const char *Path) goto lineError; } AddKTerminal(id, command); - free(command); } else if(strcmp(cmdbuf, "stty") == 0 ) { // stty [78][NOE][012][bB] char path_seg[32+1]; char modespec[4+6+1]; - if( fscanf(fp, "%32s %6s ", &path_seg, &modespec) != 2 ) { + if( fscanf(fp, "%32s %10s ", path_seg, modespec) != 2 ) { goto lineError; } char **command = ReadCommand(fp); @@ -271,8 +270,14 @@ int ProcessInittab(const char *Path) // - Runs a daemon (respawning) that logs to the specified files // - Will append a header whenever the daemon starts char *stdout_path = ReadQuotedString(fp); + if( !stdout_path ) + goto lineError; char *stderr_path = ReadQuotedString(fp); + if( !stderr_path ) + goto lineError; char **command = ReadCommand(fp); + if( !command ) + goto lineError; AddDaemon(stdout_path, stderr_path, command); } @@ -284,7 +289,7 @@ int ProcessInittab(const char *Path) if(!command) goto lineError; - int handles[] = {0, 1, 2}; + int handles[] = {0, 1, 1}; int pid = _SysSpawn(command[0], (const char **)command, NULL, 3, handles, NULL); int retstatus; _SysWaitTID(pid, &retstatus); @@ -368,8 +373,9 @@ int AddSerialTerminal(const char *DevPathSegment, const char *ModeStr, char **Co int baud; // Parse mode string - if( sscanf(ModeStr, "%1[78]%1[NOE]%1[012]%*1[bB]%d", &dbit, &parity, &sbit, &baud) != 5 ) { + if( sscanf(ModeStr, "%1[78]%1[NOE]%1[012]%*1[bB]%d", &dbit, &parity, &sbit, &baud) != 4 ) { // Oops? + _SysDebug("Serial mode string is invalid ('%s')", ModeStr); return -1; } @@ -420,7 +426,7 @@ int SpawnCommand(int c_stdin, int c_stdout, int c_stderr, char **ArgV) int SpawnKTerm(tInitProgram *Program) { - const char fmt[] = "/Devices/VTerm/%i"; + const char fmt[] = "/Devices/pts/vt%ic"; char path[sizeof(fmt)]; snprintf(path, sizeof(path), fmt, Program->TypeInfo.KTerm.ID); @@ -436,6 +442,11 @@ int SpawnSTerm(tInitProgram *Program) int in = _SysOpen(Program->TypeInfo.STerm.Path, OPENFLAG_READ); int out = _SysOpen(Program->TypeInfo.STerm.Path, OPENFLAG_WRITE); + if(in == -1 || out == -1 ) { + _SysDebug("Unable to open serial port '%s'", Program->TypeInfo.STerm.Path); + return -1; + } + #if 0 if( _SysIOCtl(in, 0, NULL) != DRV_TYPE_SERIAL ) { @@ -462,6 +473,13 @@ int SpawnDaemon(tInitProgram *Program) return -2; } + // Log spawn header + { + char buffer[101]; + size_t len = snprintf(buffer, 100, "[%i] init spawning '%s'\n", _SysTimestamp(), Program->Command); + _SysWrite(out, buffer, len); + } + return SpawnCommand(in, out, err, Program->Command); }