Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/posix/source/unistd.c

    r1165a419 r0d0b319  
    4040#include "posix/unistd.h"
    4141
    42 #include "posix/errno.h"
     42#include <errno.h>
     43
    4344#include "posix/string.h"
    4445#include "posix/fcntl.h"
     
    5253#include <libarch/config.h>
    5354
     55// FIXME: replace with a hash table
    5456aoff64_t posix_pos[MAX_OPEN_FILES];
    5557
     
    126128char *posix_getcwd(char *buf, size_t size)
    127129{
    128         int rc = rcerrno(vfs_cwd_get, buf, size);
    129         if (rc != EOK)
     130        if (failed(vfs_cwd_get(buf, size)))
    130131                return NULL;
    131132        return buf;
     
    139140int posix_chdir(const char *path)
    140141{
    141         int rc = rcerrno(vfs_cwd_set, path);
    142         if (rc != EOK)
     142        if (failed(vfs_cwd_set(path)))
    143143                return -1;
    144144        return 0;
     
    196196{
    197197        posix_pos[fildes] = 0;
    198         int rc = rcerrno(vfs_put, fildes);
    199         if (rc != EOK)
     198        if (failed(vfs_put(fildes)))
    200199                return -1;
    201200        else
     
    213212ssize_t posix_read(int fildes, void *buf, size_t nbyte)
    214213{
    215         ssize_t size = rcerrno(vfs_read, fildes, &posix_pos[fildes], buf, nbyte);
    216         if (size < 0)
    217                 return -1;
    218         return size;
     214        size_t nread;
     215        if (failed(vfs_read(fildes, &posix_pos[fildes], buf, nbyte, &nread)))
     216                return -1;
     217        return (ssize_t) nread;
    219218}
    220219
     
    229228ssize_t posix_write(int fildes, const void *buf, size_t nbyte)
    230229{
    231         ssize_t size = rcerrno(vfs_write, fildes, &posix_pos[fildes], buf, nbyte);
    232         if (size < 0)
    233                 return -1;
    234         return size;
     230        size_t nwr;
     231        if (failed(vfs_write(fildes, &posix_pos[fildes], buf, nbyte, &nwr)))
     232                return -1;
     233        return nwr;
    235234}
    236235
     
    247246{
    248247        struct stat st;
    249         int rc;
    250248
    251249        switch (whence) {
     
    257255                break;
    258256        case SEEK_END:
    259                 rc = rcerrno(vfs_stat, fildes, &st);
    260                 if (rc != EOK)
     257                if (failed(vfs_stat(fildes, &st)))
    261258                        return -1;
    262259                posix_pos[fildes] = st.size + offset;
     
    279276int posix_fsync(int fildes)
    280277{
    281         if (rcerrno(vfs_sync, fildes) != EOK)
     278        if (failed(vfs_sync(fildes)))
    282279                return -1;
    283280        else
     
    294291int posix_ftruncate(int fildes, posix_off_t length)
    295292{
    296         if (rcerrno(vfs_resize, fildes, (aoff64_t) length) != EOK)
     293        if (failed(vfs_resize(fildes, (aoff64_t) length)))
    297294                return -1;
    298295        else
     
    308305int posix_rmdir(const char *path)
    309306{
    310         if (rcerrno(vfs_unlink_path, path) != EOK)
     307        if (failed(vfs_unlink_path(path)))
    311308                return -1;
    312309        else
     
    322319int posix_unlink(const char *path)
    323320{
    324         if (rcerrno(vfs_unlink_path, path) != EOK)
     321        if (failed(vfs_unlink_path(path)))
    325322                return -1;
    326323        else
     
    349346int posix_dup2(int fildes, int fildes2)
    350347{
    351         return negerrno(vfs_clone, fildes, fildes2, false);
     348        int file;
     349        if (failed(vfs_clone(fildes, fildes2, false, &file))) {
     350                return -1;
     351        }
     352        return file;
    352353}
    353354
Note: See TracChangeset for help on using the changeset viewer.