Added file io test to test0. Added close call to libposix.

This commit is contained in:
Bahadir Balban
2008-04-18 21:17:09 +01:00
parent cff7a505e8
commit f7163b7e93
7 changed files with 83 additions and 13 deletions

46
tasks/libposix/close.c Normal file
View File

@@ -0,0 +1,46 @@
/*
* l4/posix glue for close()
*
* Copyright (C) 2007 Bahadir Balban
*/
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <l4lib/arch/syscalls.h>
#include <l4lib/arch/syslib.h>
#include <l4lib/ipcdefs.h>
#include <l4lib/utcb.h>
#include <l4/macros.h>
#include INC_GLUE(memory.h)
static inline int l4_close(int fd)
{
write_mr(L4SYS_ARG0, fd);
/* Call pager with close() request. Check ipc error. */
if ((fd = l4_sendrecv(VFS_TID, VFS_TID, L4_IPC_TAG_CLOSE)) < 0) {
printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, fd);
return fd;
}
/* Check if syscall itself was successful */
if ((fd = l4_get_retval()) < 0) {
printf("%s: CLOSE Error: %d.\n", __FUNCTION__, fd);
return fd;
}
return fd;
}
int close(int fd)
{
int ret = l4_close(fd);
/* If error, return positive error code */
if (ret < 0) {
errno = -ret;
return -1;
}
/* else return value */
return ret;
}

View File

@@ -22,13 +22,12 @@ static inline int l4_open(const char *pathname, int flags, mode_t mode)
{
int fd;
// write_mr(L4SYS_ARG0, (unsigned long)pathname);
copy_to_utcb((void *)pathname, 0, strlen(pathname) + 1);
write_mr(L4SYS_ARG0, (unsigned long)utcb_page);
write_mr(L4SYS_ARG1, flags);
write_mr(L4SYS_ARG2, (u32)mode);
/* Call pager with shmget() request. Check ipc error. */
/* Call pager with open() request. Check ipc error. */
if ((fd = l4_sendrecv(VFS_TID, VFS_TID, L4_IPC_TAG_OPEN)) < 0) {
printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, fd);
return fd;

View File

@@ -19,7 +19,7 @@ static inline int l4_write(int fd, const void *buf, size_t count)
write_mr(L4SYS_ARG1, (const unsigned long)buf);
write_mr(L4SYS_ARG2, count);
/* Call pager with shmget() request. Check ipc error. */
/* Call pager with write() request. Check ipc error. */
if ((wrcnt = l4_sendrecv(VFS_TID, VFS_TID, L4_IPC_TAG_WRITE)) < 0) {
printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, wrcnt);
return wrcnt;