1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

execve(2) now works relative to current dir.

This commit is contained in:
Jonas 'Sortie' Termansen 2011-11-22 15:27:58 +01:00
parent e8fb8d885b
commit 2c3fb60d52

View file

@ -382,10 +382,11 @@ namespace Sortix
return 0;
}
DevBuffer* OpenProgramImage(const char* progname)
DevBuffer* OpenProgramImage(const char* progname, const char* wd, const char* path)
{
// TODO: Use the PATH enviromental variable.
char* abs = Directory::MakeAbsolute("/bin", progname);
const char* base = ( *progname == '.' ) ? wd : path;
char* abs = Directory::MakeAbsolute(base, progname);
if ( !abs ) { Error::Set(Error::ENOMEM); return NULL; }
// TODO: Use O_EXEC here!
@ -421,7 +422,8 @@ namespace Sortix
if ( !state->argv[i] ) { delete state; return -1; }
}
state->dev = OpenProgramImage(state->filename);
Process* process = CurrentProcess();
state->dev = OpenProgramImage(state->filename, process->workingdir, "/bin");
if ( !state->dev ) { delete state; return -1; }
state->dev->Refer(); // TODO: Rules of GC may change soon.