/branches/tracing/uspace/lib/libc/generic/vfs/vfs.c |
---|
48,7 → 48,6 |
#include <futex.h> |
#include <errno.h> |
#include <string.h> |
#include <ipc/devmap.h> |
#include "../../srv/vfs/vfs.h" |
int vfs_phone = -1; |
103,49 → 102,14 |
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; |
res = device_get_handle(dev, &dev_handle); |
if (res != EOK) |
return res; |
dev_handle_t dev_handle = 0; /* TODO */ |
size_t mpa_len; |
char *mpa = absolutize(mp, &mpa_len); |
if (!mpa) |
/branches/tracing/uspace/lib/libc/generic/libc.c |
---|
64,10 → 64,14 |
_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/tracing/uspace/lib/libc/generic/io/stream.c |
---|
56,54 → 56,52 |
ssize_t read_stdin(void *buf, size_t count) |
{ |
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; |
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; |
} |
return i; |
} else { |
return -1; |
((char *) buf)[i++] = r0; |
} |
return i; |
} |
ssize_t write_stdout(const void *buf, size_t count) |
{ |
open_console(); |
if (console_phone >= 0) { |
int i; |
int i; |
for (i = 0; i < count; i++) |
async_msg_1(console_phone, CONSOLE_PUTCHAR, |
((const char *) buf)[i]); |
for (i = 0; i < count; i++) |
async_msg_1(console_phone, CONSOLE_PUTCHAR, |
((const char *) buf)[i]); |
return count; |
} else |
return __SYSCALL3(SYS_KLOG, 1, (sysarg_t) buf, count); |
return count; |
} |
void open_console(void) |
void open_stdin(void) |
{ |
if (console_phone < 0) { |
int phone = ipc_connect_me_to(PHONE_NS, SERVICE_CONSOLE, 0, 0); |
if (phone >= 0) |
console_phone = phone; |
while ((console_phone = ipc_connect_me_to(PHONE_NS, |
SERVICE_CONSOLE, 0, 0)) < 0) { |
usleep(10000); |
} |
} |
} |
void klog_update(void) |
void open_stdout(void) |
{ |
(void) __SYSCALL3(SYS_KLOG, 1, NULL, 0); |
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; |
} |
/branches/tracing/uspace/lib/libc/generic/async.c |
---|
1012,3 → 1012,4 |
/** @} |
*/ |
/branches/tracing/uspace/lib/libc/generic/fibril.c |
---|
342,3 → 342,4 |
/** @} |
*/ |
/branches/tracing/uspace/lib/libc/generic/task.c |
---|
44,10 → 44,5 |
return task_id; |
} |
int task_spawn(void *image, size_t size) |
{ |
return __SYSCALL2(SYS_TASK_SPAWN, (sysarg_t) image, (sysarg_t) size); |
} |
/** @} |
*/ |