Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3149 → Rev 3150

/branches/dynload/uspace/lib/libc/generic/task.c
54,7 → 54,7
{
int phone_id, rc;
 
rc = __SYSCALL1(SYS_TASK_SPAWN, (sysarg_t) &phone_id);
rc = __SYSCALL1(SYS_TASK_SPAWN_LOADER, (sysarg_t) &phone_id);
if (rc != 0)
return rc;
 
67,7 → 67,7
* @param argv command-line arguments
* @return ID of the newly created task or zero on error.
*/
task_id_t task_spawn(const char *path, const char *argv[])
task_id_t task_spawn_ex(const char *path, const char *argv[])
{
int phone_id;
ipc_call_t answer;
105,5 → 105,10
return 1;
}
 
int task_spawn(void *image, size_t size)
{
return __SYSCALL2(SYS_TASK_SPAWN, (sysarg_t) image, (sysarg_t) size);
}
 
/** @}
*/
/branches/dynload/uspace/lib/libc/generic/libc.c
64,14 → 64,10
_async_init();
f = fibril_setup();
__tcb_set(f->tcb);
open_console();
}
 
void __io_init(void)
{
open_stdin();
open_stdout();
}
 
void __exit(void)
{
fibril_teardown(__tcb_get()->fibril_data);
/branches/dynload/uspace/lib/libc/generic/vfs/vfs.c
48,6 → 48,7
#include <futex.h>
#include <errno.h>
#include <string.h>
#include <ipc/devmap.h>
#include "../../srv/vfs/vfs.h"
 
int vfs_phone = -1;
102,14 → 103,49
return vfs_phone;
}
 
static int device_get_handle(char *name, dev_handle_t *handle)
{
int phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP, DEVMAP_CLIENT, 0);
if (phone < 0)
return phone;
ipc_call_t answer;
aid_t req = async_send_2(phone, DEVMAP_DEVICE_GET_HANDLE, 0, 0,
&answer);
ipcarg_t retval = ipc_data_write_start(phone, name, strlen(name) + 1);
 
if (retval != EOK) {
async_wait_for(req, NULL);
ipc_hangup(phone);
return retval;
}
 
async_wait_for(req, &retval);
 
if (handle != NULL)
*handle = -1;
if (retval == EOK) {
if (handle != NULL)
*handle = (dev_handle_t) IPC_GET_ARG1(answer);
}
ipc_hangup(phone);
return retval;
}
 
int mount(const char *fs_name, const char *mp, const char *dev)
{
int res;
ipcarg_t rc;
aid_t req;
 
dev_handle_t dev_handle = 0; /* TODO */
 
dev_handle_t dev_handle;
res = device_get_handle(dev, &dev_handle);
if (res != EOK)
return res;
size_t mpa_len;
char *mpa = absolutize(mp, &mpa_len);
if (!mpa)
/branches/dynload/uspace/lib/libc/generic/io/stream.c
56,52 → 56,47
 
ssize_t read_stdin(void *buf, size_t count)
{
ipcarg_t r0, r1;
size_t i = 0;
 
while (i < count) {
if (async_req_0_2(console_phone, CONSOLE_GETCHAR, &r0,
&r1) < 0) {
return -1;
open_console();
if (console_phone >= 0) {
ipcarg_t r0, r1;
size_t i = 0;
while (i < count) {
if (async_req_0_2(console_phone, CONSOLE_GETCHAR, &r0, &r1) < 0)
return -1;
((char *) buf)[i++] = r0;
}
((char *) buf)[i++] = r0;
return i;
}
return i;
}
 
ssize_t write_stdout(const void *buf, size_t count)
{
int i;
 
for (i = 0; i < count; i++)
async_msg_1(console_phone, CONSOLE_PUTCHAR,
((const char *) buf)[i]);
open_console();
if (console_phone >= 0) {
int i;
return count;
for (i = 0; i < count; i++)
async_msg_1(console_phone, CONSOLE_PUTCHAR,
((const char *) buf)[i]);
return count;
} else
return __SYSCALL3(SYS_IO, 1, (sysarg_t) buf, count);
}
 
void open_stdin(void)
void open_console(void)
{
if (console_phone < 0) {
while ((console_phone = ipc_connect_me_to(PHONE_NS,
SERVICE_CONSOLE, 0, 0)) < 0) {
usleep(10000);
}
int phone = ipc_connect_me_to(PHONE_NS, SERVICE_CONSOLE, 0, 0);
if (phone >= 0)
console_phone = phone;
}
}
 
void open_stdout(void)
{
if (console_phone < 0) {
while ((console_phone = ipc_connect_me_to(PHONE_NS,
SERVICE_CONSOLE, 0, 0)) < 0) {
usleep(10000);
}
}
}
 
int get_cons_phone(void)
{
open_console();
return console_phone;
}