Index: abi/include/abi/errno.h
===================================================================
--- abi/include/abi/errno.h	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
+++ abi/include/abi/errno.h	(revision 0d0b3197a149bb5e5c53d21136df5b8c283cdc4a)
@@ -1,44 +1,115 @@
 /* Generated file. Edit errno.in instead. */
 #define EOK             __errno_t(      0)
-#define ENOENT          __errno_t(     -1)
-#define ENOMEM          __errno_t(     -2)
-#define ELIMIT          __errno_t(     -3)
-#define EREFUSED        __errno_t(     -4)
-#define EFORWARD        __errno_t(     -5)
-#define EPERM           __errno_t(     -6)
-#define EHANGUP         __errno_t(     -7)
-#define EPARTY          __errno_t(     -8)
-#define EEXIST          __errno_t(     -9)
-#define EBADMEM         __errno_t(    -10)
-#define ENOTSUP         __errno_t(    -11)
-#define EADDRNOTAVAIL   __errno_t(    -12)
-#define ETIMEOUT        __errno_t(    -13)
-#define EINVAL          __errno_t(    -14)
-#define EBUSY           __errno_t(    -15)
-#define EOVERFLOW       __errno_t(    -16)
-#define EINTR           __errno_t(    -17)
-#define EMFILE          __errno_t(    -18)
-#define ENAMETOOLONG    __errno_t(   -256)
-#define EISDIR          __errno_t(   -257)
-#define ENOTDIR         __errno_t(   -258)
-#define ENOSPC          __errno_t(   -259)
-#define ENOTEMPTY       __errno_t(   -261)
-#define EBADF           __errno_t(   -262)
-#define EDOM            __errno_t(   -263)
-#define ERANGE          __errno_t(   -264)
-#define EXDEV           __errno_t(   -265)
-#define EIO             __errno_t(   -266)
-#define EMLINK          __errno_t(   -267)
-#define ENXIO           __errno_t(   -268)
-#define ENOFS           __errno_t(   -269)
-#define EBADCHECKSUM    __errno_t(   -300)
-#define ESTALL          __errno_t(   -301)
-#define EEMPTY          __errno_t(   -302)
-#define ENAK            __errno_t(   -303)
-#define EAGAIN          __errno_t( -11002)
+#define ENOENT          __errno_t(      1)
+#define ENOMEM          __errno_t(      2)
+#define ELIMIT          __errno_t(      3)
+#define EREFUSED        __errno_t(      4)
+#define EFORWARD        __errno_t(      5)
+#define EPERM           __errno_t(      6)
+#define EHANGUP         __errno_t(      7)
+#define EPARTY          __errno_t(      8)
+#define EEXIST          __errno_t(      9)
+#define EBADMEM         __errno_t(     10)
+#define ENOTSUP         __errno_t(     11)
+#define EADDRNOTAVAIL   __errno_t(     12)
+#define ETIMEOUT        __errno_t(     13)
+#define EINVAL          __errno_t(     14)
+#define EBUSY           __errno_t(     15)
+#define EOVERFLOW       __errno_t(     16)
+#define EINTR           __errno_t(     17)
+#define EMFILE          __errno_t(     18)
+#define ENAMETOOLONG    __errno_t(     19)
+#define EISDIR          __errno_t(     20)
+#define ENOTDIR         __errno_t(     21)
+#define ENOSPC          __errno_t(     22)
+#define ENOTEMPTY       __errno_t(     23)
+#define EBADF           __errno_t(     24)
+#define EDOM            __errno_t(     25)
+#define ERANGE          __errno_t(     26)
+#define EXDEV           __errno_t(     27)
+#define EIO             __errno_t(     28)
+#define EMLINK          __errno_t(     29)
+#define ENXIO           __errno_t(     30)
+#define ENOFS           __errno_t(     31)
+#define EBADCHECKSUM    __errno_t(     32)
+#define ESTALL          __errno_t(     33)
+#define EEMPTY          __errno_t(     34)
+#define ENAK            __errno_t(     35)
+#define EAGAIN          __errno_t(     36)
 
-#define HTTP_EMULTIPLE_HEADERS  __errno_t( -20001)
-#define HTTP_EMISSING_HEADER    __errno_t( -20002)
-#define HTTP_EPARSE             __errno_t( -20003)
+/* libhttp error codes. Defining them here is a temporary hack. */
 
-#define EXT4_ERR_BAD_DX_DIR     __errno_t( -75000)
+#define HTTP_EMULTIPLE_HEADERS  __errno_t(  50)
+#define HTTP_EMISSING_HEADER    __errno_t(  51)
+#define HTTP_EPARSE             __errno_t(  52)
+
+/* libext4 error codes. Same as above. */
+
+#define EXT4_ERR_BAD_DX_DIR     __errno_t(  60)
+
+
+/* POSIX error codes + whatever nonstandard names crop up in third-party
+ * software. These are not used in HelenOS code, but are defined here in
+ * order to avoid nasty hacks in libposix.
+ *
+ * If you decide to use one of these in native HelenOS code,
+ * move it up to the first group.
+ */
+
+#define E2BIG             __errno_t(  101)
+#define EACCES            __errno_t(  102)
+#define EADDRINUSE        __errno_t(  103)
+#define EAFNOSUPPORT      __errno_t(  105)
+#define EALREADY          __errno_t(  107)
+#define EBADMSG           __errno_t(  109)
+#define ECANCELED         __errno_t(  111)
+#define ECHILD            __errno_t(  112)
+#define ECONNABORTED      __errno_t(  113)
+#define ECONNREFUSED      __errno_t(  114)
+#define ECONNRESET        __errno_t(  115)
+#define EDEADLK           __errno_t(  116)
+#define EDESTADDRREQ      __errno_t(  117)
+#define EDQUOT            __errno_t(  119)
+#define EFAULT            __errno_t(  121)
+#define EFBIG             __errno_t(  122)
+#define EHOSTUNREACH      __errno_t(  123)
+#define EIDRM             __errno_t(  124)
+#define EILSEQ            __errno_t(  125)
+#define EINPROGRESS       __errno_t(  126)
+#define EISCONN           __errno_t(  130)
+#define ELOOP             __errno_t(  132)
+#define EMSGSIZE          __errno_t(  135)
+#define EMULTIHOP         __errno_t(  136)
+#define ENETDOWN          __errno_t(  138)
+#define ENETRESET         __errno_t(  139)
+#define ENETUNREACH       __errno_t(  140)
+#define ENFILE            __errno_t(  141)
+#define ENOBUFS           __errno_t(  142)
+#define ENODATA           __errno_t(  143)
+#define ENODEV            __errno_t(  144)
+#define ENOEXEC           __errno_t(  146)
+#define ENOLCK            __errno_t(  147)
+#define ENOLINK           __errno_t(  148)
+#define ENOMSG            __errno_t(  150)
+#define ENOPROTOOPT       __errno_t(  151)
+#define ENOSR             __errno_t(  153)
+#define ENOSTR            __errno_t(  154)
+#define ENOSYS            __errno_t(  155)
+#define ENOTCONN          __errno_t(  156)
+#define ENOTRECOVERABLE   __errno_t(  159)
+#define ENOTSOCK          __errno_t(  160)
+#define ENOTTY            __errno_t(  162)
+#define EOPNOTSUPP        __errno_t(  164)
+#define EOWNERDEAD        __errno_t(  166)
+#define EPIPE             __errno_t(  168)
+#define EPROTO            __errno_t(  169)
+#define EPROTONOSUPPORT   __errno_t(  170)
+#define EPROTOTYPE        __errno_t(  171)
+#define EROFS             __errno_t(  173)
+#define ESPIPE            __errno_t(  174)
+#define ESRCH             __errno_t(  175)
+#define ESTALE            __errno_t(  176)
+#define ETIME             __errno_t(  177)
+#define ETIMEDOUT         __errno_t(  178)
+#define ETXTBSY           __errno_t(  179)
+#define EWOULDBLOCK       __errno_t(  180)
Index: abi/include/abi/errno.in
===================================================================
--- abi/include/abi/errno.in	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
+++ abi/include/abi/errno.in	(revision 0d0b3197a149bb5e5c53d21136df5b8c283cdc4a)
@@ -1,43 +1,114 @@
 __errno_entry(EOK            ,      0, "No error")
-__errno_entry(ENOENT         ,     -1, "No such entry")
-__errno_entry(ENOMEM         ,     -2, "Not enough memory")
-__errno_entry(ELIMIT         ,     -3, "Limit exceeded")
-__errno_entry(EREFUSED       ,     -4, "Connection refused")
-__errno_entry(EFORWARD       ,     -5, "Forwarding error")
-__errno_entry(EPERM          ,     -6, "Permission denied")
-__errno_entry(EHANGUP        ,     -7, "Answerbox closed connection")
-__errno_entry(EPARTY         ,     -8, "Other party encountered an error")
-__errno_entry(EEXIST         ,     -9, "Entry already exists")
-__errno_entry(EBADMEM        ,    -10, "Bad memory pointer")
-__errno_entry(ENOTSUP        ,    -11, "Operation not supported")
-__errno_entry(EADDRNOTAVAIL  ,    -12, "Address not available")
-__errno_entry(ETIMEOUT       ,    -13, "Timeout expired")
-__errno_entry(EINVAL         ,    -14, "Invalid value")
-__errno_entry(EBUSY          ,    -15, "Resource is busy")
-__errno_entry(EOVERFLOW      ,    -16, "Result does not fit its size")
-__errno_entry(EINTR          ,    -17, "Operation interrupted")
-__errno_entry(EMFILE         ,    -18, "Too many open files")
-__errno_entry(ENAMETOOLONG   ,   -256, "Name is too long")
-__errno_entry(EISDIR         ,   -257, "Entry is a directory")
-__errno_entry(ENOTDIR        ,   -258, "Entry is not a directory")
-__errno_entry(ENOSPC         ,   -259, "No space left")
-__errno_entry(ENOTEMPTY      ,   -261, "Directory is not empty")
-__errno_entry(EBADF          ,   -262, "Bad object handle")
-__errno_entry(EDOM           ,   -263, "Domain error")
-__errno_entry(ERANGE         ,   -264, "Value out of range")
-__errno_entry(EXDEV          ,   -265, "Prohibited cross-device link")
-__errno_entry(EIO            ,   -266, "Input/output error")
-__errno_entry(EMLINK         ,   -267, "Too many links")
-__errno_entry(ENXIO          ,   -268, "Device or address does not exist")
-__errno_entry(ENOFS          ,   -269, "No such file system type")
-__errno_entry(EBADCHECKSUM   ,   -300, "Bad checksum")
-__errno_entry(ESTALL         ,   -301, "USB: Operation stalled")
-__errno_entry(EEMPTY         ,   -302, "Resource is empty")
-__errno_entry(ENAK           ,   -303, "Negative acknowledgement")
-__errno_entry(EAGAIN         , -11002, "Operation could not proceed, try again")
+__errno_entry(ENOENT         ,      1, "No such entry")
+__errno_entry(ENOMEM         ,      2, "Not enough memory")
+__errno_entry(ELIMIT         ,      3, "Limit exceeded")
+__errno_entry(EREFUSED       ,      4, "Connection refused")
+__errno_entry(EFORWARD       ,      5, "Forwarding error")
+__errno_entry(EPERM          ,      6, "Permission denied")
+__errno_entry(EHANGUP        ,      7, "Answerbox closed connection")
+__errno_entry(EPARTY         ,      8, "Other party encountered an error")
+__errno_entry(EEXIST         ,      9, "Entry already exists")
+__errno_entry(EBADMEM        ,     10, "Bad memory pointer")
+__errno_entry(ENOTSUP        ,     11, "Operation not supported")
+__errno_entry(EADDRNOTAVAIL  ,     12, "Address not available")
+__errno_entry(ETIMEOUT       ,     13, "Timeout expired")
+__errno_entry(EINVAL         ,     14, "Invalid value")
+__errno_entry(EBUSY          ,     15, "Resource is busy")
+__errno_entry(EOVERFLOW      ,     16, "Result does not fit its size")
+__errno_entry(EINTR          ,     17, "Operation interrupted")
+__errno_entry(EMFILE         ,     18, "Too many open files")
+__errno_entry(ENAMETOOLONG   ,     19, "Name is too long")
+__errno_entry(EISDIR         ,     20, "Entry is a directory")
+__errno_entry(ENOTDIR        ,     21, "Entry is not a directory")
+__errno_entry(ENOSPC         ,     22, "No space left")
+__errno_entry(ENOTEMPTY      ,     23, "Directory is not empty")
+__errno_entry(EBADF          ,     24, "Bad object handle")
+__errno_entry(EDOM           ,     25, "Mathematics argument out of domain of function")
+__errno_entry(ERANGE         ,     26, "Value out of range")
+__errno_entry(EXDEV          ,     27, "Prohibited cross-device link")
+__errno_entry(EIO            ,     28, "Input/output error")
+__errno_entry(EMLINK         ,     29, "Too many links")
+__errno_entry(ENXIO          ,     30, "Device or address does not exist")
+__errno_entry(ENOFS          ,     31, "No such file system type")
+__errno_entry(EBADCHECKSUM   ,     32, "Bad checksum")
+__errno_entry(ESTALL         ,     33, "USB: Operation stalled")
+__errno_entry(EEMPTY         ,     34, "Resource is empty")
+__errno_entry(ENAK           ,     35, "Negative acknowledgement")
+__errno_entry(EAGAIN         ,     36, "Operation could not proceed, try again")
 
-__errno_entry(HTTP_EMULTIPLE_HEADERS , -20001, "HTTP: Multiple headers")  // libhttp error codes. Defining them here is a temporary hack.
-__errno_entry(HTTP_EMISSING_HEADER   , -20002, "HTTP: Missing header")
-__errno_entry(HTTP_EPARSE            , -20003, "HTTP: Parse error")
+/* libhttp error codes. Defining them here is a temporary hack. */
 
-__errno_entry(EXT4_ERR_BAD_DX_DIR    , -75000, "EXT4: Filesystem corrupted")  // libext4
+__errno_entry(HTTP_EMULTIPLE_HEADERS ,  50, "HTTP: Multiple headers")
+__errno_entry(HTTP_EMISSING_HEADER   ,  51, "HTTP: Missing header")
+__errno_entry(HTTP_EPARSE            ,  52, "HTTP: Parse error")
+
+/* libext4 error codes. Same as above. */
+
+__errno_entry(EXT4_ERR_BAD_DX_DIR    ,  60, "EXT4: Filesystem corrupted")
+
+
+/* POSIX error codes + whatever nonstandard names crop up in third-party
+ * software. These are not used in HelenOS code, but are defined here in
+ * order to avoid nasty hacks in libposix.
+ *
+ * If you decide to use one of these in native HelenOS code,
+ * move it up to the first group.
+ */
+
+__errno_entry(E2BIG            ,  101, "Argument list too long")
+__errno_entry(EACCES           ,  102, "Permission denied")
+__errno_entry(EADDRINUSE       ,  103, "Address in use")
+__errno_entry(EAFNOSUPPORT     ,  105, "Address family not supported")
+__errno_entry(EALREADY         ,  107, "Connection already in progress")
+__errno_entry(EBADMSG          ,  109, "Bad message")
+__errno_entry(ECANCELED        ,  111, "Operation canceled")
+__errno_entry(ECHILD           ,  112, "No child processes")
+__errno_entry(ECONNABORTED     ,  113, "Connection aborted")
+__errno_entry(ECONNREFUSED     ,  114, "Connection refused")
+__errno_entry(ECONNRESET       ,  115, "Connection reset")
+__errno_entry(EDEADLK          ,  116, "Resource deadlock would occur")
+__errno_entry(EDESTADDRREQ     ,  117, "Destination address required")
+__errno_entry(EDQUOT           ,  119, "Reserved")
+__errno_entry(EFAULT           ,  121, "Bad address")
+__errno_entry(EFBIG            ,  122, "File too large")
+__errno_entry(EHOSTUNREACH     ,  123, "Host is unreachable")
+__errno_entry(EIDRM            ,  124, "Identifier removed")
+__errno_entry(EILSEQ           ,  125, "Illegal byte sequence")
+__errno_entry(EINPROGRESS      ,  126, "Operation in progress")
+__errno_entry(EISCONN          ,  130, "Socket is connected")
+__errno_entry(ELOOP            ,  132, "Too many levels of symbolic links")
+__errno_entry(EMSGSIZE         ,  135, "Message too large")
+__errno_entry(EMULTIHOP        ,  136, "Reserved")
+__errno_entry(ENETDOWN         ,  138, "Network is down")
+__errno_entry(ENETRESET        ,  139, "Connection aborted by network")
+__errno_entry(ENETUNREACH      ,  140, "Network unreachable")
+__errno_entry(ENFILE           ,  141, "Too many files open in system")
+__errno_entry(ENOBUFS          ,  142, "No buffer space available")
+__errno_entry(ENODATA          ,  143, "No message is available on the STREAM head read queue")
+__errno_entry(ENODEV           ,  144, "No such device")
+__errno_entry(ENOEXEC          ,  146, "Executable file format error")
+__errno_entry(ENOLCK           ,  147, "No locks available")
+__errno_entry(ENOLINK          ,  148, "Reserved")
+__errno_entry(ENOMSG           ,  150, "No message of the desired type")
+__errno_entry(ENOPROTOOPT      ,  151, "Protocol not available")
+__errno_entry(ENOSR            ,  153, "No STREAM resources.")
+__errno_entry(ENOSTR           ,  154, "Not a STREAM")
+__errno_entry(ENOSYS           ,  155, "Function not supported")
+__errno_entry(ENOTCONN         ,  156, "The socket is not connected")
+__errno_entry(ENOTRECOVERABLE  ,  159, "State not recoverable")
+__errno_entry(ENOTSOCK         ,  160, "Not a socket")
+__errno_entry(ENOTTY           ,  162, "Inappropriate I/O control operation")
+__errno_entry(EOPNOTSUPP       ,  164, "Operation not supported")
+__errno_entry(EOWNERDEAD       ,  166, "Previous owned died")
+__errno_entry(EPIPE            ,  168, "Broken pipe")
+__errno_entry(EPROTO           ,  169, "Protocol error")
+__errno_entry(EPROTONOSUPPORT  ,  170, "Protocol not supported")
+__errno_entry(EPROTOTYPE       ,  171, "Protocol wrong type for socket")
+__errno_entry(EROFS            ,  173, "Read-only file system")
+__errno_entry(ESPIPE           ,  174, "Invalid seek")
+__errno_entry(ESRCH            ,  175, "No such process")
+__errno_entry(ESTALE           ,  176, "Reserved")
+__errno_entry(ETIME            ,  177, "Stream ioctl() timeout")
+__errno_entry(ETIMEDOUT        ,  178, "Connection timed out")
+__errno_entry(ETXTBSY          ,  179, "Text file busy")
+__errno_entry(EWOULDBLOCK      ,  180, "Operation would block")
Index: uspace/lib/c/generic/vfs/vfs.c
===================================================================
--- uspace/lib/c/generic/vfs/vfs.c	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
+++ uspace/lib/c/generic/vfs/vfs.c	(revision 0d0b3197a149bb5e5c53d21136df5b8c283cdc4a)
@@ -566,4 +566,7 @@
 		return ENOENT;
 	}
+
+	// XXX: Workaround for GCC diagnostics.
+	*handle = -1;
 
 	int rc = vfs_walk(root, p, flags, handle);
Index: uspace/lib/posix/Makefile
===================================================================
--- uspace/lib/posix/Makefile	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
+++ uspace/lib/posix/Makefile	(revision 0d0b3197a149bb5e5c53d21136df5b8c283cdc4a)
@@ -63,5 +63,4 @@
 	source/ctype.c \
 	source/dlfcn.c \
-	source/errno.c \
 	source/fcntl.c \
 	source/fnmatch.c \
Index: pace/lib/posix/include/posix/errno.h
===================================================================
--- uspace/lib/posix/include/posix/errno.h	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
+++ 	(revision )
@@ -1,326 +1,0 @@
-/*
- * Copyright (c) 2011 Jiri Zarevucky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libposix
- * @{
- */
-/** @file System error numbers.
- */
-
-#ifndef POSIX_ERRNO_H_
-#define POSIX_ERRNO_H_
-
-#include "libc/errno.h"
-
-/* IMPORTANT:
- * Since libc uses negative errorcodes, some sort of conversion is necessary to
- * keep POSIX programs and libraries from breaking. This file maps POSIX error
- * codes to absolute values of corresponding libc codes where available, and
- * assigns new code where there is no prior definition in libc.
- *
- * A new errno variable is defined. When accessed, the function first looks at
- * libc errno and iff it is != 0, sets the POSIX errno to absolute value of
- * libc errno. Given that no library function sets errno to 0 and that all
- * POSIX libraries will be used solely by POSIX programs (thus, there only needs
- * to be one way correspondence between errno and posix_errno), this approach
- * should work as expected in most cases and does not require any wrappers for
- * libc routines that would just change errno values.
- *
- * There is no conditioning by LIBPOSIX_INTERNAL for redefinitions of macros.
- * If there is a need to check errno for a value not defined by POSIX, it's
- * necessary to compare errno against abs(ECODE), because there is no
- * redefinition for such error codes.
- *
- * XXX: maybe all HOS error codes should be redefined
- *
- * NOTE: This redefinition is slightly POSIX incompatible, since the
- *  specification requires the macro values to be usable in preprocessing
- *  directives. I don't think that's very important, though.
- */
-
-#undef errno
-#define errno (*__posix_errno())
-
-extern int *__posix_errno(void);
-
-#define __TOP_ERRNO (-EAGAIN)
-
-enum {
-	POSIX_E2BIG = __TOP_ERRNO + 1,
-	POSIX_EACCES = __TOP_ERRNO + 2,
-	POSIX_EADDRNOTAVAIL = -EADDRNOTAVAIL,
-	POSIX_EAGAIN = -EAGAIN,
-	POSIX_EALREADY = __TOP_ERRNO + 3,
-	POSIX_EBADF = -EBADF,
-	POSIX_EBADMSG = __TOP_ERRNO + 4,
-	POSIX_EBUSY = -EBUSY,
-	POSIX_ECANCELED = __TOP_ERRNO + 5,
-	POSIX_ECHILD = __TOP_ERRNO + 6,
-	POSIX_ECONNABORTED = __TOP_ERRNO + 7,
-	POSIX_ECONNREFUSED = __TOP_ERRNO + 8,
-	POSIX_ECONNRESET = __TOP_ERRNO + 9,
-	POSIX_EDEADLK = __TOP_ERRNO + 10,
-	POSIX_EDOM = __TOP_ERRNO + 11,
-	POSIX_EDQUOT = __TOP_ERRNO + 12,
-	POSIX_EEXIST = -EEXIST,
-	POSIX_EFAULT = __TOP_ERRNO + 13,
-	POSIX_EFBIG = __TOP_ERRNO + 14,
-	POSIX_EHOSTUNREACH = __TOP_ERRNO + 15,
-	POSIX_EIDRM = __TOP_ERRNO + 16,
-	POSIX_EILSEQ = __TOP_ERRNO + 17,
-	POSIX_EINTR = -EINTR,
-	POSIX_EINVAL = -EINVAL,
-	POSIX_EIO = -EIO,
-	POSIX_EISCONN = __TOP_ERRNO + 18,
-	POSIX_EISDIR = -EISDIR,
-	POSIX_ELOOP = __TOP_ERRNO + 19,
-	POSIX_EMFILE = -EMFILE,
-	POSIX_EMLINK = -EMLINK,
-	POSIX_EMSGSIZE = __TOP_ERRNO + 20,
-	POSIX_EMULTIHOP = __TOP_ERRNO + 21,
-	POSIX_ENAMETOOLONG = -ENAMETOOLONG,
-	POSIX_ENETDOWN = __TOP_ERRNO + 22,
-	POSIX_ENETRESET = __TOP_ERRNO + 23,
-	POSIX_ENETUNREACH = __TOP_ERRNO + 24,
-	POSIX_ENFILE = __TOP_ERRNO + 25,
-	POSIX_ENOBUFS = __TOP_ERRNO + 26,
-	POSIX_ENODEV = __TOP_ERRNO + 27,
-	POSIX_ENOENT = -ENOENT,
-	POSIX_ENOEXEC = __TOP_ERRNO + 28,
-	POSIX_ENOLCK = __TOP_ERRNO + 29,
-	POSIX_ENOLINK = __TOP_ERRNO + 30,
-	POSIX_ENOMEM = -ENOMEM,
-	POSIX_ENOMSG = __TOP_ERRNO + 31,
-	POSIX_ENOPROTOOPT = __TOP_ERRNO + 32,
-	POSIX_ENOSPC = -ENOSPC,
-	POSIX_ENOSR = __TOP_ERRNO + 33,
-	POSIX_ENOSTR = __TOP_ERRNO + 34,
-	POSIX_ENOSYS = __TOP_ERRNO + 35,
-	POSIX_ENOTDIR = -ENOTDIR,
-	POSIX_ENOTEMPTY = -ENOTEMPTY,
-	POSIX_ENOTRECOVERABLE = __TOP_ERRNO + 36,
-	POSIX_ENOTSUP = -ENOTSUP,
-	POSIX_ENOTTY = __TOP_ERRNO + 37,
-	POSIX_ENXIO = __TOP_ERRNO + 38,
-	POSIX_EOPNOTSUPP = __TOP_ERRNO + 39,
-	POSIX_EOVERFLOW = -EOVERFLOW,
-	POSIX_EOWNERDEAD = __TOP_ERRNO + 40,
-	POSIX_EPERM = -EPERM,
-	POSIX_EPIPE = __TOP_ERRNO + 41,
-	POSIX_EPROTO = __TOP_ERRNO + 42,
-	POSIX_EPROTOTYPE = __TOP_ERRNO + 43,
-	POSIX_ERANGE = -ERANGE,
-	POSIX_EROFS = __TOP_ERRNO + 44,
-	POSIX_ESPIPE = __TOP_ERRNO + 45,
-	POSIX_ESRCH = __TOP_ERRNO + 46,
-	POSIX_ESTALE = __TOP_ERRNO + 47,
-	POSIX_ETIME = __TOP_ERRNO + 48,
-	POSIX_ETIMEDOUT = __TOP_ERRNO + 49,
-	POSIX_ETXTBSY = __TOP_ERRNO + 50,
-	POSIX_EWOULDBLOCK = __TOP_ERRNO + 51,
-	POSIX_EXDEV = -EXDEV,
-	POSIX_EINPROGRESS = __TOP_ERRNO + 52,
-	POSIX_ENOTSOCK = __TOP_ERRNO + 53,
-	POSIX_EDESTADDRREQ = __TOP_ERRNO + 54,
-	POSIX_EPROTONOSUPPORT = __TOP_ERRNO + 55,
-	POSIX_EAFNOSUPPORT = __TOP_ERRNO + 56,
-	POSIX_EADDRINUSE = __TOP_ERRNO + 57,
-	POSIX_ENOTCONN = __TOP_ERRNO + 58,
-	POSIX_ENODATA = __TOP_ERRNO + 59,
-};
-
-#undef __TOP_ERRNO
-
-#undef E2BIG
-#undef EACCES
-#undef EADDRINUSE
-#undef EADDRNOTAVAIL
-#undef EAFNOSUPPORT
-#undef EAGAIN
-#undef EALREADY
-#undef EBADF
-#undef EBADMSG
-#undef EBUSY
-#undef ECANCELED
-#undef ECHILD
-#undef ECONNABORTED
-#undef ECONNREFUSED
-#undef ECONNRESET
-#undef EDEADLK
-#undef EDESTADDRREQ
-#undef EDOM
-#undef EDQUOT
-#undef EEXIST
-#undef EFAULT
-#undef EFBIG
-#undef EHOSTUNREACH
-#undef EIDRM
-#undef EILSEQ
-#undef EINPROGRESS
-#undef EINTR
-#undef EINVAL
-#undef EIO
-#undef EISCONN
-#undef EISDIR
-#undef ELOOP
-#undef EMFILE
-#undef EMLINK
-#undef EMSGSIZE
-#undef EMULTIHOP
-#undef ENAMETOOLONG
-#undef ENETDOWN
-#undef ENETRESET
-#undef ENETUNREACH
-#undef ENFILE
-#undef ENOBUFS
-#undef ENODATA
-#undef ENODEV
-#undef ENOENT
-#undef ENOEXEC
-#undef ENOLCK
-#undef ENOLINK
-#undef ENOMEM
-#undef ENOMSG
-#undef ENOPROTOOPT
-#undef ENOSPC
-#undef ENOSR
-#undef ENOSTR
-#undef ENOSYS
-#undef ENOTCONN
-#undef ENOTDIR
-#undef ENOTEMPTY
-#undef ENOTRECOVERABLE
-#undef ENOTSOCK
-#undef ENOTSUP
-#undef ENOTTY
-#undef ENXIO
-#undef EOPNOTSUPP
-#undef EOVERFLOW
-#undef EOWNERDEAD
-#undef EPERM
-#undef EPIPE
-#undef EPROTO
-#undef EPROTONOSUPPORT
-#undef EPROTOTYPE
-#undef ERANGE
-#undef EROFS
-#undef ESPIPE
-#undef ESRCH
-#undef ESTALE
-#undef ETIME
-#undef ETIMEDOUT
-#undef ETXTBSY
-#undef EWOULDBLOCK
-#undef EXDEV
-
-#define E2BIG POSIX_E2BIG
-#define EACCES POSIX_EACCES
-#define EADDRINUSE POSIX_EADDRINUSE
-#define EADDRNOTAVAIL POSIX_EADDRNOTAVAIL
-#define EAFNOSUPPORT POSIX_EAFNOSUPPORT
-#define EAGAIN POSIX_EAGAIN
-#define EALREADY POSIX_EALREADY
-#define EBADF POSIX_EBADF
-#define EBADMSG POSIX_EBADMSG
-#define EBUSY POSIX_EBUSY
-#define ECANCELED POSIX_ECANCELED
-#define ECHILD POSIX_ECHILD
-#define ECONNABORTED POSIX_ECONNABORTED
-#define ECONNREFUSED POSIX_ECONNREFUSED
-#define ECONNRESET POSIX_ECONNRESET
-#define EDEADLK POSIX_EDEADLK
-#define EDESTADDRREQ POSIX_EDESTADDRREQ
-#define EDOM POSIX_EDOM
-#define EDQUOT POSIX_EDQUOT
-#define EEXIST POSIX_EEXIST
-#define EFAULT POSIX_EFAULT
-#define EFBIG POSIX_EFBIG
-#define EHOSTUNREACH POSIX_EHOSTUNREACH
-#define EIDRM POSIX_EIDRM
-#define EILSEQ POSIX_EILSEQ
-#define EINPROGRESS POSIX_EINPROGRESS
-#define EINTR POSIX_EINTR
-#define EINVAL POSIX_EINVAL
-#define EIO POSIX_EIO
-#define EISCONN POSIX_EISCONN
-#define EISDIR POSIX_EISDIR
-#define ELOOP POSIX_ELOOP
-#define EMFILE POSIX_EMFILE
-#define EMLINK POSIX_EMLINK
-#define EMSGSIZE POSIX_EMSGSIZE
-#define EMULTIHOP POSIX_EMULTIHOP
-#define ENAMETOOLONG POSIX_ENAMETOOLONG
-#define ENETDOWN POSIX_ENETDOWN
-#define ENETRESET POSIX_ENETRESET
-#define ENETUNREACH POSIX_ENETUNREACH
-#define ENFILE POSIX_ENFILE
-#define ENOBUFS POSIX_ENOBUFS
-#define ENODATA POSIX_ENODATA
-#define ENODEV POSIX_ENODEV
-#define ENOENT POSIX_ENOENT
-#define ENOEXEC POSIX_ENOEXEC
-#define ENOLCK POSIX_ENOLCK
-#define ENOLINK POSIX_ENOLINK
-#define ENOMEM POSIX_ENOMEM
-#define ENOMSG POSIX_ENOMSG
-#define ENOPROTOOPT POSIX_ENOPROTOOPT
-#define ENOSPC POSIX_ENOSPC
-#define ENOSR POSIX_ENOSR
-#define ENOSTR POSIX_ENOSTR
-#define ENOSYS POSIX_ENOSYS
-#define ENOTCONN POSIX_ENOTCONN
-#define ENOTDIR POSIX_ENOTDIR
-#define ENOTEMPTY POSIX_ENOTEMPTY
-#define ENOTRECOVERABLE POSIX_ENOTRECOVERABLE
-#define ENOTSOCK POSIX_ENOTSOCK
-#define ENOTSUP POSIX_ENOTSUP
-#define ENOTTY POSIX_ENOTTY
-#define ENXIO POSIX_ENXIO
-#define EOPNOTSUPP POSIX_EOPNOTSUPP
-#define EOVERFLOW POSIX_EOVERFLOW
-#define EOWNERDEAD POSIX_EOWNERDEAD
-#define EPERM POSIX_EPERM
-#define EPIPE POSIX_EPIPE
-#define EPROTO POSIX_EPROTO
-#define EPROTONOSUPPORT POSIX_EPROTONOSUPPORT
-#define EPROTOTYPE POSIX_EPROTOTYPE
-#define ERANGE POSIX_ERANGE
-#define EROFS POSIX_EROFS
-#define ESPIPE POSIX_ESPIPE
-#define ESRCH POSIX_ESRCH
-#define ESTALE POSIX_ESTALE
-#define ETIME POSIX_ETIME
-#define ETIMEDOUT POSIX_ETIMEDOUT
-#define ETXTBSY POSIX_ETXTBSY
-#define EWOULDBLOCK POSIX_EWOULDBLOCK
-#define EXDEV POSIX_EXDEV
-
-#endif /* POSIX_ERRNO_H_ */
-
-/** @}
- */
Index: uspace/lib/posix/include/posix/stdlib.h
===================================================================
--- uspace/lib/posix/include/posix/stdlib.h	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
+++ uspace/lib/posix/include/posix/stdlib.h	(revision 0d0b3197a149bb5e5c53d21136df5b8c283cdc4a)
@@ -40,4 +40,6 @@
 #define __POSIX_DEF__(x) x
 #endif
+
+#include "libc/stdlib.h"
 
 #include "sys/types.h"
Index: pace/lib/posix/source/errno.c
===================================================================
--- uspace/lib/posix/source/errno.c	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
+++ 	(revision )
@@ -1,54 +1,0 @@
-/*
- * Copyright (c) 2011 Jiri Zarevucky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libposix
- * @{
- */
-/** @file System error numbers.
- */
-#define LIBPOSIX_INTERNAL
-#define __POSIX_DEF__(x) posix_##x
-
-#include "posix/errno.h"
-
-#include "posix/stdlib.h"
-#include "libc/fibril.h"
-
-static fibril_local int _posix_errno;
-
-int *__posix_errno(void)
-{
-	if (*__errno() != 0) {
-		_posix_errno = posix_abs(*__errno());
-		*__errno() = 0;
-	}
-	return &_posix_errno;
-}
-
-/** @}
- */
Index: uspace/lib/posix/source/fcntl.c
===================================================================
--- uspace/lib/posix/source/fcntl.c	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
+++ uspace/lib/posix/source/fcntl.c	(revision 0d0b3197a149bb5e5c53d21136df5b8c283cdc4a)
@@ -40,5 +40,6 @@
 
 #include "libc/vfs/vfs.h"
-#include "posix/errno.h"
+
+#include <errno.h>
 
 /**
@@ -103,5 +104,4 @@
 int posix_open(const char *pathname, int posix_flags, ...)
 {
-	int rc;
 	posix_mode_t posix_mode = 0;
 	if (posix_flags & O_CREAT) {
@@ -136,10 +136,9 @@
 
 	int file;
-	rc = rcerrno(vfs_lookup, pathname, flags, &file);
-	if (rc != EOK)
+
+	if (failed(vfs_lookup(pathname, flags, &file)))
 		return -1;
 
-	rc = rcerrno(vfs_open, file, mode);
-	if (rc != EOK) {
+	if (failed(vfs_open(file, mode))) {
 		vfs_put(file);
 		return -1;
@@ -148,6 +147,5 @@
 	if (posix_flags & O_TRUNC) {
 		if (posix_flags & (O_RDWR | O_WRONLY)) {
-			rc = rcerrno(vfs_resize, file, 0);
-			if (rc != EOK) {
+			if (failed(vfs_resize(file, 0))) {
 				vfs_put(file);
 				return -1;
Index: uspace/lib/posix/source/internal/common.h
===================================================================
--- uspace/lib/posix/source/internal/common.h	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
+++ uspace/lib/posix/source/internal/common.h	(revision 0d0b3197a149bb5e5c53d21136df5b8c283cdc4a)
@@ -50,20 +50,14 @@
 	} while (0)
 
-/* Convert negative errno to positive errno */
-#define negerrno(func, ...) ({ \
-	int rc = func(__VA_ARGS__); \
-	if (rc < 0) { \
-		errno = -errno; \
-	} \
-	rc; \
-})
-
-/* Convert error code to positive errno and -1 return value */
-#define rcerrno(func, ...) ({ \
-	int rc = func(__VA_ARGS__); \
-	if (rc < 0) \
-		errno = -rc; \
-	rc; \
-})
+/* Checks if the value is a failing error code.
+ * If so, writes the error code to errno and returns true.
+ */
+static inline bool failed(int rc) {
+	if (rc != EOK) {
+		errno = rc;
+		return true;
+	}
+	return false;
+}
 
 extern aoff64_t posix_pos[MAX_OPEN_FILES];
Index: uspace/lib/posix/source/locale.c
===================================================================
--- uspace/lib/posix/source/locale.c	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
+++ uspace/lib/posix/source/locale.c	(revision 0d0b3197a149bb5e5c53d21136df5b8c283cdc4a)
@@ -39,5 +39,6 @@
 #include "posix/locale.h"
 
-#include "posix/errno.h"
+#include <errno.h>
+
 #include "posix/limits.h"
 #include "posix/string.h"
Index: uspace/lib/posix/source/pthread/keys.c
===================================================================
--- uspace/lib/posix/source/pthread/keys.c	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
+++ uspace/lib/posix/source/pthread/keys.c	(revision 0d0b3197a149bb5e5c53d21136df5b8c283cdc4a)
@@ -38,5 +38,5 @@
 #include "posix/stdlib.h"
 #include "posix/pthread.h"
-#include "errno.h"
+#include <errno.h>
 #include "../internal/common.h"
 
Index: uspace/lib/posix/source/pthread/mutex.c
===================================================================
--- uspace/lib/posix/source/pthread/mutex.c	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
+++ uspace/lib/posix/source/pthread/mutex.c	(revision 0d0b3197a149bb5e5c53d21136df5b8c283cdc4a)
@@ -37,5 +37,5 @@
 
 #include "posix/pthread.h"
-#include "errno.h"
+#include <errno.h>
 #include "../internal/common.h"
 
Index: uspace/lib/posix/source/pwd.c
===================================================================
--- uspace/lib/posix/source/pwd.c	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
+++ uspace/lib/posix/source/pwd.c	(revision 0d0b3197a149bb5e5c53d21136df5b8c283cdc4a)
@@ -39,5 +39,5 @@
 #include "posix/pwd.h"
 #include "posix/string.h"
-#include "posix/errno.h"
+#include <errno.h>
 #include "posix/assert.h"
 
Index: uspace/lib/posix/source/signal.c
===================================================================
--- uspace/lib/posix/source/signal.c	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
+++ uspace/lib/posix/source/signal.c	(revision 0d0b3197a149bb5e5c53d21136df5b8c283cdc4a)
@@ -41,5 +41,6 @@
 #include "posix/stdlib.h"
 #include "posix/string.h"
-#include "posix/errno.h"
+
+#include <errno.h>
 
 #include "libc/fibril_synch.h"
Index: uspace/lib/posix/source/stdio.c
===================================================================
--- uspace/lib/posix/source/stdio.c	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
+++ uspace/lib/posix/source/stdio.c	(revision 0d0b3197a149bb5e5c53d21136df5b8c283cdc4a)
@@ -41,5 +41,7 @@
 
 #include "posix/assert.h"
-#include "posix/errno.h"
+
+#include <errno.h>
+
 #include "posix/stdlib.h"
 #include "posix/string.h"
@@ -313,5 +315,5 @@
 int posix_fflush(FILE *stream)
 {
-	return negerrno(fflush, stream);
+	return fflush(stream);
 }
 
@@ -344,7 +346,6 @@
 	const int fildes = *(int *) fd;
 	size_t wr;
-	int rc = vfs_write(fildes, &posix_pos[fildes], str, size, &wr);
-	if (rc != EOK)
-		return rc;
+	if (failed(vfs_write(fildes, &posix_pos[fildes], str, size, &wr)))
+		return -1;
 	return str_nlength(str, wr);
 }
@@ -576,5 +577,5 @@
 int posix_remove(const char *path)
 {
-	if (rcerrno(vfs_unlink_path, path) != EOK)
+	if (failed(vfs_unlink_path(path)))
 		return -1;
 	else
@@ -591,6 +592,5 @@
 int posix_rename(const char *old, const char *new)
 {
-	int rc = rcerrno(vfs_rename_path, old, new);
-	if (rc != EOK)
+	if (failed(vfs_rename_path(old, new)))
 		return -1;
 	else
@@ -664,5 +664,5 @@
 		
 		int orig_errno = errno;
-		errno = 0;
+		errno = EOK;
 		/* Check if the file exists. */
 		if (posix_access(result, F_OK) == -1) {
Index: uspace/lib/posix/source/stdio/scanf.c
===================================================================
--- uspace/lib/posix/source/stdio/scanf.c	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
+++ uspace/lib/posix/source/stdio/scanf.c	(revision 0d0b3197a149bb5e5c53d21136df5b8c283cdc4a)
@@ -37,5 +37,6 @@
 
 #include "posix/assert.h"
-#include "posix/errno.h"
+
+#include <errno.h>
 
 #include "posix/stdio.h"
Index: uspace/lib/posix/source/stdlib.c
===================================================================
--- uspace/lib/posix/source/stdlib.c	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
+++ uspace/lib/posix/source/stdlib.c	(revision 0d0b3197a149bb5e5c53d21136df5b8c283cdc4a)
@@ -40,5 +40,6 @@
 #include "posix/stdlib.h"
 
-#include "posix/errno.h"
+#include <errno.h>
+
 #include "posix/fcntl.h"
 #include "posix/limits.h"
Index: uspace/lib/posix/source/stdlib/strtol.c
===================================================================
--- uspace/lib/posix/source/stdlib/strtol.c	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
+++ uspace/lib/posix/source/stdlib/strtol.c	(revision 0d0b3197a149bb5e5c53d21136df5b8c283cdc4a)
@@ -40,5 +40,7 @@
 
 #include "posix/ctype.h"
-#include "posix/errno.h"
+
+#include <errno.h>
+
 #include "posix/inttypes.h"
 #include "posix/limits.h"
Index: uspace/lib/posix/source/stdlib/strtold.c
===================================================================
--- uspace/lib/posix/source/stdlib/strtold.c	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
+++ uspace/lib/posix/source/stdlib/strtold.c	(revision 0d0b3197a149bb5e5c53d21136df5b8c283cdc4a)
@@ -44,5 +44,7 @@
 #include "posix/stdint.h"
 #include "posix/strings.h"
-#include "posix/errno.h"
+
+#include <errno.h>
+
 #include "posix/limits.h"
 
Index: uspace/lib/posix/source/string.c
===================================================================
--- uspace/lib/posix/source/string.c	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
+++ uspace/lib/posix/source/string.c	(revision 0d0b3197a149bb5e5c53d21136df5b8c283cdc4a)
@@ -41,5 +41,7 @@
 
 #include "posix/assert.h"
-#include "posix/errno.h"
+
+#include <errno.h>
+
 #include "posix/limits.h"
 #include "posix/stdlib.h"
@@ -615,89 +617,6 @@
 char *posix_strerror(int errnum)
 {
-	static const char *error_msgs[] = {
-		[E2BIG] = "[E2BIG] Argument list too long",
-		[EACCES] = "[EACCES] Permission denied",
-		[EADDRINUSE] = "[EADDRINUSE] Address in use",
-		[EADDRNOTAVAIL] = "[EADDRNOTAVAIL] Address not available",
-		[EAFNOSUPPORT] = "[EAFNOSUPPORT] Address family not supported",
-		[EAGAIN] = "[EAGAIN] Resource unavailable, try again",
-		[EALREADY] = "[EALREADY] Connection already in progress",
-		[EBADF] = "[EBADF] Bad file descriptor",
-		[EBADMSG] = "[EBADMSG] Bad message",
-		[EBUSY] = "[EBUSY] Device or resource busy",
-		[ECANCELED] = "[ECANCELED] Operation canceled",
-		[ECHILD] = "[ECHILD] No child processes",
-		[ECONNABORTED] = "[ECONNABORTED] Connection aborted",
-		[ECONNREFUSED] = "[ECONNREFUSED] Connection refused",
-		[ECONNRESET] = "[ECONNRESET] Connection reset",
-		[EDEADLK] = "[EDEADLK] Resource deadlock would occur",
-		[EDESTADDRREQ] = "[EDESTADDRREQ] Destination address required",
-		[EDOM] = "[EDOM] Mathematics argument out of domain of function",
-		[EDQUOT] = "[EDQUOT] Reserved",
-		[EEXIST] = "[EEXIST] File exists",
-		[EFAULT] = "[EFAULT] Bad address",
-		[EFBIG] = "[EFBIG] File too large",
-		[EHOSTUNREACH] = "[EHOSTUNREACH] Host is unreachable",
-		[EIDRM] = "[EIDRM] Identifier removed",
-		[EILSEQ] = "[EILSEQ] Illegal byte sequence",
-		[EINPROGRESS] = "[EINPROGRESS] Operation in progress",
-		[EINTR] = "[EINTR] Interrupted function",
-		[EINVAL] = "[EINVAL] Invalid argument",
-		[EIO] = "[EIO] I/O error",
-		[EISCONN] = "[EISCONN] Socket is connected",
-		[EISDIR] = "[EISDIR] Is a directory",
-		[ELOOP] = "[ELOOP] Too many levels of symbolic links",
-		[EMFILE] = "[EMFILE] File descriptor value too large",
-		[EMLINK] = "[EMLINK] Too many links",
-		[EMSGSIZE] = "[EMSGSIZE] Message too large",
-		[EMULTIHOP] = "[EMULTIHOP] Reserved",
-		[ENAMETOOLONG] = "[ENAMETOOLONG] Filename too long",
-		[ENETDOWN] = "[ENETDOWN] Network is down",
-		[ENETRESET] = "[ENETRESET] Connection aborted by network",
-		[ENETUNREACH] = "[ENETUNREACH] Network unreachable",
-		[ENFILE] = "[ENFILE] Too many files open in system",
-		[ENOBUFS] = "[ENOBUFS] No buffer space available",
-		[ENODATA] = "[ENODATA] No message is available on the STREAM head read queue",
-		[ENODEV] = "[ENODEV] No such device",
-		[ENOENT] = "[ENOENT] No such file or directory",
-		[ENOEXEC] = "[ENOEXEC] Executable file format error",
-		[ENOLCK] = "[ENOLCK] No locks available",
-		[ENOLINK] = "[ENOLINK] Reserved",
-		[ENOMEM] = "[ENOMEM] Not enough space",
-		[ENOMSG] = "[ENOMSG] No message of the desired type",
-		[ENOPROTOOPT] = "[ENOPROTOOPT] Protocol not available",
-		[ENOSPC] = "[ENOSPC] No space left on device",
-		[ENOSR] = "[ENOSR] No STREAM resources.",
-		[ENOSTR] = "[ENOSTR] Not a STREAM",
-		[ENOSYS] = "[ENOSYS] Function not supported",
-		[ENOTCONN] = "[ENOTCONN] The socket is not connected",
-		[ENOTDIR] = "[ENOTDIR] Not a directory",
-		[ENOTEMPTY] = "[ENOTEMPTY] Directory not empty",
-		[ENOTRECOVERABLE] = "[ENOTRECOVERABLE] State not recoverable",
-		[ENOTSOCK] = "[ENOTSOCK] Not a socket",
-		[ENOTSUP] = "[ENOTSUP] Not supported",
-		[ENOTTY] = "[ENOTTY] Inappropriate I/O control operation",
-		[ENXIO] = "[ENXIO] No such device or address",
-		[EOPNOTSUPP] = "[EOPNOTSUPP] Operation not supported",
-		[EOVERFLOW] = "[EOVERFLOW] Value too large to be stored in data type",
-		[EOWNERDEAD] = "[EOWNERDEAD] Previous owned died",
-		[EPERM] = "[EPERM] Operation not permitted",
-		[EPIPE] = "[EPIPE] Broken pipe",
-		[EPROTO] = "[EPROTO] Protocol error",
-		[EPROTONOSUPPORT] = "[EPROTONOSUPPORT] Protocol not supported",
-		[EPROTOTYPE] = "[EPROTOTYPE] Protocol wrong type for socket",
-		[ERANGE] = "[ERANGE] Result too large",
-		[EROFS] = "[EROFS] Read-only file system",
-		[ESPIPE] = "[ESPIPE] Invalid seek",
-		[ESRCH] = "[ESRCH] No such process",
-		[ESTALE] = "[ESTALE] Reserved",
-		[ETIME] = "[ETIME] Stream ioctl() timeout",
-		[ETIMEDOUT] = "[ETIMEDOUT] Connection timed out",
-		[ETXTBSY] = "[ETXTBSY] Text file busy",
-		[EWOULDBLOCK] = "[EWOULDBLOCK] Operation would block",
-		[EXDEV] = "[EXDEV] Cross-device link",
-	};
-
-	return (char *) error_msgs[posix_abs(errnum)];
+	// FIXME: move strerror() and strerror_r() to libc.
+	return (char *) str_error(errnum);
 }
 
@@ -722,5 +641,5 @@
 	}
 
-	return 0;
+	return EOK;
 }
 
Index: uspace/lib/posix/source/sys/mman.c
===================================================================
--- uspace/lib/posix/source/sys/mman.c	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
+++ uspace/lib/posix/source/sys/mman.c	(revision 0d0b3197a149bb5e5c53d21136df5b8c283cdc4a)
@@ -59,5 +59,10 @@
 int posix_munmap(void *start, size_t length)
 {
-	return as_area_destroy(start);
+	int rc = as_area_destroy(start);
+	if (rc != EOK) {
+		errno = rc;
+		return -1;
+	}
+	return 0;
 }
 
Index: uspace/lib/posix/source/sys/stat.c
===================================================================
--- uspace/lib/posix/source/sys/stat.c	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
+++ uspace/lib/posix/source/sys/stat.c	(revision 0d0b3197a149bb5e5c53d21136df5b8c283cdc4a)
@@ -41,5 +41,5 @@
 #include "libc/vfs/vfs.h"
 
-#include "posix/errno.h"
+#include <errno.h>
 #include "libc/mem.h"
 
@@ -89,6 +89,5 @@
 {
 	struct stat hst;
-	int rc = rcerrno(vfs_stat, fd, &hst);
-	if (rc < 0)
+	if (failed(vfs_stat(fd, &hst)))
 		return -1;
 	return stat_to_posix(st, &hst);
@@ -118,6 +117,5 @@
 {
 	struct stat hst;
-	int rc = rcerrno(vfs_stat_path, path, &hst);
-	if (rc < 0)
+	if (failed(vfs_stat_path(path, &hst)))
 		return -1;
 	return stat_to_posix(st, &hst);
@@ -159,6 +157,5 @@
 int posix_mkdir(const char *path, posix_mode_t mode)
 {
-	int rc = rcerrno(vfs_link_path, path, KIND_DIRECTORY, NULL);
-	if (rc != EOK)
+	if (failed(vfs_link_path(path, KIND_DIRECTORY, NULL)))
 		return -1;
 	else
Index: uspace/lib/posix/source/sys/wait.c
===================================================================
--- uspace/lib/posix/source/sys/wait.c	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
+++ uspace/lib/posix/source/sys/wait.c	(revision 0d0b3197a149bb5e5c53d21136df5b8c283cdc4a)
@@ -42,5 +42,7 @@
 #include "libc/task.h"
 #include "posix/assert.h"
-#include "posix/errno.h"
+
+#include <errno.h>
+
 #include "posix/limits.h"
 #include "posix/signal.h"
@@ -100,9 +102,6 @@
 	int retval;
 	
-	int rc = task_wait_task_id((task_id_t) pid, &texit, &retval);
-	
-	if (rc < 0) {
+	if (failed(task_wait_task_id((task_id_t) pid, &texit, &retval))) {
 		/* Unable to retrieve status. */
-		errno = -rc;
 		return (posix_pid_t) -1;
 	}
Index: uspace/lib/posix/source/time.c
===================================================================
--- uspace/lib/posix/source/time.c	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
+++ uspace/lib/posix/source/time.c	(revision 0d0b3197a149bb5e5c53d21136df5b8c283cdc4a)
@@ -41,5 +41,7 @@
 
 #include "posix/ctype.h"
-#include "posix/errno.h"
+
+#include <errno.h>
+
 #include "posix/signal.h"
 #include "posix/assert.h"
@@ -100,7 +102,5 @@
     struct tm *restrict result)
 {
-	int rc = time_utc2tm(*timer, result);
-	if (rc != EOK) {
-		errno = rc;
+	if (failed(time_utc2tm(*timer, result))) {
 		return NULL;
 	}
@@ -197,7 +197,5 @@
 char *posix_ctime_r(const time_t *timer, char *buf)
 {
-	int r = time_local2str(*timer, buf);
-	if (r != EOK) {
-		errno = r;
+	if (failed(time_local2str(*timer, buf))) {
 		return NULL;
 	}
Index: uspace/lib/posix/source/unistd.c
===================================================================
--- uspace/lib/posix/source/unistd.c	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
+++ uspace/lib/posix/source/unistd.c	(revision 0d0b3197a149bb5e5c53d21136df5b8c283cdc4a)
@@ -40,5 +40,6 @@
 #include "posix/unistd.h"
 
-#include "posix/errno.h"
+#include <errno.h>
+
 #include "posix/string.h"
 #include "posix/fcntl.h"
@@ -52,4 +53,5 @@
 #include <libarch/config.h>
 
+// FIXME: replace with a hash table
 aoff64_t posix_pos[MAX_OPEN_FILES];
 
@@ -126,6 +128,5 @@
 char *posix_getcwd(char *buf, size_t size)
 {
-	int rc = rcerrno(vfs_cwd_get, buf, size);
-	if (rc != EOK) 
+	if (failed(vfs_cwd_get(buf, size))) 
 		return NULL;
 	return buf;
@@ -139,6 +140,5 @@
 int posix_chdir(const char *path)
 {
-	int rc = rcerrno(vfs_cwd_set, path);
-	if (rc != EOK)
+	if (failed(vfs_cwd_set(path)))
 		return -1;
 	return 0;
@@ -196,6 +196,5 @@
 {
 	posix_pos[fildes] = 0;
-	int rc = rcerrno(vfs_put, fildes);
-	if (rc != EOK)
+	if (failed(vfs_put(fildes)))
 		return -1;
 	else
@@ -214,8 +213,5 @@
 {
 	size_t nread;
-	int rc;
-
-	rc = rcerrno(vfs_read, fildes, &posix_pos[fildes], buf, nbyte, &nread);
-	if (rc != EOK)
+	if (failed(vfs_read(fildes, &posix_pos[fildes], buf, nbyte, &nread)))
 		return -1;
 	return (ssize_t) nread;
@@ -233,8 +229,5 @@
 {
 	size_t nwr;
-	int rc;
-
-	rc = rcerrno(vfs_write, fildes, &posix_pos[fildes], buf, nbyte, &nwr);
-	if (rc != EOK)
+	if (failed(vfs_write(fildes, &posix_pos[fildes], buf, nbyte, &nwr)))
 		return -1;
 	return nwr;
@@ -253,5 +246,4 @@
 {
 	struct stat st;
-	int rc;
 
 	switch (whence) {
@@ -263,6 +255,5 @@
 		break;
 	case SEEK_END:
-		rc = rcerrno(vfs_stat, fildes, &st);
-		if (rc != EOK)
+		if (failed(vfs_stat(fildes, &st)))
 			return -1;
 		posix_pos[fildes] = st.size + offset;
@@ -285,5 +276,5 @@
 int posix_fsync(int fildes)
 {
-	if (rcerrno(vfs_sync, fildes) != EOK)
+	if (failed(vfs_sync(fildes)))
 		return -1;
 	else
@@ -300,5 +291,5 @@
 int posix_ftruncate(int fildes, posix_off_t length)
 {
-	if (rcerrno(vfs_resize, fildes, (aoff64_t) length) != EOK)
+	if (failed(vfs_resize(fildes, (aoff64_t) length)))
 		return -1;
 	else
@@ -314,5 +305,5 @@
 int posix_rmdir(const char *path)
 {
-	if (rcerrno(vfs_unlink_path, path) != EOK)
+	if (failed(vfs_unlink_path(path)))
 		return -1;
 	else
@@ -328,5 +319,5 @@
 int posix_unlink(const char *path)
 {
-	if (rcerrno(vfs_unlink_path, path) != EOK)
+	if (failed(vfs_unlink_path(path)))
 		return -1;
 	else
@@ -356,7 +347,5 @@
 {
 	int file;
-	int rc = vfs_clone(fildes, fildes2, false, &file);
-	if (rc != EOK) {
-		errno = rc < 0 ? -rc : rc;
+	if (failed(vfs_clone(fildes, fildes2, false, &file))) {
 		return -1;
 	}
Index: uspace/lib/posix/test/scanf.c
===================================================================
--- uspace/lib/posix/test/scanf.c	(revision 10de84286f36c6e4f3f92d59c073639668ffe9a1)
+++ uspace/lib/posix/test/scanf.c	(revision 0d0b3197a149bb5e5c53d21136df5b8c283cdc4a)
@@ -30,5 +30,6 @@
 #define __POSIX_DEF__(x) posix_##x
 
-#include "posix/errno.h"
+#include <errno.h>
+
 #include "posix/stdio.h"
 
