Index: uspace/app/bdsh/cmds/modules/cp/cp.c
===================================================================
--- uspace/app/bdsh/cmds/modules/cp/cp.c	(revision a56cef94f0134cc76a541b53862ec1f1d710d49c)
+++ uspace/app/bdsh/cmds/modules/cp/cp.c	(revision 6e5562a50605c74483afabb2b90fff85b7f3b5cc)
@@ -36,5 +36,4 @@
 #include <str.h>
 #include <fcntl.h>
-#include <sys/stat.h>
 #include <vfs/vfs.h>
 #include <dirent.h>
@@ -296,5 +295,5 @@
 				merge_paths(dest_path, PATH_MAX, src_dirname);
 
-				if (mkdir(dest_path, 0) != 0) {
+				if (vfs_link_path(dest_path, KIND_DIRECTORY) != EOK) {
 					printf("Unable to create "
 					    "dest directory %s\n", dest_path);
@@ -310,5 +309,5 @@
 			 * e.g. cp -r /src /data/new_dir_src
 			 */
-			if (mkdir(dest_path, 0) != 0) {
+			if (vfs_link_path(dest_path, KIND_DIRECTORY) != EOK) {
 				printf("Unable to create "
 				    "dest directory %s\n", dest_path);
Index: uspace/app/bdsh/cmds/modules/mkdir/mkdir.c
===================================================================
--- uspace/app/bdsh/cmds/modules/mkdir/mkdir.c	(revision a56cef94f0134cc76a541b53862ec1f1d710d49c)
+++ uspace/app/bdsh/cmds/modules/mkdir/mkdir.c	(revision 6e5562a50605c74483afabb2b90fff85b7f3b5cc)
@@ -32,5 +32,4 @@
 #include <fcntl.h>
 #include <sys/types.h>
-#include <sys/stat.h>
 #include <getopt.h>
 #include <stdarg.h>
@@ -98,7 +97,8 @@
 
 	if (!create_parents) {
-		if (mkdir(path, 0) != 0) {
+		ret = vfs_link_path(path, KIND_DIRECTORY);
+		if (ret != EOK) {
 			cli_error(CL_EFAIL, "%s: could not create %s (%s)",
-			    cmdname, path, str_error(errno));
+			    cmdname, path, str_error(ret));
 			ret = 1;
 		}
@@ -136,7 +136,8 @@
 			path[prev_off] = 0;
 
-			if (mkdir(path, 0) != 0 && errno != EEXIST) {
+			ret = vfs_link_path(path, KIND_DIRECTORY);
+			if (ret != EOK && ret != EEXIST) {
 				cli_error(CL_EFAIL, "%s: could not create %s (%s)",
-				    cmdname, path, str_error(errno));
+				    cmdname, path, str_error(ret));
 				ret = 1;
 				goto leave;
@@ -146,7 +147,8 @@
 		}
 		/* Create the final directory. */
-		if (mkdir(path, 0) != 0) {
+		ret = vfs_link_path(path, KIND_DIRECTORY);
+		if (ret != EOK) {
 			cli_error(CL_EFAIL, "%s: could not create %s (%s)",
-			    cmdname, path, str_error(errno));
+			    cmdname, path, str_error(ret));
 			ret = 1;
 		}
Index: uspace/app/bdsh/cmds/modules/mkfile/mkfile.c
===================================================================
--- uspace/app/bdsh/cmds/modules/mkfile/mkfile.c	(revision a56cef94f0134cc76a541b53862ec1f1d710d49c)
+++ uspace/app/bdsh/cmds/modules/mkfile/mkfile.c	(revision 6e5562a50605c74483afabb2b90fff85b7f3b5cc)
@@ -33,5 +33,4 @@
 #include <fcntl.h>
 #include <sys/types.h>
-#include <sys/stat.h>
 #include <macros.h>
 #include <getopt.h>
Index: uspace/app/fontviewer/fontviewer.c
===================================================================
--- uspace/app/fontviewer/fontviewer.c	(revision a56cef94f0134cc76a541b53862ec1f1d710d49c)
+++ uspace/app/fontviewer/fontviewer.c	(revision 6e5562a50605c74483afabb2b90fff85b7f3b5cc)
@@ -36,5 +36,4 @@
 #include <unistd.h>
 #include <fcntl.h>
-#include <sys/stat.h>
 #include <errno.h>
 #include <malloc.h>
Index: uspace/app/sysinst/futil.c
===================================================================
--- uspace/app/sysinst/futil.c	(revision a56cef94f0134cc76a541b53862ec1f1d710d49c)
+++ uspace/app/sysinst/futil.c	(revision 6e5562a50605c74483afabb2b90fff85b7f3b5cc)
@@ -39,5 +39,4 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <sys/stat.h>
 #include <vfs/vfs.h>
 #include <sys/types.h>
@@ -130,5 +129,5 @@
 		} else if (s.is_directory) {
 			printf("Create directory '%s'\n", destp);
-			rc = mkdir(destp, 0);
+			rc = vfs_link_path(destp, KIND_DIRECTORY);
 			if (rc != EOK)
 				return EIO;
Index: uspace/app/sysinst/sysinst.c
===================================================================
--- uspace/app/sysinst/sysinst.c	(revision a56cef94f0134cc76a541b53862ec1f1d710d49c)
+++ uspace/app/sysinst/sysinst.c	(revision 6e5562a50605c74483afabb2b90fff85b7f3b5cc)
@@ -43,5 +43,4 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <sys/stat.h>
 #include <task.h>
 #include <vfs/vfs.h>
@@ -175,5 +174,5 @@
 		return EIO;
 
-	rc = mkdir(MOUNT_POINT, 0);
+	rc = vfs_link_path(MOUNT_POINT, KIND_DIRECTORY);
 	if (rc != EOK)
 		return rc;
@@ -214,5 +213,5 @@
 
 	printf("sysinst_copy_boot_files(): create CD mount point\n");
-	rc = mkdir(CD_MOUNT_POINT, 0);
+	rc = vfs_link_path(CD_MOUNT_POINT, KIND_DIRECTORY);
 	if (rc != EOK)
 		return rc;
Index: uspace/app/taskdump/elf_core.c
===================================================================
--- uspace/app/taskdump/elf_core.c	(revision a56cef94f0134cc76a541b53862ec1f1d710d49c)
+++ uspace/app/taskdump/elf_core.c	(revision 6e5562a50605c74483afabb2b90fff85b7f3b5cc)
@@ -54,5 +54,4 @@
 #include <errno.h>
 #include <sys/types.h>
-#include <sys/stat.h>
 #include <unistd.h>
 #include <fcntl.h>
Index: uspace/app/taskdump/symtab.c
===================================================================
--- uspace/app/taskdump/symtab.c	(revision a56cef94f0134cc76a541b53862ec1f1d710d49c)
+++ uspace/app/taskdump/symtab.c	(revision 6e5562a50605c74483afabb2b90fff85b7f3b5cc)
@@ -41,5 +41,4 @@
 #include <errno.h>
 #include <sys/types.h>
-#include <sys/stat.h>
 #include <fcntl.h>
 
Index: uspace/app/tester/hw/misc/virtchar1.c
===================================================================
--- uspace/app/tester/hw/misc/virtchar1.c	(revision a56cef94f0134cc76a541b53862ec1f1d710d49c)
+++ uspace/app/tester/hw/misc/virtchar1.c	(revision 6e5562a50605c74483afabb2b90fff85b7f3b5cc)
@@ -45,5 +45,4 @@
 #include <vfs/vfs.h>
 #include <vfs/vfs_sess.h>
-#include <sys/stat.h>
 #include <fcntl.h>
 #include "../../tester.h"
Index: uspace/app/tester/vfs/vfs1.c
===================================================================
--- uspace/app/tester/vfs/vfs1.c	(revision a56cef94f0134cc76a541b53862ec1f1d710d49c)
+++ uspace/app/tester/vfs/vfs1.c	(revision 6e5562a50605c74483afabb2b90fff85b7f3b5cc)
@@ -37,5 +37,4 @@
 #include <loc.h>
 #include <sys/types.h>
-#include <sys/stat.h>
 #include "../tester.h"
 
@@ -71,8 +70,10 @@
 {
 	aoff64_t pos = 0;
+	int rc;
 
-	if (mkdir(TEST_DIRECTORY, 0) != 0) {
-		TPRINTF("rc=%d\n", errno);
-		return "mkdir() failed";
+	rc = vfs_link_path(TEST_DIRECTORY, KIND_DIRECTORY);
+	if (rc != EOK) {
+		TPRINTF("rc=%d\n", rc);
+		return "vfs_link_path() failed";
 	}
 	TPRINTF("Created directory %s\n", TEST_DIRECTORY);
Index: uspace/app/untar/main.c
===================================================================
--- uspace/app/untar/main.c	(revision a56cef94f0134cc76a541b53862ec1f1d710d49c)
+++ uspace/app/untar/main.c	(revision 6e5562a50605c74483afabb2b90fff85b7f3b5cc)
@@ -35,7 +35,7 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <sys/stat.h>
 #include <errno.h>
 #include <str_error.h>
+#include <vfs/vfs.h>
 #include "tar.h"
 
@@ -103,9 +103,12 @@
 static int handle_directory(const tar_header_t *header, FILE *tarfile)
 {
-	if (mkdir(header->filename, 0755) != 0) {
-		if (errno != EEXIST) {
+	int rc;
+
+	rc = vfs_link_path(header->filename, KIND_DIRECTORY);
+	if (rc != EOK) {
+		if (rc != EEXIST) {
 			fprintf(stderr, "Failed to create directory %s: %s.\n",
-			    header->filename, str_error(errno));
-			return errno;
+			    header->filename, str_error(rc));
+			return rc;
 		}
 	}
Index: uspace/app/websrv/websrv.c
===================================================================
--- uspace/app/websrv/websrv.c	(revision a56cef94f0134cc76a541b53862ec1f1d710d49c)
+++ uspace/app/websrv/websrv.c	(revision 6e5562a50605c74483afabb2b90fff85b7f3b5cc)
@@ -39,5 +39,4 @@
 #include <stdio.h>
 #include <sys/types.h>
-#include <sys/stat.h>
 #include <stdlib.h>
 #include <fcntl.h>
Index: uspace/drv/char/ns8250/ns8250.c
===================================================================
--- uspace/drv/char/ns8250/ns8250.c	(revision a56cef94f0134cc76a541b53862ec1f1d710d49c)
+++ uspace/drv/char/ns8250/ns8250.c	(revision 6e5562a50605c74483afabb2b90fff85b7f3b5cc)
@@ -49,5 +49,4 @@
 #include <dirent.h>
 #include <fcntl.h>
-#include <sys/stat.h>
 #include <ddi.h>
 
Index: uspace/lib/bithenge/src/failure.c
===================================================================
--- uspace/lib/bithenge/src/failure.c	(revision a56cef94f0134cc76a541b53862ec1f1d710d49c)
+++ uspace/lib/bithenge/src/failure.c	(revision 6e5562a50605c74483afabb2b90fff85b7f3b5cc)
@@ -41,5 +41,4 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/wait.h>
Index: uspace/lib/bithenge/src/failure.h
===================================================================
--- uspace/lib/bithenge/src/failure.h	(revision a56cef94f0134cc76a541b53862ec1f1d710d49c)
+++ uspace/lib/bithenge/src/failure.h	(revision 6e5562a50605c74483afabb2b90fff85b7f3b5cc)
@@ -42,5 +42,4 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
Index: uspace/lib/c/generic/vfs/vfs.c
===================================================================
--- uspace/lib/c/generic/vfs/vfs.c	(revision a56cef94f0134cc76a541b53862ec1f1d710d49c)
+++ uspace/lib/c/generic/vfs/vfs.c	(revision 6e5562a50605c74483afabb2b90fff85b7f3b5cc)
@@ -43,5 +43,4 @@
 #include <fcntl.h>
 #include <stdio.h>
-#include <sys/stat.h>
 #include <sys/types.h>
 #include <ipc/services.h>
@@ -765,20 +764,51 @@
 }
 
-/** Create directory.
+int vfs_link(int parent, const char *child, vfs_file_kind_t kind)
+{
+	int flags = (kind == KIND_DIRECTORY) ? WALK_DIRECTORY : WALK_REGULAR;
+	int file = _vfs_walk(parent, child, WALK_MUST_CREATE | flags);
+
+	if (file < 0)
+		return file;
+
+	close(file);
+
+	return EOK;
+}
+
+/** Link a file or directory.
  *
  * @param path Path
- * @param mode File mode
- * @return 0 on success. On error returns -1 and sets errno.
- */
-int mkdir(const char *path, mode_t mode)
-{
-	int fd = vfs_lookup(path, WALK_MUST_CREATE | WALK_DIRECTORY);
-	if (fd < 0) {
-		errno = fd;
-		return -1;
-	}
-	
-	return close(fd);
-}
+ * @param kind Kind of the file to be created.
+ * @return EOK on success or a negative error code otherwise
+ */
+int vfs_link_path(const char *path, vfs_file_kind_t kind)
+{
+	size_t pa_size;
+	char *pa = vfs_absolutize(path, &pa_size);
+	if (!pa)
+		return ENOMEM;
+
+	int parent;
+	char *slash = str_rchr(pa, L'/');
+	if (slash != pa) {
+		*slash = '\0';
+		parent = vfs_lookup(pa, WALK_DIRECTORY);
+		*slash = '/';
+	} else {
+		parent = vfs_root();
+	}
+
+	if (parent < 0) {
+		free(pa);
+		return parent;
+	}
+
+	int rc = vfs_link(parent, slash, kind);
+
+	free(pa);
+	close(parent);
+	return rc;
+}	
 
 int vfs_unlink(int parent, const char *child, int expect)
@@ -802,8 +832,8 @@
 }
 
-/** Unlink file or directory.
+/** Unlink a file or directory.
  *
  * @param path Path
- * @return EOk on success or a negative error code otherwise
+ * @return EOK on success or a negative error code otherwise
  */
 int vfs_unlink_path(const char *path)
Index: pace/lib/c/include/sys/stat.h
===================================================================
--- uspace/lib/c/include/sys/stat.h	(revision a56cef94f0134cc76a541b53862ec1f1d710d49c)
+++ 	(revision )
@@ -1,45 +1,0 @@
-/*
- * Copyright (c) 2008 Jakub Jermar
- * 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 libc
- * @{
- */
-/** @file
- */
-
-#ifndef LIBC_SYS_STAT_H_
-#define LIBC_SYS_STAT_H_
-
-#include <ipc/vfs.h>
-
-extern int mkdir(const char *, mode_t);
-
-#endif
-
-/** @}
- */
Index: uspace/lib/c/include/vfs/vfs.h
===================================================================
--- uspace/lib/c/include/vfs/vfs.h	(revision a56cef94f0134cc76a541b53862ec1f1d710d49c)
+++ uspace/lib/c/include/vfs/vfs.h	(revision 6e5562a50605c74483afabb2b90fff85b7f3b5cc)
@@ -49,4 +49,10 @@
 };
 
+typedef enum {
+	KIND_FILE,
+	KIND_DIRECTORY,
+} vfs_file_kind_t;
+
+
 struct stat {
 	fs_handle_t fs_handle;
@@ -88,7 +94,9 @@
 
 extern int vfs_clone(int, int, bool);
+extern int vfs_link(int, const char *, vfs_file_kind_t);
+extern int vfs_link_path(const char *, vfs_file_kind_t);
+extern int vfs_resize(int, aoff64_t);
 extern int vfs_root(void);
 extern void vfs_root_set(int);
-extern int vfs_resize(int, aoff64_t);
 extern int vfs_stat(int, struct stat *);
 extern int vfs_stat_path(const char *, struct stat *);
Index: uspace/lib/fs/libfs.c
===================================================================
--- uspace/lib/fs/libfs.c	(revision a56cef94f0134cc76a541b53862ec1f1d710d49c)
+++ uspace/lib/fs/libfs.c	(revision 6e5562a50605c74483afabb2b90fff85b7f3b5cc)
@@ -44,5 +44,4 @@
 #include <mem.h>
 #include <str.h>
-#include <sys/stat.h>
 #include <stdlib.h>
 #include <fibril_synch.h>
Index: uspace/lib/posix/include/posix/sys/stat.h
===================================================================
--- uspace/lib/posix/include/posix/sys/stat.h	(revision a56cef94f0134cc76a541b53862ec1f1d710d49c)
+++ uspace/lib/posix/include/posix/sys/stat.h	(revision 6e5562a50605c74483afabb2b90fff85b7f3b5cc)
@@ -133,5 +133,5 @@
 extern int __POSIX_DEF__(chmod)(const char *path, mode_t mode);
 extern mode_t __POSIX_DEF__(umask)(mode_t mask);
-extern int mkdir(const char *, mode_t);
+extern int __POSIX_DEF__(mkdir)(const char *path, mode_t mode);
 
 
Index: uspace/lib/posix/source/stdio.c
===================================================================
--- uspace/lib/posix/source/stdio.c	(revision a56cef94f0134cc76a541b53862ec1f1d710d49c)
+++ uspace/lib/posix/source/stdio.c	(revision 6e5562a50605c74483afabb2b90fff85b7f3b5cc)
@@ -53,5 +53,4 @@
 #include "libc/malloc.h"
 #include "libc/adt/list.h"
-#include "libc/sys/stat.h"
 
 /** Clears the stream's error and end-of-file indicators.
Index: uspace/lib/posix/source/sys/stat.c
===================================================================
--- uspace/lib/posix/source/sys/stat.c	(revision a56cef94f0134cc76a541b53862ec1f1d710d49c)
+++ uspace/lib/posix/source/sys/stat.c	(revision 6e5562a50605c74483afabb2b90fff85b7f3b5cc)
@@ -143,4 +143,20 @@
 }
 
+/**
+ * Create a directory.
+ * 
+ * @param path Path to the new directory.
+ * @param mode Permission bits to be set.
+ * @return Zero on success, -1 otherwise.
+ */
+int posix_mkdir(const char *path, mode_t mode)
+{
+	int rc = rcerrno(vfs_link_path, path, KIND_DIRECTORY);
+	if (rc != EOK)
+		return -1;
+	else
+		return 0;
+}
+
 /** @}
  */
Index: uspace/srv/fs/locfs/locfs_ops.c
===================================================================
--- uspace/srv/fs/locfs/locfs_ops.c	(revision a56cef94f0134cc76a541b53862ec1f1d710d49c)
+++ uspace/srv/fs/locfs/locfs_ops.c	(revision 6e5562a50605c74483afabb2b90fff85b7f3b5cc)
@@ -45,5 +45,4 @@
 #include <adt/hash_table.h>
 #include <ipc/loc.h>
-#include <sys/stat.h>
 #include <assert.h>
 #include "locfs.h"
