Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3820 → Rev 3896

/trunk/uspace/lib/libc/generic/task.c
63,8 → 63,8
task_id_t task_id;
int rc;
 
/* Spawn a program loader. */
ldr = loader_spawn(path);
/* Connect to a program loader. */
ldr = loader_connect();
if (ldr == NULL)
return 0;
 
89,7 → 89,6
goto error;
 
/* Run it. */
/* Load the program. */
rc = loader_run(ldr);
if (rc != EOK)
goto error;
/trunk/uspace/lib/libc/generic/loader.c
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(const char *name)
int loader_spawn(const char *name)
{
int phone_id, rc;
return __SYSCALL2(SYS_PROGRAM_SPAWN_LOADER,
(sysarg_t) name, strlen(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(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.