Changeset ec18957a in mainline for uspace/lib/posix/unistd.c


Ignore:
Timestamp:
2011-07-08T00:54:24Z (13 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9c1984f
Parents:
3f466c33
Message:

Added errno.h (see commentary inside).

File:
1 edited

Legend:

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

    r3f466c33 rec18957a  
    3838#include "internal/common.h"
    3939#include "unistd.h"
    40 #include <task.h>
    41 #include <errno.h>
     40
     41#include "errno.h"
    4242#include "string.h"
    4343#include "fcntl.h"
    44 #include <stats.h>
     44
     45#include "libc/task.h"
     46#include "libc/stats.h"
    4547#include "libc/malloc.h"
    4648
     
    145147                /* Check file existence by attempt to open it. */
    146148                int fd = open(path, O_RDONLY);
    147                 // TODO: propagate a POSIX compatible errno
    148                 int rc = fd < 0 ? -1 : 0;
    149                 close(fd);
    150                 return rc;
     149                if (fd < 0) {
     150                        /* FIXME: open() returns error code as negative retval. */
     151                        errno = -fd;
     152                        fd = -1;
     153                } else {
     154                        close(fd);
     155                }
     156                return fd;
    151157        } else if (amode & (X_OK | W_OK | R_OK)) {
    152158                /* HelenOS doesn't support permissions, return success. */
Note: See TracChangeset for help on using the changeset viewer.