34,6 → 34,7 |
|
#include <ipc/ipc.h> |
#include <ipc/loader.h> |
#include <ipc/services.h> |
#include <libc.h> |
#include <task.h> |
#include <string.h> |
50,33 → 51,27 |
* @return Pointer to the loader connection structure (should be |
* de-allocated using free() after use). |
*/ |
loader_t *loader_spawn(char *name) |
int loader_spawn(const char *name) |
{ |
int phone_id, rc; |
return __SYSCALL2(SYS_PROGRAM_SPAWN_LOADER, |
(sysarg_t) name, str_size(name)); |
} |
|
loader_t *loader_connect(void) |
{ |
loader_t *ldr; |
int phone_id; |
|
/* |
* Ask kernel to spawn a new loader task. |
*/ |
rc = __SYSCALL3(SYS_PROGRAM_SPAWN_LOADER, (sysarg_t) &phone_id, |
(sysarg_t) name, strlen(name)); |
if (rc != 0) |
phone_id = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_LOAD, 0, 0); |
if (phone_id < 0) |
return NULL; |
|
/* |
* Say hello so that the loader knows the incoming connection's |
* phone hash. |
*/ |
rc = async_req_0_0(phone_id, LOADER_HELLO); |
if (rc != EOK) |
return NULL; |
|
ldr = malloc(sizeof(loader_t)); |
if (ldr == NULL) |
return NULL; |
|
ldr->phone_id = phone_id; |
return ldr; |
return ldr; |
} |
|
/** Get ID of the new task. |
173,7 → 168,7 |
ap = argv; |
buffer_size = 0; |
while (*ap != NULL) { |
buffer_size += strlen(*ap) + 1; |
buffer_size += str_size(*ap) + 1; |
++ap; |
} |
|
183,9 → 178,10 |
/* Now fill the buffer with null-terminated argument strings */ |
ap = argv; |
dp = arg_buf; |
|
while (*ap != NULL) { |
strcpy(dp, *ap); |
dp += strlen(*ap) + 1; |
str_cpy(dp, buffer_size - (dp - arg_buf), *ap); |
dp += str_size(*ap) + 1; |
|
++ap; |
} |
247,6 → 243,8 |
if (rc != EOK) |
return rc; |
|
ipc_hangup(ldr->phone_id); |
ldr->phone_id = 0; |
return EOK; |
} |
|