diff options
Diffstat (limited to 'arch/sandbox/cpu/os.c')
-rw-r--r-- | arch/sandbox/cpu/os.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index da96ebe43c9..f5c9a8aecf2 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -47,12 +47,24 @@ struct os_mem_hdr { ssize_t os_read(int fd, void *buf, size_t count) { - return read(fd, buf, count); + ssize_t ret; + + ret = read(fd, buf, count); + if (ret == -1) + return -errno; + + return ret; } ssize_t os_write(int fd, const void *buf, size_t count) { - return write(fd, buf, count); + ssize_t ret; + + ret = write(fd, buf, count); + if (ret == -1) + return -errno; + + return ret; } int os_printf(const char *fmt, ...) @@ -69,6 +81,8 @@ int os_printf(const char *fmt, ...) off_t os_lseek(int fd, off_t offset, int whence) { + off_t ret; + if (whence == OS_SEEK_SET) whence = SEEK_SET; else if (whence == OS_SEEK_CUR) @@ -77,7 +91,11 @@ off_t os_lseek(int fd, off_t offset, int whence) whence = SEEK_END; else os_exit(1); - return lseek(fd, offset, whence); + ret = lseek(fd, offset, whence); + if (ret == -1) + return -errno; + + return ret; } int os_open(const char *pathname, int os_flags) |