Errno is set by the posix calls read/write/open/close etc. rather than their l4_xxx equivalent.

mmap.c is the only one not done yet.
This commit is contained in:
Bahadir Balban
2008-02-12 19:17:19 +00:00
parent 193430d226
commit 7f9380cc78
4 changed files with 49 additions and 19 deletions

View File

@@ -20,15 +20,14 @@ static inline off_t l4_lseek(int fildes, off_t offset, int whence)
write_mr(L4SYS_ARG2, whence);
/* Call pager with shmget() request. Check ipc error. */
if ((errno = l4_sendrecv(VFS_TID, VFS_TID, L4_IPC_TAG_LSEEK)) < 0) {
printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, errno);
return -1;
if ((offres = l4_sendrecv(VFS_TID, VFS_TID, L4_IPC_TAG_LSEEK)) < 0) {
printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, offres);
return offres;
}
/* Check if syscall itself was successful */
if ((offres = l4_get_retval()) < 0) {
printf("%s: OPEN Error: %d.\n", __FUNCTION__, (int)offres);
errno = (int)offres;
return -1;
return offres;
}
return offres;
@@ -36,6 +35,15 @@ static inline off_t l4_lseek(int fildes, off_t offset, int whence)
off_t lseek(int fildes, off_t offset, int whence)
{
return l4_lseek(fildes, offset, whence);
int ret = l4_lseek(fildes, offset, whence);
/* If error, return positive error code */
if (ret < 0) {
errno = -ret;
return -1;
}
/* else return value */
return ret;
}

View File

@@ -12,6 +12,11 @@
#include <l4lib/arch/syslib.h>
#include <l4lib/ipcdefs.h>
/* FIXME: Implement the same separation that is in read.c write.c etc. such that
* l4_syscall returns negative value and then the actual posix glue sets the errno
* rather than the l4_syscall sets it itself
*/
struct mmap_descriptor {
void *start;
size_t length;

View File

@@ -23,22 +23,21 @@ static inline int l4_open(const char *pathname, int flags, mode_t mode)
write_mr(L4SYS_ARG2, (u32)mode);
/* Call pager with shmget() request. Check ipc error. */
if ((errno = l4_sendrecv(VFS_TID, VFS_TID, L4_IPC_TAG_OPEN)) < 0) {
printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, errno);
return -1;
if ((fd = l4_sendrecv(VFS_TID, VFS_TID, L4_IPC_TAG_OPEN)) < 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: OPEN Error: %d.\n", __FUNCTION__, fd);
errno = fd;
return -1;
return fd;
}
return fd;
}
int open(const char *pathname, int oflag, ...)
{
int ret;
mode_t mode = 0;
if (oflag & O_CREAT) {
@@ -47,6 +46,15 @@ int open(const char *pathname, int oflag, ...)
mode = va_arg(arg, mode_t);
va_end(arg);
}
return l4_open(pathname, oflag, mode);
ret = l4_open(pathname, oflag, mode);
/* If error, return positive error code */
if (ret < 0) {
errno = -ret;
return -1;
}
/* else return value */
return ret;
}

View File

@@ -20,15 +20,14 @@ static inline int l4_write(int fd, const void *buf, size_t count)
write_mr(L4SYS_ARG2, count);
/* Call pager with shmget() request. Check ipc error. */
if ((errno = l4_sendrecv(VFS_TID, VFS_TID, L4_IPC_TAG_WRITE)) < 0) {
printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, errno);
return -1;
if ((wrcnt = l4_sendrecv(VFS_TID, VFS_TID, L4_IPC_TAG_WRITE)) < 0) {
printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, wrcnt);
return wrcnt;
}
/* Check if syscall itself was successful */
if ((wrcnt = l4_get_retval()) < 0) {
printf("%s: WRITE Error: %d.\n", __FUNCTION__, (int)wrcnt);
errno = (int)wrcnt;
return -1;
return wrcnt;
}
return wrcnt;
@@ -36,9 +35,19 @@ static inline int l4_write(int fd, const void *buf, size_t count)
ssize_t write(int fd, const void *buf, size_t count)
{
int ret;
if (!count)
return 0;
return l4_write(fd, buf, count);
ret = l4_write(fd, buf, count);
/* If error, return positive error code */
if (ret < 0) {
errno = -ret;
return -1;
}
/* else return value */
return ret;
}