Added an extended ipc return library function.

This commit is contained in:
Bahadir Balban
2009-10-08 15:35:54 +03:00
parent cb561ab262
commit 72c6ca1ed0
9 changed files with 112 additions and 36 deletions
-2
View File
@@ -24,8 +24,6 @@ static inline int l4_chdir(const char *pathname)
utcb_full_strcpy_from(pathname);
write_mr(L4SYS_ARG0, (unsigned long)utcb_full_buffer());
/* Call pager with shmget() request. Check ipc error. */
if ((fd = l4_sendrecv_full(VFS_TID, VFS_TID, L4_IPC_TAG_CHDIR)) < 0) {
print_err("%s: L4 IPC Error: %d.\n", __FUNCTION__, fd);
+1 -2
View File
@@ -26,8 +26,7 @@ static inline int l4_mkdir(const char *pathname, mode_t mode)
// write_mr(L4SYS_ARG0, (unsigned long)pathname);
utcb_full_strcpy_from(pathname);
write_mr(L4SYS_ARG0, (unsigned long)utcb_full_buffer());
write_mr(L4SYS_ARG1, (u32)mode);
write_mr(L4SYS_ARG0, (u32)mode);
/* Call pager with shmget() request. Check ipc error. */
if ((fd = l4_sendrecv_full(PAGER_TID, PAGER_TID, L4_IPC_TAG_MKDIR)) < 0) {
+33 -2
View File
@@ -15,7 +15,7 @@
#include <l4lib/os/posix/readdir.h>
#include <l4/macros.h>
#include INC_GLUE(memory.h)
#include <shpage.h>
#include INC_GLUE(message.h)
#include <libposix.h>
/*
@@ -29,6 +29,37 @@
* Or do it just like read()
*/
static inline int l4_readdir(int fd, void *buf, size_t count)
{
int cnt, err;
write_mr(L4SYS_ARG0, fd);
write_mr(L4SYS_ARG1, count);
/* Call pager with readdir() request. Check ipc error. */
if ((err = l4_send(PAGER_TID, L4_IPC_TAG_READDIR)) < 0) {
print_err("%s: L4 IPC Error: %d.\n", __FUNCTION__, err);
return err;
}
/* Call pager with readdir() request. Check ipc error. */
if ((err = l4_receive_extended(PAGER_TID,
L4_IPC_EXTENDED_MAX_SIZE,
buf)) < 0) {
print_err("%s: L4 Extended IPC error: %d.\n", __FUNCTION__, err);
return err;
}
/* Check if syscall itself was successful */
if ((cnt = l4_get_retval()) < 0) {
print_err("%s: READDIR Error: %d.\n", __FUNCTION__, (int)cnt);
return cnt;
}
return cnt;
}
#if 0
static inline int l4_readdir(int fd, void *buf, size_t count)
{
int cnt;
@@ -50,7 +81,7 @@ static inline int l4_readdir(int fd, void *buf, size_t count)
return cnt;
}
#endif
static inline int l4_read(int fd, void *buf, size_t count)
{
int cnt;
+1 -1
View File
@@ -38,7 +38,7 @@ void sys_exit(struct tcb *task, int status);
/* Posix calls */
int sys_open(struct tcb *sender, const char *pathname, int flags, u32 mode);
int sys_readdir(struct tcb *sender, int fd, void *buf, int count);
int sys_readdir(struct tcb *sender, int fd, int count, char *dirbuf);
int sys_mkdir(struct tcb *sender, const char *pathname, unsigned int mode);
int sys_chdir(struct tcb *sender, const char *pathname);
+14 -8
View File
@@ -148,26 +148,32 @@ void handle_requests(void)
ret = sys_execve(sender, (char *)mr[0],
(char **)mr[1], (char **)mr[2]);
if (ret < 0)
break; /* We origy for errors */
break; /* We reply for errors */
else
return; /* else we're done */
}
/* FIXME: Fix all these syscalls to read any buffer data from the caller task's utcb. */
/*
* FIXME: Fix all these syscalls to read any
* buffer data from the caller task's utcb.
*/
/* FS0 System calls */
case L4_IPC_TAG_OPEN:
ret = sys_open(sender, utcb_full_buffer(), (int)mr[0], (unsigned int)mr[1]);
break;
case L4_IPC_TAG_MKDIR:
ret = sys_mkdir(sender, (const char *)mr[0], (unsigned int)mr[1]);
ret = sys_mkdir(sender, utcb_full_buffer(), (unsigned int)mr[0]);
break;
case L4_IPC_TAG_CHDIR:
ret = sys_chdir(sender, (const char *)mr[0]);
ret = sys_chdir(sender, utcb_full_buffer());
break;
case L4_IPC_TAG_READDIR:
ret = sys_readdir(sender, (int)mr[0], (void *)mr[1], (int)mr[2]);
break;
case L4_IPC_TAG_READDIR: {
char dirbuf[L4_IPC_EXTENDED_MAX_SIZE];
ret = sys_readdir(sender, (int)mr[0], (int)mr[1], dirbuf);
l4_return_extended(ret, L4_IPC_EXTENDED_MAX_SIZE, dirbuf, ret < 0);
return;
}
default:
printf("%s: Unrecognised ipc tag (%d) "
"received from (%d). Full mr reading: "
+9 -2
View File
@@ -31,6 +31,8 @@
#include <path.h>
#include <syscalls.h>
#include INC_GLUE(message.h)
/* Copy from one page's buffer into another page */
int page_copy(struct page *dst, struct page *src,
unsigned long dst_offset, unsigned long src_offset,
@@ -1173,17 +1175,22 @@ int fill_dirent(void *buf, unsigned long vnum, int offset, char *name)
*
* FIXME: Ensure buf is in shared utcb, and count does not exceed it.
*/
int sys_readdir(struct tcb *t, int fd, void *buf, int count)
int sys_readdir(struct tcb *t, int fd, int count, char *dirbuf)
{
int dirent_size = sizeof(struct dirent);
int total = 0, nbytes = 0;
unsigned long vnum;
struct vnode *v;
struct dentry *d;
char *buf = dirbuf;
// printf("%s/%s\n", __TASKNAME__, __FUNCTION__);
BUG(); /* Do this by extended ipc !!! */
/*
* FIXME:
* Add dirbuf overflow checking
*/
/* Check address is in task's utcb */
if (fd < 0 || fd > TASK_FILES_MAX || !t->files->fd[fd].vnum)