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: uspace/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: uspace/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"
 
