From 2c3fb60d5279c19185ad4891b6ceb2bea666e695 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Tue, 22 Nov 2011 15:27:58 +0100 Subject: [PATCH] execve(2) now works relative to current dir. --- sortix/process.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sortix/process.cpp b/sortix/process.cpp index 2122c8d2..c3da6bfd 100644 --- a/sortix/process.cpp +++ b/sortix/process.cpp @@ -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.