Index: uspace/app/bdsh/cmds/modules/cat/cat.c
===================================================================
--- uspace/app/bdsh/cmds/modules/cat/cat.c	(revision b5b5d841e02991430e1371523c988d98ab5c2786)
+++ uspace/app/bdsh/cmds/modules/cat/cat.c	(revision 23a0368c8849e72c980ea32ce3092dffde6cf9e8)
@@ -31,5 +31,4 @@
 #include <stdlib.h>
 #include <unistd.h>
-#include <sys/stat.h>
 #include <getopt.h>
 #include <str.h>
@@ -214,8 +213,8 @@
 		struct stat st;
 
-		if (fstat(fd, &st) != EOK) {
+		if (vfs_stat(fd, &st) != EOK) {
 			close(fd);
 			free(buff);
-			printf("Unable to fstat %d\n", fd);
+			printf("Unable to vfs_stat %d\n", fd);
 			return 1;
 		}
Index: uspace/app/bdsh/cmds/modules/cp/cp.c
===================================================================
--- uspace/app/bdsh/cmds/modules/cp/cp.c	(revision b5b5d841e02991430e1371523c988d98ab5c2786)
+++ uspace/app/bdsh/cmds/modules/cp/cp.c	(revision 23a0368c8849e72c980ea32ce3092dffde6cf9e8)
@@ -37,4 +37,5 @@
 #include <fcntl.h>
 #include <sys/stat.h>
+#include <vfs/vfs.h>
 #include <dirent.h>
 #include "config.h"
@@ -83,7 +84,7 @@
 	struct stat s;
 
-	int r = stat(path, &s);
-
-	if (r != 0)
+	int r = vfs_stat_path(path, &s);
+
+	if (r != EOK)
 		return TYPE_NONE;
 	else if (s.is_directory)
@@ -341,6 +342,6 @@
 
 			/* Check if we are copying a directory into itself */
-			stat(src_dent, &src_s);
-			stat(dest_path, &dest_s);
+			vfs_stat_path(src_dent, &src_s);
+			vfs_stat_path(dest_path, &dest_s);
 
 			if (dest_s.index == src_s.index &&
@@ -394,5 +395,5 @@
 	}
 
-	if (fstat(fd1, &st) != EOK) {
+	if (vfs_stat(fd1, &st) != EOK) {
 		printf("Unable to fstat %d\n", fd1);
 		close(fd1);
Index: uspace/app/bdsh/cmds/modules/ls/ls.c
===================================================================
--- uspace/app/bdsh/cmds/modules/ls/ls.c	(revision b5b5d841e02991430e1371523c988d98ab5c2786)
+++ uspace/app/bdsh/cmds/modules/ls/ls.c	(revision 23a0368c8849e72c980ea32ce3092dffde6cf9e8)
@@ -39,5 +39,5 @@
 #include <getopt.h>
 #include <sys/types.h>
-#include <sys/stat.h>
+#include <vfs/vfs.h>
 #include <str.h>
 #include <sort.h>
@@ -185,8 +185,8 @@
 		buff[len] = '\0';
 
-		rc = stat(buff, &tosort[nbdirs++].s);
-		if (rc != 0) {
+		rc = vfs_stat_path(buff, &tosort[nbdirs++].s);
+		if (rc != EOK) {
 			printf("ls: skipping bogus node %s\n", buff);
-			printf("error=%d\n", errno);
+			printf("error=%d\n", rc);
 			goto out;
 		}
@@ -315,5 +315,5 @@
 static unsigned int ls_scope(const char *path, struct dir_elem_t *de)
 {
-	if (stat(path, &de->s) != 0) {
+	if (vfs_stat_path(path, &de->s) != EOK) {
 		cli_error(CL_ENOENT, "%s", path);
 		return LS_BOGUS;
Index: uspace/app/bdsh/cmds/modules/ls/ls.h
===================================================================
--- uspace/app/bdsh/cmds/modules/ls/ls.h	(revision b5b5d841e02991430e1371523c988d98ab5c2786)
+++ uspace/app/bdsh/cmds/modules/ls/ls.h	(revision 23a0368c8849e72c980ea32ce3092dffde6cf9e8)
@@ -1,4 +1,6 @@
 #ifndef LS_H
 #define LS_H
+
+#include <vfs/vfs.h>
 
 /* Various values that can be returned by ls_scope() */
Index: uspace/app/bdsh/cmds/modules/touch/touch.c
===================================================================
--- uspace/app/bdsh/cmds/modules/touch/touch.c	(revision b5b5d841e02991430e1371523c988d98ab5c2786)
+++ uspace/app/bdsh/cmds/modules/touch/touch.c	(revision 23a0368c8849e72c980ea32ce3092dffde6cf9e8)
@@ -40,6 +40,6 @@
 #include <str.h>
 #include <getopt.h>
-#include <sys/stat.h>
 #include <errno.h>
+#include <vfs/vfs.h>
 
 #include "config.h"
@@ -123,6 +123,8 @@
 		
 		/* Check whether file exists if -c (--no-create) option is given */
-		if ((!no_create) || ((no_create) && (stat(buff, &file_stat) == 0)))
+		if ((!no_create) ||
+		    ((no_create) && (vfs_stat_path(buff, &file_stat) == EOK))) {
 			fd = open(buff, O_RDWR | O_CREAT);
+		}
 		
 		if (fd < 0) {
Index: uspace/app/bdsh/compl.c
===================================================================
--- uspace/app/bdsh/compl.c	(revision b5b5d841e02991430e1371523c988d98ab5c2786)
+++ uspace/app/bdsh/compl.c	(revision 23a0368c8849e72c980ea32ce3092dffde6cf9e8)
@@ -33,5 +33,5 @@
 #include <macros.h>
 #include <stdlib.h>
-#include <sys/stat.h>
+#include <vfs/vfs.h>
 
 #include "cmds/cmds.h"
@@ -360,5 +360,5 @@
 				asprintf(&ent_path, "%s/%s", *cs->path, dent->d_name);
 				struct stat ent_stat;
-				if (stat(ent_path, &ent_stat) != 0) {
+				if (vfs_stat_path(ent_path, &ent_stat) != EOK) {
 					/* Error */
 					free(ent_path);
Index: uspace/app/init/init.c
===================================================================
--- uspace/app/init/init.c	(revision b5b5d841e02991430e1371523c988d98ab5c2786)
+++ uspace/app/init/init.c	(revision 23a0368c8849e72c980ea32ce3092dffde6cf9e8)
@@ -42,5 +42,4 @@
 #include <errno.h>
 #include <fcntl.h>
-#include <sys/stat.h>
 #include <task.h>
 #include <malloc.h>
@@ -156,5 +155,5 @@
 {
 	struct stat s;
-	if (stat(path, &s) != 0) {
+	if (vfs_stat_path(path, &s) != EOK) {
 		printf("%s: Unable to stat %s\n", NAME, path);
 		return ENOENT;
Index: uspace/app/sysinst/futil.c
===================================================================
--- uspace/app/sysinst/futil.c	(revision b5b5d841e02991430e1371523c988d98ab5c2786)
+++ uspace/app/sysinst/futil.c	(revision 23a0368c8849e72c980ea32ce3092dffde6cf9e8)
@@ -40,4 +40,5 @@
 #include <stdlib.h>
 #include <sys/stat.h>
+#include <vfs/vfs.h>
 #include <sys/types.h>
 #include <dirent.h>
@@ -119,5 +120,5 @@
 			return ENOMEM;
 
-		rc = stat(srcp, &s);
+		rc = vfs_stat_path(srcp, &s);
 		if (rc != EOK)
 			return EIO;
@@ -166,5 +167,5 @@
 		return ENOENT;
 
-	if (fstat(sf, &st) != EOK) {
+	if (vfs_stat(sf, &st) != EOK) {
 		close(sf);
 		return EIO;
Index: uspace/app/viewer/viewer.c
===================================================================
--- uspace/app/viewer/viewer.c	(revision b5b5d841e02991430e1371523c988d98ab5c2786)
+++ uspace/app/viewer/viewer.c	(revision 23a0368c8849e72c980ea32ce3092dffde6cf9e8)
@@ -36,5 +36,5 @@
 #include <unistd.h>
 #include <fcntl.h>
-#include <sys/stat.h>
+#include <vfs/vfs.h>
 #include <errno.h>
 #include <malloc.h>
@@ -115,6 +115,6 @@
 	
 	struct stat stat;
-	int rc = fstat(fd, &stat);
-	if (rc != 0) {
+	int rc = vfs_stat(fd, &stat);
+	if (rc != EOK) {
 		close(fd);
 		return false;
Index: uspace/drv/bus/isa/isa.c
===================================================================
--- uspace/drv/bus/isa/isa.c	(revision b5b5d841e02991430e1371523c988d98ab5c2786)
+++ uspace/drv/bus/isa/isa.c	(revision 23a0368c8849e72c980ea32ce3092dffde6cf9e8)
@@ -54,5 +54,5 @@
 #include <ipc/irc.h>
 #include <ipc/services.h>
-#include <sys/stat.h>
+#include <vfs/vfs.h>
 #include <irc.h>
 #include <ns.h>
@@ -264,6 +264,6 @@
 	opened = true;
 
-	if (fstat(fd, &st) != EOK) {
-		ddf_msg(LVL_ERROR, "Unable to fstat %d", fd);
+	if (vfs_stat(fd, &st) != EOK) {
+		ddf_msg(LVL_ERROR, "Unable to vfs_stat %d", fd);
 		goto cleanup;
 	}
Index: uspace/lib/bithenge/src/file.c
===================================================================
--- uspace/lib/bithenge/src/file.c	(revision b5b5d841e02991430e1371523c988d98ab5c2786)
+++ uspace/lib/bithenge/src/file.c	(revision 23a0368c8849e72c980ea32ce3092dffde6cf9e8)
@@ -41,5 +41,5 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <sys/stat.h>
+#include <vfs/vfs.h>
 #include <sys/types.h>
 #include <unistd.h>
@@ -104,6 +104,6 @@
 
 	struct stat stat;
-	int rc = fstat(fd, &stat);
-	if (rc != 0) {
+	int rc = vfs_stat(fd, &stat);
+	if (rc != EOK) {
 		if (needs_close)
 			close(fd);
Index: uspace/lib/c/generic/io/io.c
===================================================================
--- uspace/lib/c/generic/io/io.c	(revision b5b5d841e02991430e1371523c988d98ab5c2786)
+++ uspace/lib/c/generic/io/io.c	(revision 23a0368c8849e72c980ea32ce3092dffde6cf9e8)
@@ -41,5 +41,4 @@
 #include <stdbool.h>
 #include <malloc.h>
-#include <sys/stat.h>
 #include <async.h>
 #include <io/kio.h>
@@ -765,4 +764,6 @@
 int fseek(FILE *stream, off64_t offset, int whence)
 {
+	int rc;
+
 	if (stream->error)
 		return -1;
@@ -785,6 +786,7 @@
 		break;
 	case SEEK_END:
-		if (fstat(stream->fd, &st) != EOK) {
-			/* errno was set by fstat() */
+		rc = vfs_stat(stream->fd, &st);
+		if (rc != EOK) {
+			errno = rc;
 			stream->error = true;
 			return -1;	
Index: uspace/lib/c/generic/vfs/vfs.c
===================================================================
--- uspace/lib/c/generic/vfs/vfs.c	(revision b5b5d841e02991430e1371523c988d98ab5c2786)
+++ uspace/lib/c/generic/vfs/vfs.c	(revision 23a0368c8849e72c980ea32ce3092dffde6cf9e8)
@@ -641,10 +641,10 @@
 /** Get file status.
  *
- * @param fildes File descriptor
+ * @param file File descriptor
  * @param stat Place to store file information
  *
- * @return 0 on success, -1 on error and sets errno.
- */
-int fstat(int fildes, struct stat *stat)
+ * @return EOK on success or a negative error code otherwise.
+ */
+int vfs_stat(int file, struct stat *stat)
 {
 	sysarg_t rc;
@@ -653,5 +653,5 @@
 	async_exch_t *exch = vfs_exchange_begin();
 	
-	req = async_send_1(exch, VFS_IN_STAT, fildes, NULL);
+	req = async_send_1(exch, VFS_IN_STAT, file, NULL);
 	rc = async_data_read_start(exch, (void *) stat, sizeof(struct stat));
 	if (rc != EOK) {
@@ -663,10 +663,6 @@
 		if (rc_orig != EOK)
 			rc = rc_orig;
-		if (rc != EOK) {
-			errno = rc;
-			return -1;
-		}
 		
-		return 0;
+		return rc;
 	}
 	
@@ -674,10 +670,5 @@
 	async_wait_for(req, &rc);
 	
-	if (rc != EOK) {
-		errno = rc;
-		return -1;
-	}
-	
-	return 0;
+	return rc;
 }
 
@@ -687,21 +678,15 @@
  * @param stat Place to store file information
  *
- * @return 0 on success, -1 on error and sets errno.
- */
-int stat(const char *path, struct stat *stat)
-{
-	int fd = vfs_lookup(path, 0);
-	if (fd < 0) {
-		errno = fd;
-		return -1;
-	}
-	
-	int rc = fstat(fd, stat);
-	if (rc != EOK) {
-		close(fd);
-		errno = rc;
-		rc = -1;
-	} else
-		rc = close(fd);
+ * @return EOK on success or a negative error code otherwise.
+ */
+int vfs_stat_path(const char *path, struct stat *stat)
+{
+	int file = vfs_lookup(path, 0);
+	if (file < 0)
+		return file;
+	
+	int rc = vfs_stat(file, stat);
+
+	close(file);
 
 	return rc;
@@ -1057,8 +1042,8 @@
  * @return On success returns session pointer. On error returns @c NULL.
  */
-async_sess_t *vfs_fd_session(int fildes, iface_t iface)
+async_sess_t *vfs_fd_session(int file, iface_t iface)
 {
 	struct stat stat;
-	int rc = fstat(fildes, &stat);
+	int rc = vfs_stat(file, &stat);
 	if (rc != 0)
 		return NULL;
@@ -1122,5 +1107,5 @@
 		child = pa;
 
-		rc = stat(child, &st);
+		rc = vfs_stat_path(child, &st);
 		if (rc != 0) {
 			free(child);
@@ -1152,5 +1137,5 @@
 	struct stat st;
 
-	int rc = stat("/", &st);
+	int rc = vfs_stat_path("/", &st);
 	if (rc != 0)
 		return rc;
@@ -1165,5 +1150,5 @@
  * @param file File located on the queried file system
  * @param st Buffer for storing information
- * @return 0 on success. On error -1 is returned and errno is set.
+ * @return EOK on success or a negative error code otherwise.
  */
 int vfs_statfs(int file, struct statfs *st)
Index: uspace/lib/c/include/sys/stat.h
===================================================================
--- uspace/lib/c/include/sys/stat.h	(revision b5b5d841e02991430e1371523c988d98ab5c2786)
+++ uspace/lib/c/include/sys/stat.h	(revision 23a0368c8849e72c980ea32ce3092dffde6cf9e8)
@@ -36,22 +36,6 @@
 #define LIBC_SYS_STAT_H_
 
-#include <sys/types.h>
-#include <stdbool.h>
 #include <ipc/vfs.h>
-#include <ipc/loc.h>
 
-struct stat {
-	fs_handle_t fs_handle;
-	service_id_t service_id;
-	fs_index_t index;
-	unsigned int lnkcnt;
-	bool is_file;
-	bool is_directory;
-	aoff64_t size;
-	service_id_t service;
-};
-
-extern int fstat(int, struct stat *);
-extern int stat(const char *, struct stat *);
 extern int mkdir(const char *, mode_t);
 
Index: uspace/lib/c/include/vfs/vfs.h
===================================================================
--- uspace/lib/c/include/vfs/vfs.h	(revision b5b5d841e02991430e1371523c988d98ab5c2786)
+++ uspace/lib/c/include/vfs/vfs.h	(revision 23a0368c8849e72c980ea32ce3092dffde6cf9e8)
@@ -49,4 +49,15 @@
 };
 
+struct stat {
+	fs_handle_t fs_handle;
+	service_id_t service_id;
+	fs_index_t index;
+	unsigned int lnkcnt;
+	bool is_file;
+	bool is_directory;
+	aoff64_t size;
+	service_id_t service;
+};
+
 struct statfs { 
 	char fs_name[FS_NAME_MAXLEN + 1];
@@ -79,4 +90,6 @@
 extern int vfs_root(void);
 extern void vfs_root_set(int);
+extern int vfs_stat(int, struct stat *);
+extern int vfs_stat_path(const char *, struct stat *);
 extern int vfs_statfs(int, struct statfs *);
 extern int vfs_statfs_path(const char *, struct statfs *);
Index: uspace/lib/posix/source/internal/common.h
===================================================================
--- uspace/lib/posix/source/internal/common.h	(revision b5b5d841e02991430e1371523c988d98ab5c2786)
+++ uspace/lib/posix/source/internal/common.h	(revision 23a0368c8849e72c980ea32ce3092dffde6cf9e8)
@@ -59,4 +59,12 @@
 })
 
+/* Convert error code to positive errno and -1 return value */
+#define rcerrno(func, ...) ({ \
+	int rc = func(__VA_ARGS__); \
+	if (rc < 0) \
+		errno = -rc; \
+	rc; \
+})
+
 extern aoff64_t posix_pos[MAX_OPEN_FILES];
 
Index: uspace/lib/posix/source/sys/stat.c
===================================================================
--- uspace/lib/posix/source/sys/stat.c	(revision b5b5d841e02991430e1371523c988d98ab5c2786)
+++ uspace/lib/posix/source/sys/stat.c	(revision 23a0368c8849e72c980ea32ce3092dffde6cf9e8)
@@ -39,5 +39,5 @@
 #include "../internal/common.h"
 #include "posix/sys/stat.h"
-#include "libc/sys/stat.h"
+#include "libc/vfs/vfs.h"
 
 #include "posix/errno.h"
@@ -80,7 +80,7 @@
 {
 	struct stat hst;
-	int rc = negerrno(fstat, fd, &hst);
+	int rc = rcerrno(vfs_stat, fd, &hst);
 	if (rc < 0)
-		return rc;
+		return -1;
 	stat_to_posix(st, &hst);
 	return 0;
@@ -110,7 +110,7 @@
 {
 	struct stat hst;
-	int rc = negerrno(stat, path, &hst);
+	int rc = rcerrno(vfs_stat_path, path, &hst);
 	if (rc < 0)
-		return rc;
+		return -1;
 	stat_to_posix(st, &hst);
 	return 0;
Index: uspace/lib/posix/source/unistd.c
===================================================================
--- uspace/lib/posix/source/unistd.c	(revision b5b5d841e02991430e1371523c988d98ab5c2786)
+++ uspace/lib/posix/source/unistd.c	(revision 23a0368c8849e72c980ea32ce3092dffde6cf9e8)
@@ -48,5 +48,4 @@
 #include "libc/malloc.h"
 #include "libc/vfs/vfs.h"
-#include "libc/sys/stat.h"
 
 aoff64_t posix_pos[MAX_OPEN_FILES];
@@ -221,4 +220,5 @@
 {
 	struct stat st;
+	int rc;
 
 	switch (whence) {
@@ -230,8 +230,7 @@
 		break;
 	case SEEK_END:
-		if (fstat(fildes, &st) != EOK) {
-			errno = -errno;
+		rc = rcerrno(vfs_stat, fildes, &st);
+		if (rc != EOK)
 			return -1;
-		}
 		posix_pos[fildes] = st.size + offset;
 		break;
Index: uspace/srv/devman/driver.c
===================================================================
--- uspace/srv/devman/driver.c	(revision b5b5d841e02991430e1371523c988d98ab5c2786)
+++ uspace/srv/devman/driver.c	(revision 23a0368c8849e72c980ea32ce3092dffde6cf9e8)
@@ -34,6 +34,6 @@
 #include <errno.h>
 #include <fcntl.h>
-#include <sys/stat.h>
 #include <io/log.h>
+#include <vfs/vfs.h>
 #include <loc.h>
 #include <str_error.h>
@@ -142,5 +142,5 @@
 	/* Check whether the driver's binary exists. */
 	struct stat s;
-	if (stat(drv->binary_path, &s) != 0) {
+	if (vfs_stat_path(drv->binary_path, &s) != EOK) {
 		log_msg(LOG_DEFAULT, LVL_ERROR, "Driver not found at path `%s'.",
 		    drv->binary_path);
Index: uspace/srv/devman/match.c
===================================================================
--- uspace/srv/devman/match.c	(revision b5b5d841e02991430e1371523c988d98ab5c2786)
+++ uspace/srv/devman/match.c	(revision 23a0368c8849e72c980ea32ce3092dffde6cf9e8)
@@ -37,5 +37,5 @@
 #include <str_error.h>
 #include <sys/types.h>
-#include <sys/stat.h>
+#include <vfs/vfs.h>
 
 #include "devman.h"
@@ -211,5 +211,5 @@
 	opened = true;
 	
-	if (fstat(fd, &st) != EOK) {
+	if (vfs_stat(fd, &st) != EOK) {
 		log_msg(LOG_DEFAULT, LVL_ERROR, "Unable to fstat %d: %s.", fd,
 		    str_error(errno));
