Index: uspace/lib/c/Makefile
===================================================================
--- uspace/lib/c/Makefile	(revision ce04ea446ae259288dc1f51ca1fdcc70dd74d6bb)
+++ uspace/lib/c/Makefile	(revision d4067a792b7c6d4786058f0ae59ea029852a9a9d)
@@ -73,4 +73,5 @@
 	generic/device/clock_dev.c \
 	generic/device/led_dev.c \
+	generic/dirent.c \
 	generic/dhcp.c \
 	generic/dnsr.c \
@@ -147,6 +148,6 @@
 	generic/stdlib.c \
 	generic/udebug.c \
+	generic/vfs/canonify.c \
 	generic/vfs/vfs.c \
-	generic/vfs/canonify.c \
 	generic/rcu.c \
 	generic/setjmp.c \
Index: uspace/lib/c/generic/dirent.c
===================================================================
--- uspace/lib/c/generic/dirent.c	(revision d4067a792b7c6d4786058f0ae59ea029852a9a9d)
+++ uspace/lib/c/generic/dirent.c	(revision d4067a792b7c6d4786058f0ae59ea029852a9a9d)
@@ -0,0 +1,125 @@
+/*
+ * 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
+ */
+
+#include <vfs/vfs.h>
+#include <stdlib.h>
+#include <dirent.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <assert.h>
+
+/** Open directory.
+ *
+ * @param dirname Directory pathname
+ *
+ * @return Non-NULL pointer on success. On error returns @c NULL and sets errno.
+ */
+DIR *opendir(const char *dirname)
+{
+	DIR *dirp = malloc(sizeof(DIR));
+	if (!dirp) {
+		errno = ENOMEM;
+		return NULL;
+	}
+	
+	int fd = vfs_lookup(dirname, WALK_DIRECTORY);
+	if (fd < 0) {
+		free(dirp);
+		errno = fd;
+		return NULL;
+	}
+	
+	int rc = vfs_open(fd, MODE_READ);
+	if (rc < 0) {
+		free(dirp);
+		vfs_put(fd);
+		errno = rc;
+		return NULL;
+	}
+	
+	dirp->fd = fd;
+	dirp->pos = 0;
+	return dirp;
+}
+
+/** Read directory entry.
+ *
+ * @param dirp Open directory
+ * @return Non-NULL pointer to directory entry on success. On error returns
+ *         @c NULL and sets errno.
+ */
+struct dirent *readdir(DIR *dirp)
+{
+	int rc;
+	ssize_t len = 0;
+	
+	rc = vfs_read_short(dirp->fd, dirp->pos, &dirp->res.d_name[0],
+	    NAME_MAX + 1, &len);
+	if (rc != EOK) {
+		errno = rc;
+		return NULL;
+	}
+	
+	dirp->pos += len;
+	
+	return &dirp->res;
+}
+
+/** Rewind directory position to the beginning.
+ *
+ * @param dirp Open directory
+ */
+void rewinddir(DIR *dirp)
+{
+	dirp->pos = 0;
+}
+
+/** Close directory.
+ *
+ * @param dirp Open directory
+ * @return 0 on success. On error returns -1 and sets errno.
+ */
+int closedir(DIR *dirp)
+{
+	int rc;
+	
+	rc = vfs_put(dirp->fd);
+	free(dirp);
+
+	/* On error errno was set by close() */
+	return rc;
+}
+
+/** @}
+ */
Index: uspace/lib/c/generic/vfs/vfs.c
===================================================================
--- uspace/lib/c/generic/vfs/vfs.c	(revision ce04ea446ae259288dc1f51ca1fdcc70dd74d6bb)
+++ uspace/lib/c/generic/vfs/vfs.c	(revision d4067a792b7c6d4786058f0ae59ea029852a9a9d)
@@ -39,7 +39,5 @@
 #include <macros.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <dirent.h>
-#include <stdio.h>
 #include <sys/types.h>
 #include <ipc/services.h>
@@ -632,86 +630,4 @@
 }
 
-/** Open directory.
- *
- * @param dirname Directory pathname
- *
- * @return Non-NULL pointer on success. On error returns @c NULL and sets errno.
- */
-DIR *opendir(const char *dirname)
-{
-	DIR *dirp = malloc(sizeof(DIR));
-	if (!dirp) {
-		errno = ENOMEM;
-		return NULL;
-	}
-	
-	int fd = vfs_lookup(dirname, WALK_DIRECTORY);
-	if (fd < 0) {
-		free(dirp);
-		errno = fd;
-		return NULL;
-	}
-	
-	int rc = vfs_open(fd, MODE_READ);
-	if (rc < 0) {
-		free(dirp);
-		vfs_put(fd);
-		errno = rc;
-		return NULL;
-	}
-	
-	dirp->fd = fd;
-	dirp->pos = 0;
-	return dirp;
-}
-
-/** Read directory entry.
- *
- * @param dirp Open directory
- * @return Non-NULL pointer to directory entry on success. On error returns
- *         @c NULL and sets errno.
- */
-struct dirent *readdir(DIR *dirp)
-{
-	int rc;
-	ssize_t len = 0;
-	
-	rc = vfs_read_short(dirp->fd, dirp->pos, &dirp->res.d_name[0],
-	    NAME_MAX + 1, &len);
-	if (rc != EOK) {
-		errno = rc;
-		return NULL;
-	}
-	
-	dirp->pos += len;
-	
-	return &dirp->res;
-}
-
-/** Rewind directory position to the beginning.
- *
- * @param dirp Open directory
- */
-void rewinddir(DIR *dirp)
-{
-	dirp->pos = 0;
-}
-
-/** Close directory.
- *
- * @param dirp Open directory
- * @return 0 on success. On error returns -1 and sets errno.
- */
-int closedir(DIR *dirp)
-{
-	int rc;
-	
-	rc = vfs_put(dirp->fd);
-	free(dirp);
-
-	/* On error errno was set by close() */
-	return rc;
-}
-
 int vfs_link(int parent, const char *child, vfs_file_kind_t kind)
 {
