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

Keep track of program image path.

This commit is contained in:
Jonas 'Sortie' Termansen 2013-03-19 23:17:36 +01:00
parent e97990e144
commit f2556c3551
3 changed files with 19 additions and 1 deletions

View file

@ -46,6 +46,7 @@
#include <sortix/kernel/time.h> #include <sortix/kernel/time.h>
#include <sortix/kernel/scheduler.h> #include <sortix/kernel/scheduler.h>
#include <sortix/kernel/fcache.h> #include <sortix/kernel/fcache.h>
#include <sortix/kernel/string.h>
#include <sortix/fcntl.h> #include <sortix/fcntl.h>
#include <sortix/stat.h> #include <sortix/stat.h>
@ -266,6 +267,9 @@ extern "C" void KernelInit(unsigned long magic, multiboot_info_t* bootinfo)
addr_t systemaddrspace = Memory::GetAddressSpace(); addr_t systemaddrspace = Memory::GetAddressSpace();
system->addrspace = systemaddrspace; system->addrspace = systemaddrspace;
if ( !(system->program_image_path = String::Clone("<kernel process>")) )
Panic("Unable to clone string for system process name");
// We construct this thread manually for bootstrap reasons. We wish to // We construct this thread manually for bootstrap reasons. We wish to
// create a kernel thread that is the current thread and isn't put into the // create a kernel thread that is the current thread and isn't put into the
// scheduler's set of runnable threads, but rather run whenever there is // scheduler's set of runnable threads, but rather run whenever there is

View file

@ -112,6 +112,7 @@ namespace Sortix
nextsibling = NULL; nextsibling = NULL;
firstchild = NULL; firstchild = NULL;
zombiechild = NULL; zombiechild = NULL;
program_image_path = NULL;
parentlock = KTHREAD_MUTEX_INITIALIZER; parentlock = KTHREAD_MUTEX_INITIALIZER;
childlock = KTHREAD_MUTEX_INITIALIZER; childlock = KTHREAD_MUTEX_INITIALIZER;
zombiecond = KTHREAD_COND_INITIALIZER; zombiecond = KTHREAD_COND_INITIALIZER;
@ -129,6 +130,8 @@ namespace Sortix
Process::~Process() Process::~Process()
{ {
if ( program_image_path )
delete[] program_image_path;
assert(!zombiechild); assert(!zombiechild);
assert(!firstchild); assert(!firstchild);
assert(!addrspace); assert(!addrspace);
@ -568,6 +571,9 @@ namespace Sortix
clone->mtable = mtable; clone->mtable = mtable;
kthread_mutex_unlock(&ptrlock); kthread_mutex_unlock(&ptrlock);
if ( !(clone->program_image_path = String::Clone(program_image_path)) )
failure = false;
if ( pid == 1) if ( pid == 1)
assert(dtable->Get(1)); assert(dtable->Get(1));
@ -601,8 +607,15 @@ namespace Sortix
(void) programname; (void) programname;
assert(CurrentProcess() == this); assert(CurrentProcess() == this);
char* programname_clone = String::Clone(programname);
if ( !programname_clone )
return -1;
addr_t entry = ELF::Construct(CurrentProcess(), program, programsize); addr_t entry = ELF::Construct(CurrentProcess(), program, programsize);
if ( !entry ) { return -1; } if ( !entry ) { delete[] programname_clone; return -1; }
delete[] program_image_path;
program_image_path = programname_clone; programname_clone = NULL;
// TODO: This may be an ugly hack! // TODO: This may be an ugly hack!
// TODO: Move this to x86/process.cpp. // TODO: Move this to x86/process.cpp.

View file

@ -80,6 +80,7 @@ namespace Sortix
static pid_t AllocatePID(); static pid_t AllocatePID();
public: public:
char* program_image_path;
addr_t addrspace; addr_t addrspace;
pid_t pid; pid_t pid;
uid_t uid; uid_t uid;