Changeset 0d0b319 in mainline


Ignore:
Timestamp:
2018-01-04T20:03:02Z (6 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:
3c7702c0
Parents:
10de842
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-01-04 19:18:29)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-01-04 20:03:02)
Message:

Flip error constants to positive values, and update libposix for the change.

Files:
2 deleted
24 edited

Legend:

Unmodified
Added
Removed
  • abi/include/abi/errno.h

    r10de842 r0d0b319  
    11/* Generated file. Edit errno.in instead. */
    22#define EOK             __errno_t(      0)
    3 #define ENOENT          __errno_t(     -1)
    4 #define ENOMEM          __errno_t(     -2)
    5 #define ELIMIT          __errno_t(     -3)
    6 #define EREFUSED        __errno_t(     -4)
    7 #define EFORWARD        __errno_t(     -5)
    8 #define EPERM           __errno_t(     -6)
    9 #define EHANGUP         __errno_t(     -7)
    10 #define EPARTY          __errno_t(     -8)
    11 #define EEXIST          __errno_t(     -9)
    12 #define EBADMEM         __errno_t(    -10)
    13 #define ENOTSUP         __errno_t(    -11)
    14 #define EADDRNOTAVAIL   __errno_t(    -12)
    15 #define ETIMEOUT        __errno_t(    -13)
    16 #define EINVAL          __errno_t(    -14)
    17 #define EBUSY           __errno_t(    -15)
    18 #define EOVERFLOW       __errno_t(    -16)
    19 #define EINTR           __errno_t(    -17)
    20 #define EMFILE          __errno_t(    -18)
    21 #define ENAMETOOLONG    __errno_t(   -256)
    22 #define EISDIR          __errno_t(   -257)
    23 #define ENOTDIR         __errno_t(   -258)
    24 #define ENOSPC          __errno_t(   -259)
    25 #define ENOTEMPTY       __errno_t(   -261)
    26 #define EBADF           __errno_t(   -262)
    27 #define EDOM            __errno_t(   -263)
    28 #define ERANGE          __errno_t(   -264)
    29 #define EXDEV           __errno_t(   -265)
    30 #define EIO             __errno_t(   -266)
    31 #define EMLINK          __errno_t(   -267)
    32 #define ENXIO           __errno_t(   -268)
    33 #define ENOFS           __errno_t(   -269)
    34 #define EBADCHECKSUM    __errno_t(   -300)
    35 #define ESTALL          __errno_t(   -301)
    36 #define EEMPTY          __errno_t(   -302)
    37 #define ENAK            __errno_t(   -303)
    38 #define EAGAIN          __errno_t( -11002)
     3#define ENOENT          __errno_t(      1)
     4#define ENOMEM          __errno_t(      2)
     5#define ELIMIT          __errno_t(      3)
     6#define EREFUSED        __errno_t(      4)
     7#define EFORWARD        __errno_t(      5)
     8#define EPERM           __errno_t(      6)
     9#define EHANGUP         __errno_t(      7)
     10#define EPARTY          __errno_t(      8)
     11#define EEXIST          __errno_t(      9)
     12#define EBADMEM         __errno_t(     10)
     13#define ENOTSUP         __errno_t(     11)
     14#define EADDRNOTAVAIL   __errno_t(     12)
     15#define ETIMEOUT        __errno_t(     13)
     16#define EINVAL          __errno_t(     14)
     17#define EBUSY           __errno_t(     15)
     18#define EOVERFLOW       __errno_t(     16)
     19#define EINTR           __errno_t(     17)
     20#define EMFILE          __errno_t(     18)
     21#define ENAMETOOLONG    __errno_t(     19)
     22#define EISDIR          __errno_t(     20)
     23#define ENOTDIR         __errno_t(     21)
     24#define ENOSPC          __errno_t(     22)
     25#define ENOTEMPTY       __errno_t(     23)
     26#define EBADF           __errno_t(     24)
     27#define EDOM            __errno_t(     25)
     28#define ERANGE          __errno_t(     26)
     29#define EXDEV           __errno_t(     27)
     30#define EIO             __errno_t(     28)
     31#define EMLINK          __errno_t(     29)
     32#define ENXIO           __errno_t(     30)
     33#define ENOFS           __errno_t(     31)
     34#define EBADCHECKSUM    __errno_t(     32)
     35#define ESTALL          __errno_t(     33)
     36#define EEMPTY          __errno_t(     34)
     37#define ENAK            __errno_t(     35)
     38#define EAGAIN          __errno_t(     36)
    3939
    40 #define HTTP_EMULTIPLE_HEADERS  __errno_t( -20001)
    41 #define HTTP_EMISSING_HEADER    __errno_t( -20002)
    42 #define HTTP_EPARSE             __errno_t( -20003)
     40/* libhttp error codes. Defining them here is a temporary hack. */
    4341
    44 #define EXT4_ERR_BAD_DX_DIR     __errno_t( -75000)
     42#define HTTP_EMULTIPLE_HEADERS  __errno_t(  50)
     43#define HTTP_EMISSING_HEADER    __errno_t(  51)
     44#define HTTP_EPARSE             __errno_t(  52)
     45
     46/* libext4 error codes. Same as above. */
     47
     48#define EXT4_ERR_BAD_DX_DIR     __errno_t(  60)
     49
     50
     51/* POSIX error codes + whatever nonstandard names crop up in third-party
     52 * software. These are not used in HelenOS code, but are defined here in
     53 * order to avoid nasty hacks in libposix.
     54 *
     55 * If you decide to use one of these in native HelenOS code,
     56 * move it up to the first group.
     57 */
     58
     59#define E2BIG             __errno_t(  101)
     60#define EACCES            __errno_t(  102)
     61#define EADDRINUSE        __errno_t(  103)
     62#define EAFNOSUPPORT      __errno_t(  105)
     63#define EALREADY          __errno_t(  107)
     64#define EBADMSG           __errno_t(  109)
     65#define ECANCELED         __errno_t(  111)
     66#define ECHILD            __errno_t(  112)
     67#define ECONNABORTED      __errno_t(  113)
     68#define ECONNREFUSED      __errno_t(  114)
     69#define ECONNRESET        __errno_t(  115)
     70#define EDEADLK           __errno_t(  116)
     71#define EDESTADDRREQ      __errno_t(  117)
     72#define EDQUOT            __errno_t(  119)
     73#define EFAULT            __errno_t(  121)
     74#define EFBIG             __errno_t(  122)
     75#define EHOSTUNREACH      __errno_t(  123)
     76#define EIDRM             __errno_t(  124)
     77#define EILSEQ            __errno_t(  125)
     78#define EINPROGRESS       __errno_t(  126)
     79#define EISCONN           __errno_t(  130)
     80#define ELOOP             __errno_t(  132)
     81#define EMSGSIZE          __errno_t(  135)
     82#define EMULTIHOP         __errno_t(  136)
     83#define ENETDOWN          __errno_t(  138)
     84#define ENETRESET         __errno_t(  139)
     85#define ENETUNREACH       __errno_t(  140)
     86#define ENFILE            __errno_t(  141)
     87#define ENOBUFS           __errno_t(  142)
     88#define ENODATA           __errno_t(  143)
     89#define ENODEV            __errno_t(  144)
     90#define ENOEXEC           __errno_t(  146)
     91#define ENOLCK            __errno_t(  147)
     92#define ENOLINK           __errno_t(  148)
     93#define ENOMSG            __errno_t(  150)
     94#define ENOPROTOOPT       __errno_t(  151)
     95#define ENOSR             __errno_t(  153)
     96#define ENOSTR            __errno_t(  154)
     97#define ENOSYS            __errno_t(  155)
     98#define ENOTCONN          __errno_t(  156)
     99#define ENOTRECOVERABLE   __errno_t(  159)
     100#define ENOTSOCK          __errno_t(  160)
     101#define ENOTTY            __errno_t(  162)
     102#define EOPNOTSUPP        __errno_t(  164)
     103#define EOWNERDEAD        __errno_t(  166)
     104#define EPIPE             __errno_t(  168)
     105#define EPROTO            __errno_t(  169)
     106#define EPROTONOSUPPORT   __errno_t(  170)
     107#define EPROTOTYPE        __errno_t(  171)
     108#define EROFS             __errno_t(  173)
     109#define ESPIPE            __errno_t(  174)
     110#define ESRCH             __errno_t(  175)
     111#define ESTALE            __errno_t(  176)
     112#define ETIME             __errno_t(  177)
     113#define ETIMEDOUT         __errno_t(  178)
     114#define ETXTBSY           __errno_t(  179)
     115#define EWOULDBLOCK       __errno_t(  180)
  • abi/include/abi/errno.in

    r10de842 r0d0b319  
    11__errno_entry(EOK            ,      0, "No error")
    2 __errno_entry(ENOENT         ,     -1, "No such entry")
    3 __errno_entry(ENOMEM         ,     -2, "Not enough memory")
    4 __errno_entry(ELIMIT         ,     -3, "Limit exceeded")
    5 __errno_entry(EREFUSED       ,     -4, "Connection refused")
    6 __errno_entry(EFORWARD       ,     -5, "Forwarding error")
    7 __errno_entry(EPERM          ,     -6, "Permission denied")
    8 __errno_entry(EHANGUP        ,     -7, "Answerbox closed connection")
    9 __errno_entry(EPARTY         ,     -8, "Other party encountered an error")
    10 __errno_entry(EEXIST         ,     -9, "Entry already exists")
    11 __errno_entry(EBADMEM        ,    -10, "Bad memory pointer")
    12 __errno_entry(ENOTSUP        ,    -11, "Operation not supported")
    13 __errno_entry(EADDRNOTAVAIL  ,    -12, "Address not available")
    14 __errno_entry(ETIMEOUT       ,    -13, "Timeout expired")
    15 __errno_entry(EINVAL         ,    -14, "Invalid value")
    16 __errno_entry(EBUSY          ,    -15, "Resource is busy")
    17 __errno_entry(EOVERFLOW      ,    -16, "Result does not fit its size")
    18 __errno_entry(EINTR          ,    -17, "Operation interrupted")
    19 __errno_entry(EMFILE         ,    -18, "Too many open files")
    20 __errno_entry(ENAMETOOLONG   ,   -256, "Name is too long")
    21 __errno_entry(EISDIR         ,   -257, "Entry is a directory")
    22 __errno_entry(ENOTDIR        ,   -258, "Entry is not a directory")
    23 __errno_entry(ENOSPC         ,   -259, "No space left")
    24 __errno_entry(ENOTEMPTY      ,   -261, "Directory is not empty")
    25 __errno_entry(EBADF          ,   -262, "Bad object handle")
    26 __errno_entry(EDOM           ,   -263, "Domain error")
    27 __errno_entry(ERANGE         ,   -264, "Value out of range")
    28 __errno_entry(EXDEV          ,   -265, "Prohibited cross-device link")
    29 __errno_entry(EIO            ,   -266, "Input/output error")
    30 __errno_entry(EMLINK         ,   -267, "Too many links")
    31 __errno_entry(ENXIO          ,   -268, "Device or address does not exist")
    32 __errno_entry(ENOFS          ,   -269, "No such file system type")
    33 __errno_entry(EBADCHECKSUM   ,   -300, "Bad checksum")
    34 __errno_entry(ESTALL         ,   -301, "USB: Operation stalled")
    35 __errno_entry(EEMPTY         ,   -302, "Resource is empty")
    36 __errno_entry(ENAK           ,   -303, "Negative acknowledgement")
    37 __errno_entry(EAGAIN         , -11002, "Operation could not proceed, try again")
     2__errno_entry(ENOENT         ,      1, "No such entry")
     3__errno_entry(ENOMEM         ,      2, "Not enough memory")
     4__errno_entry(ELIMIT         ,      3, "Limit exceeded")
     5__errno_entry(EREFUSED       ,      4, "Connection refused")
     6__errno_entry(EFORWARD       ,      5, "Forwarding error")
     7__errno_entry(EPERM          ,      6, "Permission denied")
     8__errno_entry(EHANGUP        ,      7, "Answerbox closed connection")
     9__errno_entry(EPARTY         ,      8, "Other party encountered an error")
     10__errno_entry(EEXIST         ,      9, "Entry already exists")
     11__errno_entry(EBADMEM        ,     10, "Bad memory pointer")
     12__errno_entry(ENOTSUP        ,     11, "Operation not supported")
     13__errno_entry(EADDRNOTAVAIL  ,     12, "Address not available")
     14__errno_entry(ETIMEOUT       ,     13, "Timeout expired")
     15__errno_entry(EINVAL         ,     14, "Invalid value")
     16__errno_entry(EBUSY          ,     15, "Resource is busy")
     17__errno_entry(EOVERFLOW      ,     16, "Result does not fit its size")
     18__errno_entry(EINTR          ,     17, "Operation interrupted")
     19__errno_entry(EMFILE         ,     18, "Too many open files")
     20__errno_entry(ENAMETOOLONG   ,     19, "Name is too long")
     21__errno_entry(EISDIR         ,     20, "Entry is a directory")
     22__errno_entry(ENOTDIR        ,     21, "Entry is not a directory")
     23__errno_entry(ENOSPC         ,     22, "No space left")
     24__errno_entry(ENOTEMPTY      ,     23, "Directory is not empty")
     25__errno_entry(EBADF          ,     24, "Bad object handle")
     26__errno_entry(EDOM           ,     25, "Mathematics argument out of domain of function")
     27__errno_entry(ERANGE         ,     26, "Value out of range")
     28__errno_entry(EXDEV          ,     27, "Prohibited cross-device link")
     29__errno_entry(EIO            ,     28, "Input/output error")
     30__errno_entry(EMLINK         ,     29, "Too many links")
     31__errno_entry(ENXIO          ,     30, "Device or address does not exist")
     32__errno_entry(ENOFS          ,     31, "No such file system type")
     33__errno_entry(EBADCHECKSUM   ,     32, "Bad checksum")
     34__errno_entry(ESTALL         ,     33, "USB: Operation stalled")
     35__errno_entry(EEMPTY         ,     34, "Resource is empty")
     36__errno_entry(ENAK           ,     35, "Negative acknowledgement")
     37__errno_entry(EAGAIN         ,     36, "Operation could not proceed, try again")
    3838
    39 __errno_entry(HTTP_EMULTIPLE_HEADERS , -20001, "HTTP: Multiple headers")  // libhttp error codes. Defining them here is a temporary hack.
    40 __errno_entry(HTTP_EMISSING_HEADER   , -20002, "HTTP: Missing header")
    41 __errno_entry(HTTP_EPARSE            , -20003, "HTTP: Parse error")
     39/* libhttp error codes. Defining them here is a temporary hack. */
    4240
    43 __errno_entry(EXT4_ERR_BAD_DX_DIR    , -75000, "EXT4: Filesystem corrupted")  // libext4
     41__errno_entry(HTTP_EMULTIPLE_HEADERS ,  50, "HTTP: Multiple headers")
     42__errno_entry(HTTP_EMISSING_HEADER   ,  51, "HTTP: Missing header")
     43__errno_entry(HTTP_EPARSE            ,  52, "HTTP: Parse error")
     44
     45/* libext4 error codes. Same as above. */
     46
     47__errno_entry(EXT4_ERR_BAD_DX_DIR    ,  60, "EXT4: Filesystem corrupted")
     48
     49
     50/* POSIX error codes + whatever nonstandard names crop up in third-party
     51 * software. These are not used in HelenOS code, but are defined here in
     52 * order to avoid nasty hacks in libposix.
     53 *
     54 * If you decide to use one of these in native HelenOS code,
     55 * move it up to the first group.
     56 */
     57
     58__errno_entry(E2BIG            ,  101, "Argument list too long")
     59__errno_entry(EACCES           ,  102, "Permission denied")
     60__errno_entry(EADDRINUSE       ,  103, "Address in use")
     61__errno_entry(EAFNOSUPPORT     ,  105, "Address family not supported")
     62__errno_entry(EALREADY         ,  107, "Connection already in progress")
     63__errno_entry(EBADMSG          ,  109, "Bad message")
     64__errno_entry(ECANCELED        ,  111, "Operation canceled")
     65__errno_entry(ECHILD           ,  112, "No child processes")
     66__errno_entry(ECONNABORTED     ,  113, "Connection aborted")
     67__errno_entry(ECONNREFUSED     ,  114, "Connection refused")
     68__errno_entry(ECONNRESET       ,  115, "Connection reset")
     69__errno_entry(EDEADLK          ,  116, "Resource deadlock would occur")
     70__errno_entry(EDESTADDRREQ     ,  117, "Destination address required")
     71__errno_entry(EDQUOT           ,  119, "Reserved")
     72__errno_entry(EFAULT           ,  121, "Bad address")
     73__errno_entry(EFBIG            ,  122, "File too large")
     74__errno_entry(EHOSTUNREACH     ,  123, "Host is unreachable")
     75__errno_entry(EIDRM            ,  124, "Identifier removed")
     76__errno_entry(EILSEQ           ,  125, "Illegal byte sequence")
     77__errno_entry(EINPROGRESS      ,  126, "Operation in progress")
     78__errno_entry(EISCONN          ,  130, "Socket is connected")
     79__errno_entry(ELOOP            ,  132, "Too many levels of symbolic links")
     80__errno_entry(EMSGSIZE         ,  135, "Message too large")
     81__errno_entry(EMULTIHOP        ,  136, "Reserved")
     82__errno_entry(ENETDOWN         ,  138, "Network is down")
     83__errno_entry(ENETRESET        ,  139, "Connection aborted by network")
     84__errno_entry(ENETUNREACH      ,  140, "Network unreachable")
     85__errno_entry(ENFILE           ,  141, "Too many files open in system")
     86__errno_entry(ENOBUFS          ,  142, "No buffer space available")
     87__errno_entry(ENODATA          ,  143, "No message is available on the STREAM head read queue")
     88__errno_entry(ENODEV           ,  144, "No such device")
     89__errno_entry(ENOEXEC          ,  146, "Executable file format error")
     90__errno_entry(ENOLCK           ,  147, "No locks available")
     91__errno_entry(ENOLINK          ,  148, "Reserved")
     92__errno_entry(ENOMSG           ,  150, "No message of the desired type")
     93__errno_entry(ENOPROTOOPT      ,  151, "Protocol not available")
     94__errno_entry(ENOSR            ,  153, "No STREAM resources.")
     95__errno_entry(ENOSTR           ,  154, "Not a STREAM")
     96__errno_entry(ENOSYS           ,  155, "Function not supported")
     97__errno_entry(ENOTCONN         ,  156, "The socket is not connected")
     98__errno_entry(ENOTRECOVERABLE  ,  159, "State not recoverable")
     99__errno_entry(ENOTSOCK         ,  160, "Not a socket")
     100__errno_entry(ENOTTY           ,  162, "Inappropriate I/O control operation")
     101__errno_entry(EOPNOTSUPP       ,  164, "Operation not supported")
     102__errno_entry(EOWNERDEAD       ,  166, "Previous owned died")
     103__errno_entry(EPIPE            ,  168, "Broken pipe")
     104__errno_entry(EPROTO           ,  169, "Protocol error")
     105__errno_entry(EPROTONOSUPPORT  ,  170, "Protocol not supported")
     106__errno_entry(EPROTOTYPE       ,  171, "Protocol wrong type for socket")
     107__errno_entry(EROFS            ,  173, "Read-only file system")
     108__errno_entry(ESPIPE           ,  174, "Invalid seek")
     109__errno_entry(ESRCH            ,  175, "No such process")
     110__errno_entry(ESTALE           ,  176, "Reserved")
     111__errno_entry(ETIME            ,  177, "Stream ioctl() timeout")
     112__errno_entry(ETIMEDOUT        ,  178, "Connection timed out")
     113__errno_entry(ETXTBSY          ,  179, "Text file busy")
     114__errno_entry(EWOULDBLOCK      ,  180, "Operation would block")
  • uspace/lib/c/generic/vfs/vfs.c

    r10de842 r0d0b319  
    566566                return ENOENT;
    567567        }
     568
     569        // XXX: Workaround for GCC diagnostics.
     570        *handle = -1;
    568571
    569572        int rc = vfs_walk(root, p, flags, handle);
  • uspace/lib/posix/Makefile

    r10de842 r0d0b319  
    6363        source/ctype.c \
    6464        source/dlfcn.c \
    65         source/errno.c \
    6665        source/fcntl.c \
    6766        source/fnmatch.c \
  • uspace/lib/posix/include/posix/stdlib.h

    r10de842 r0d0b319  
    4040#define __POSIX_DEF__(x) x
    4141#endif
     42
     43#include "libc/stdlib.h"
    4244
    4345#include "sys/types.h"
  • uspace/lib/posix/source/fcntl.c

    r10de842 r0d0b319  
    4040
    4141#include "libc/vfs/vfs.h"
    42 #include "posix/errno.h"
     42
     43#include <errno.h>
    4344
    4445/**
     
    103104int posix_open(const char *pathname, int posix_flags, ...)
    104105{
    105         int rc;
    106106        posix_mode_t posix_mode = 0;
    107107        if (posix_flags & O_CREAT) {
     
    136136
    137137        int file;
    138         rc = rcerrno(vfs_lookup, pathname, flags, &file);
    139         if (rc != EOK)
     138
     139        if (failed(vfs_lookup(pathname, flags, &file)))
    140140                return -1;
    141141
    142         rc = rcerrno(vfs_open, file, mode);
    143         if (rc != EOK) {
     142        if (failed(vfs_open(file, mode))) {
    144143                vfs_put(file);
    145144                return -1;
     
    148147        if (posix_flags & O_TRUNC) {
    149148                if (posix_flags & (O_RDWR | O_WRONLY)) {
    150                         rc = rcerrno(vfs_resize, file, 0);
    151                         if (rc != EOK) {
     149                        if (failed(vfs_resize(file, 0))) {
    152150                                vfs_put(file);
    153151                                return -1;
  • uspace/lib/posix/source/internal/common.h

    r10de842 r0d0b319  
    5050        } while (0)
    5151
    52 /* Convert negative errno to positive errno */
    53 #define negerrno(func, ...) ({ \
    54         int rc = func(__VA_ARGS__); \
    55         if (rc < 0) { \
    56                 errno = -errno; \
    57         } \
    58         rc; \
    59 })
    60 
    61 /* Convert error code to positive errno and -1 return value */
    62 #define rcerrno(func, ...) ({ \
    63         int rc = func(__VA_ARGS__); \
    64         if (rc < 0) \
    65                 errno = -rc; \
    66         rc; \
    67 })
     52/* Checks if the value is a failing error code.
     53 * If so, writes the error code to errno and returns true.
     54 */
     55static inline bool failed(int rc) {
     56        if (rc != EOK) {
     57                errno = rc;
     58                return true;
     59        }
     60        return false;
     61}
    6862
    6963extern aoff64_t posix_pos[MAX_OPEN_FILES];
  • uspace/lib/posix/source/locale.c

    r10de842 r0d0b319  
    3939#include "posix/locale.h"
    4040
    41 #include "posix/errno.h"
     41#include <errno.h>
     42
    4243#include "posix/limits.h"
    4344#include "posix/string.h"
  • uspace/lib/posix/source/pthread/keys.c

    r10de842 r0d0b319  
    3838#include "posix/stdlib.h"
    3939#include "posix/pthread.h"
    40 #include "errno.h"
     40#include <errno.h>
    4141#include "../internal/common.h"
    4242
  • uspace/lib/posix/source/pthread/mutex.c

    r10de842 r0d0b319  
    3737
    3838#include "posix/pthread.h"
    39 #include "errno.h"
     39#include <errno.h>
    4040#include "../internal/common.h"
    4141
  • uspace/lib/posix/source/pwd.c

    r10de842 r0d0b319  
    3939#include "posix/pwd.h"
    4040#include "posix/string.h"
    41 #include "posix/errno.h"
     41#include <errno.h>
    4242#include "posix/assert.h"
    4343
  • uspace/lib/posix/source/signal.c

    r10de842 r0d0b319  
    4141#include "posix/stdlib.h"
    4242#include "posix/string.h"
    43 #include "posix/errno.h"
     43
     44#include <errno.h>
    4445
    4546#include "libc/fibril_synch.h"
  • uspace/lib/posix/source/stdio.c

    r10de842 r0d0b319  
    4141
    4242#include "posix/assert.h"
    43 #include "posix/errno.h"
     43
     44#include <errno.h>
     45
    4446#include "posix/stdlib.h"
    4547#include "posix/string.h"
     
    313315int posix_fflush(FILE *stream)
    314316{
    315         return negerrno(fflush, stream);
     317        return fflush(stream);
    316318}
    317319
     
    344346        const int fildes = *(int *) fd;
    345347        size_t wr;
    346         int rc = vfs_write(fildes, &posix_pos[fildes], str, size, &wr);
    347         if (rc != EOK)
    348                 return rc;
     348        if (failed(vfs_write(fildes, &posix_pos[fildes], str, size, &wr)))
     349                return -1;
    349350        return str_nlength(str, wr);
    350351}
     
    576577int posix_remove(const char *path)
    577578{
    578         if (rcerrno(vfs_unlink_path, path) != EOK)
     579        if (failed(vfs_unlink_path(path)))
    579580                return -1;
    580581        else
     
    591592int posix_rename(const char *old, const char *new)
    592593{
    593         int rc = rcerrno(vfs_rename_path, old, new);
    594         if (rc != EOK)
     594        if (failed(vfs_rename_path(old, new)))
    595595                return -1;
    596596        else
     
    664664               
    665665                int orig_errno = errno;
    666                 errno = 0;
     666                errno = EOK;
    667667                /* Check if the file exists. */
    668668                if (posix_access(result, F_OK) == -1) {
  • uspace/lib/posix/source/stdio/scanf.c

    r10de842 r0d0b319  
    3737
    3838#include "posix/assert.h"
    39 #include "posix/errno.h"
     39
     40#include <errno.h>
    4041
    4142#include "posix/stdio.h"
  • uspace/lib/posix/source/stdlib.c

    r10de842 r0d0b319  
    4040#include "posix/stdlib.h"
    4141
    42 #include "posix/errno.h"
     42#include <errno.h>
     43
    4344#include "posix/fcntl.h"
    4445#include "posix/limits.h"
  • uspace/lib/posix/source/stdlib/strtol.c

    r10de842 r0d0b319  
    4040
    4141#include "posix/ctype.h"
    42 #include "posix/errno.h"
     42
     43#include <errno.h>
     44
    4345#include "posix/inttypes.h"
    4446#include "posix/limits.h"
  • uspace/lib/posix/source/stdlib/strtold.c

    r10de842 r0d0b319  
    4444#include "posix/stdint.h"
    4545#include "posix/strings.h"
    46 #include "posix/errno.h"
     46
     47#include <errno.h>
     48
    4749#include "posix/limits.h"
    4850
  • uspace/lib/posix/source/string.c

    r10de842 r0d0b319  
    4141
    4242#include "posix/assert.h"
    43 #include "posix/errno.h"
     43
     44#include <errno.h>
     45
    4446#include "posix/limits.h"
    4547#include "posix/stdlib.h"
     
    615617char *posix_strerror(int errnum)
    616618{
    617         static const char *error_msgs[] = {
    618                 [E2BIG] = "[E2BIG] Argument list too long",
    619                 [EACCES] = "[EACCES] Permission denied",
    620                 [EADDRINUSE] = "[EADDRINUSE] Address in use",
    621                 [EADDRNOTAVAIL] = "[EADDRNOTAVAIL] Address not available",
    622                 [EAFNOSUPPORT] = "[EAFNOSUPPORT] Address family not supported",
    623                 [EAGAIN] = "[EAGAIN] Resource unavailable, try again",
    624                 [EALREADY] = "[EALREADY] Connection already in progress",
    625                 [EBADF] = "[EBADF] Bad file descriptor",
    626                 [EBADMSG] = "[EBADMSG] Bad message",
    627                 [EBUSY] = "[EBUSY] Device or resource busy",
    628                 [ECANCELED] = "[ECANCELED] Operation canceled",
    629                 [ECHILD] = "[ECHILD] No child processes",
    630                 [ECONNABORTED] = "[ECONNABORTED] Connection aborted",
    631                 [ECONNREFUSED] = "[ECONNREFUSED] Connection refused",
    632                 [ECONNRESET] = "[ECONNRESET] Connection reset",
    633                 [EDEADLK] = "[EDEADLK] Resource deadlock would occur",
    634                 [EDESTADDRREQ] = "[EDESTADDRREQ] Destination address required",
    635                 [EDOM] = "[EDOM] Mathematics argument out of domain of function",
    636                 [EDQUOT] = "[EDQUOT] Reserved",
    637                 [EEXIST] = "[EEXIST] File exists",
    638                 [EFAULT] = "[EFAULT] Bad address",
    639                 [EFBIG] = "[EFBIG] File too large",
    640                 [EHOSTUNREACH] = "[EHOSTUNREACH] Host is unreachable",
    641                 [EIDRM] = "[EIDRM] Identifier removed",
    642                 [EILSEQ] = "[EILSEQ] Illegal byte sequence",
    643                 [EINPROGRESS] = "[EINPROGRESS] Operation in progress",
    644                 [EINTR] = "[EINTR] Interrupted function",
    645                 [EINVAL] = "[EINVAL] Invalid argument",
    646                 [EIO] = "[EIO] I/O error",
    647                 [EISCONN] = "[EISCONN] Socket is connected",
    648                 [EISDIR] = "[EISDIR] Is a directory",
    649                 [ELOOP] = "[ELOOP] Too many levels of symbolic links",
    650                 [EMFILE] = "[EMFILE] File descriptor value too large",
    651                 [EMLINK] = "[EMLINK] Too many links",
    652                 [EMSGSIZE] = "[EMSGSIZE] Message too large",
    653                 [EMULTIHOP] = "[EMULTIHOP] Reserved",
    654                 [ENAMETOOLONG] = "[ENAMETOOLONG] Filename too long",
    655                 [ENETDOWN] = "[ENETDOWN] Network is down",
    656                 [ENETRESET] = "[ENETRESET] Connection aborted by network",
    657                 [ENETUNREACH] = "[ENETUNREACH] Network unreachable",
    658                 [ENFILE] = "[ENFILE] Too many files open in system",
    659                 [ENOBUFS] = "[ENOBUFS] No buffer space available",
    660                 [ENODATA] = "[ENODATA] No message is available on the STREAM head read queue",
    661                 [ENODEV] = "[ENODEV] No such device",
    662                 [ENOENT] = "[ENOENT] No such file or directory",
    663                 [ENOEXEC] = "[ENOEXEC] Executable file format error",
    664                 [ENOLCK] = "[ENOLCK] No locks available",
    665                 [ENOLINK] = "[ENOLINK] Reserved",
    666                 [ENOMEM] = "[ENOMEM] Not enough space",
    667                 [ENOMSG] = "[ENOMSG] No message of the desired type",
    668                 [ENOPROTOOPT] = "[ENOPROTOOPT] Protocol not available",
    669                 [ENOSPC] = "[ENOSPC] No space left on device",
    670                 [ENOSR] = "[ENOSR] No STREAM resources.",
    671                 [ENOSTR] = "[ENOSTR] Not a STREAM",
    672                 [ENOSYS] = "[ENOSYS] Function not supported",
    673                 [ENOTCONN] = "[ENOTCONN] The socket is not connected",
    674                 [ENOTDIR] = "[ENOTDIR] Not a directory",
    675                 [ENOTEMPTY] = "[ENOTEMPTY] Directory not empty",
    676                 [ENOTRECOVERABLE] = "[ENOTRECOVERABLE] State not recoverable",
    677                 [ENOTSOCK] = "[ENOTSOCK] Not a socket",
    678                 [ENOTSUP] = "[ENOTSUP] Not supported",
    679                 [ENOTTY] = "[ENOTTY] Inappropriate I/O control operation",
    680                 [ENXIO] = "[ENXIO] No such device or address",
    681                 [EOPNOTSUPP] = "[EOPNOTSUPP] Operation not supported",
    682                 [EOVERFLOW] = "[EOVERFLOW] Value too large to be stored in data type",
    683                 [EOWNERDEAD] = "[EOWNERDEAD] Previous owned died",
    684                 [EPERM] = "[EPERM] Operation not permitted",
    685                 [EPIPE] = "[EPIPE] Broken pipe",
    686                 [EPROTO] = "[EPROTO] Protocol error",
    687                 [EPROTONOSUPPORT] = "[EPROTONOSUPPORT] Protocol not supported",
    688                 [EPROTOTYPE] = "[EPROTOTYPE] Protocol wrong type for socket",
    689                 [ERANGE] = "[ERANGE] Result too large",
    690                 [EROFS] = "[EROFS] Read-only file system",
    691                 [ESPIPE] = "[ESPIPE] Invalid seek",
    692                 [ESRCH] = "[ESRCH] No such process",
    693                 [ESTALE] = "[ESTALE] Reserved",
    694                 [ETIME] = "[ETIME] Stream ioctl() timeout",
    695                 [ETIMEDOUT] = "[ETIMEDOUT] Connection timed out",
    696                 [ETXTBSY] = "[ETXTBSY] Text file busy",
    697                 [EWOULDBLOCK] = "[EWOULDBLOCK] Operation would block",
    698                 [EXDEV] = "[EXDEV] Cross-device link",
    699         };
    700 
    701         return (char *) error_msgs[posix_abs(errnum)];
     619        // FIXME: move strerror() and strerror_r() to libc.
     620        return (char *) str_error(errnum);
    702621}
    703622
     
    722641        }
    723642
    724         return 0;
     643        return EOK;
    725644}
    726645
  • uspace/lib/posix/source/sys/mman.c

    r10de842 r0d0b319  
    5959int posix_munmap(void *start, size_t length)
    6060{
    61         return as_area_destroy(start);
     61        int rc = as_area_destroy(start);
     62        if (rc != EOK) {
     63                errno = rc;
     64                return -1;
     65        }
     66        return 0;
    6267}
    6368
  • uspace/lib/posix/source/sys/stat.c

    r10de842 r0d0b319  
    4141#include "libc/vfs/vfs.h"
    4242
    43 #include "posix/errno.h"
     43#include <errno.h>
    4444#include "libc/mem.h"
    4545
     
    8989{
    9090        struct stat hst;
    91         int rc = rcerrno(vfs_stat, fd, &hst);
    92         if (rc < 0)
     91        if (failed(vfs_stat(fd, &hst)))
    9392                return -1;
    9493        return stat_to_posix(st, &hst);
     
    118117{
    119118        struct stat hst;
    120         int rc = rcerrno(vfs_stat_path, path, &hst);
    121         if (rc < 0)
     119        if (failed(vfs_stat_path(path, &hst)))
    122120                return -1;
    123121        return stat_to_posix(st, &hst);
     
    159157int posix_mkdir(const char *path, posix_mode_t mode)
    160158{
    161         int rc = rcerrno(vfs_link_path, path, KIND_DIRECTORY, NULL);
    162         if (rc != EOK)
     159        if (failed(vfs_link_path(path, KIND_DIRECTORY, NULL)))
    163160                return -1;
    164161        else
  • uspace/lib/posix/source/sys/wait.c

    r10de842 r0d0b319  
    4242#include "libc/task.h"
    4343#include "posix/assert.h"
    44 #include "posix/errno.h"
     44
     45#include <errno.h>
     46
    4547#include "posix/limits.h"
    4648#include "posix/signal.h"
     
    100102        int retval;
    101103       
    102         int rc = task_wait_task_id((task_id_t) pid, &texit, &retval);
    103        
    104         if (rc < 0) {
     104        if (failed(task_wait_task_id((task_id_t) pid, &texit, &retval))) {
    105105                /* Unable to retrieve status. */
    106                 errno = -rc;
    107106                return (posix_pid_t) -1;
    108107        }
  • uspace/lib/posix/source/time.c

    r10de842 r0d0b319  
    4141
    4242#include "posix/ctype.h"
    43 #include "posix/errno.h"
     43
     44#include <errno.h>
     45
    4446#include "posix/signal.h"
    4547#include "posix/assert.h"
     
    100102    struct tm *restrict result)
    101103{
    102         int rc = time_utc2tm(*timer, result);
    103         if (rc != EOK) {
    104                 errno = rc;
     104        if (failed(time_utc2tm(*timer, result))) {
    105105                return NULL;
    106106        }
     
    197197char *posix_ctime_r(const time_t *timer, char *buf)
    198198{
    199         int r = time_local2str(*timer, buf);
    200         if (r != EOK) {
    201                 errno = r;
     199        if (failed(time_local2str(*timer, buf))) {
    202200                return NULL;
    203201        }
  • uspace/lib/posix/source/unistd.c

    r10de842 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
     
    214213{
    215214        size_t nread;
    216         int rc;
    217 
    218         rc = rcerrno(vfs_read, fildes, &posix_pos[fildes], buf, nbyte, &nread);
    219         if (rc != EOK)
     215        if (failed(vfs_read(fildes, &posix_pos[fildes], buf, nbyte, &nread)))
    220216                return -1;
    221217        return (ssize_t) nread;
     
    233229{
    234230        size_t nwr;
    235         int rc;
    236 
    237         rc = rcerrno(vfs_write, fildes, &posix_pos[fildes], buf, nbyte, &nwr);
    238         if (rc != EOK)
     231        if (failed(vfs_write(fildes, &posix_pos[fildes], buf, nbyte, &nwr)))
    239232                return -1;
    240233        return nwr;
     
    253246{
    254247        struct stat st;
    255         int rc;
    256248
    257249        switch (whence) {
     
    263255                break;
    264256        case SEEK_END:
    265                 rc = rcerrno(vfs_stat, fildes, &st);
    266                 if (rc != EOK)
     257                if (failed(vfs_stat(fildes, &st)))
    267258                        return -1;
    268259                posix_pos[fildes] = st.size + offset;
     
    285276int posix_fsync(int fildes)
    286277{
    287         if (rcerrno(vfs_sync, fildes) != EOK)
     278        if (failed(vfs_sync(fildes)))
    288279                return -1;
    289280        else
     
    300291int posix_ftruncate(int fildes, posix_off_t length)
    301292{
    302         if (rcerrno(vfs_resize, fildes, (aoff64_t) length) != EOK)
     293        if (failed(vfs_resize(fildes, (aoff64_t) length)))
    303294                return -1;
    304295        else
     
    314305int posix_rmdir(const char *path)
    315306{
    316         if (rcerrno(vfs_unlink_path, path) != EOK)
     307        if (failed(vfs_unlink_path(path)))
    317308                return -1;
    318309        else
     
    328319int posix_unlink(const char *path)
    329320{
    330         if (rcerrno(vfs_unlink_path, path) != EOK)
     321        if (failed(vfs_unlink_path(path)))
    331322                return -1;
    332323        else
     
    356347{
    357348        int file;
    358         int rc = vfs_clone(fildes, fildes2, false, &file);
    359         if (rc != EOK) {
    360                 errno = rc < 0 ? -rc : rc;
     349        if (failed(vfs_clone(fildes, fildes2, false, &file))) {
    361350                return -1;
    362351        }
  • uspace/lib/posix/test/scanf.c

    r10de842 r0d0b319  
    3030#define __POSIX_DEF__(x) posix_##x
    3131
    32 #include "posix/errno.h"
     32#include <errno.h>
     33
    3334#include "posix/stdio.h"
    3435
Note: See TracChangeset for help on using the changeset viewer.