Index: uspace/app/ext2info/ext2info.c
===================================================================
--- uspace/app/ext2info/ext2info.c	(revision 102d4000af331bdf964271ff6b88d5992d3e1f77)
+++ uspace/app/ext2info/ext2info.c	(revision a8e1aae104b85a6c46574dd3e25885e0a77e5c45)
@@ -56,7 +56,10 @@
 static void print_block_groups(ext2_filesystem_t *);
 static void print_block_group(ext2_block_group_t *);
-static void print_inode_by_number(ext2_filesystem_t *, uint32_t, bool, uint32_t);
+static void print_inode_by_number(ext2_filesystem_t *, uint32_t, bool, uint32_t,
+    bool);
+static void print_data(unsigned char *, size_t);
 static void print_inode(ext2_filesystem_t *, ext2_inode_t *);
 static void print_inode_data(ext2_filesystem_t *, ext2_inode_t *, uint32_t);
+static void print_directory_contents(ext2_filesystem_t *, ext2_inode_ref_t *);
 
 #define ARG_SUPERBLOCK 1
@@ -65,4 +68,5 @@
 #define ARG_STRICT_CHECK 8
 #define ARG_INODE_DATA 16
+#define ARG_INODE_LIST 32
 #define ARG_COMMON (ARG_SUPERBLOCK | ARG_BLOCK_GROUPS)
 #define ARG_ALL (ARG_COMMON | ARG_INODE)
@@ -141,4 +145,9 @@
 			--argc; ++argv;
 		}
+		
+		if (str_cmp(*argv, "--list") == 0) {
+			--argc; ++argv;
+			arg_flags |= ARG_INODE_LIST;
+		}
 	}
 
@@ -186,5 +195,5 @@
 	if (arg_flags & ARG_INODE) {
 		print_inode_by_number(&filesystem, inode, arg_flags & ARG_INODE_DATA,
-		    inode_data);
+		    inode_data, arg_flags & ARG_INODE_LIST);
 	}
 
@@ -198,5 +207,5 @@
 {
 	printf("syntax: ext2info [--strict-check] [--superblock] [--block-groups] "
-	    "[--inode <i-number> [--inode-data <block-number>]] <device_name>\n");
+	    "[--inode <i-number> [--inode-data <block-number>] [--list]] <device_name>\n");
 }
 
@@ -346,5 +355,5 @@
 
 void print_inode_by_number(ext2_filesystem_t *fs, uint32_t inode, 
-    bool print_data, uint32_t data)
+    bool print_data, uint32_t data, bool list)
 {
 	int rc;
@@ -362,4 +371,9 @@
 	if (print_data) {
 		print_inode_data(fs, inode_ref->inode, data);
+	}
+	
+	if (list && ext2_inode_is_type(fs->superblock, inode_ref->inode,
+	    EXT2_INODE_MODE_DIRECTORY)) {
+		print_directory_contents(fs, inode_ref);
 	}
 	
@@ -444,4 +458,20 @@
 }
 
+void print_data(unsigned char *data, size_t size)
+{
+	unsigned char c;
+	size_t i;
+	
+	for (i = 0; i < size; i++) {
+		c = data[i];
+		if (c >= 32 && c < 127) {
+			putchar(c);
+		}
+		else {
+			putchar('.');
+		}
+	}
+}
+
 void print_inode_data(ext2_filesystem_t *fs, ext2_inode_t *inode, uint32_t data)
 {
@@ -449,6 +479,4 @@
 	uint32_t data_block_index;
 	block_t *block;
-	size_t i;
-	unsigned char c;
 	
 	rc = ext2_filesystem_get_inode_data_block_index(fs, inode, data,
@@ -471,14 +499,5 @@
 	}
 	
-	for (i = 0; i < block->size; i++) {
-		c = ((unsigned char *)block->data)[i];
-		if (c >= 32 && c < 127) {
-			putchar(c);
-		}
-		else {
-			putchar('.');
-		}
-	}
-	
+	print_data(block->data, block->size);
 	printf("\n");	
 	
@@ -486,4 +505,41 @@
 	if (rc != EOK) {
 		printf("Failed putting filesystem block\n");
+	}
+	
+}
+
+void print_directory_contents(ext2_filesystem_t *fs,
+    ext2_inode_ref_t *inode_ref)
+{
+	int rc;
+	ext2_directory_iterator_t it;
+	size_t name_size;
+	
+	printf("  Directory contents:\n");
+	
+	rc = ext2_directory_iterator_init(&it, fs, inode_ref);
+	if (rc != EOK) {
+		printf("Failed initializing directory iterator\n");
+		return;
+	}
+	
+	while (it.current != NULL) {
+		name_size = ext2_directory_entry_ll_get_name_length(fs->superblock,
+		    it.current);
+		printf("    ");
+		print_data(&it.current->name, name_size);
+		printf(" --> %u\n", it.current->inode);
+		
+		rc = ext2_directory_iterator_next(&it);
+		if (rc != EOK) {
+			printf("Failed reading directory contents\n");
+			goto cleanup;
+		}
+	}
+
+cleanup:
+	rc = ext2_directory_iterator_fini(&it);
+	if (rc != EOK) {
+		printf("Failed cleaning-up directory iterator\n");
 	}
 	
Index: uspace/lib/ext2/libext2_directory.c
===================================================================
--- uspace/lib/ext2/libext2_directory.c	(revision 102d4000af331bdf964271ff6b88d5992d3e1f77)
+++ uspace/lib/ext2/libext2_directory.c	(revision a8e1aae104b85a6c46574dd3e25885e0a77e5c45)
@@ -37,4 +37,6 @@
 #include "libext2_directory.h"
 #include <byteorder.h>
+#include <errno.h>
+#include <assert.h>
 
 /**
@@ -75,4 +77,159 @@
 }
 
+/**
+ * Initialize a directory iterator
+ * 
+ * @param it pointer to iterator to initialize
+ * @param fs pointer to filesystem structure
+ * @param inode pointer to inode reference structure
+ * @return EOK on success or negative error code on failure
+ */
+int ext2_directory_iterator_init(ext2_directory_iterator_t *it,
+    ext2_filesystem_t *fs, ext2_inode_ref_t *inode_ref)
+{
+	int rc;
+	uint32_t block_id;
+	it->inode_ref = inode_ref;
+	it->fs = fs;
+	
+	// Get the first data block, so we can get first entry
+	rc = ext2_filesystem_get_inode_data_block_index(fs, inode_ref->inode, 0, 
+	    &block_id);
+	if (rc != EOK) {
+		return rc;
+	}
+	
+	rc = block_get(&it->current_block, fs->device, block_id, 0);
+	if (rc != EOK) {
+		return rc;
+	}
+	
+	it->current = it->current_block->data;
+	it->current_offset = 0;
+	
+	return EOK;
+}
+
+/**
+ * Advance the directory iterator to the next entry
+ * 
+ * @param it pointer to iterator to initialize
+ * @return EOK on success or negative error code on failure
+ */
+int ext2_directory_iterator_next(ext2_directory_iterator_t *it)
+{
+	int rc;
+	uint16_t skip;
+	uint64_t size;
+	aoff64_t current_block_idx;
+	aoff64_t next_block_idx;
+	uint32_t next_block_phys_idx;
+	uint32_t block_size;
+	uint32_t offset_in_block;
+	
+	assert(it->current != NULL);
+	
+	skip = ext2_directory_entry_ll_get_entry_length(it->current);
+	size = ext2_inode_get_size(it->fs->superblock, it->inode_ref->inode);
+	
+	// Are we at the end?
+	if (it->current_offset + skip >= size) {
+		rc = block_put(it->current_block);
+		it->current_block = NULL;
+		it->current = NULL;
+		if (rc != EOK) {
+			return rc;
+		}
+		
+		it->current_offset += skip;
+		return EOK;
+	}
+	
+	block_size = ext2_superblock_get_block_size(it->fs->superblock);
+	current_block_idx = it->current_offset / block_size;
+	next_block_idx = (it->current_offset + skip) / block_size;
+	
+	// If we are moving accross block boundary,
+	// we need to get another block
+	if (current_block_idx != next_block_idx) {
+		rc = block_put(it->current_block);
+		it->current_block = NULL;
+		it->current = NULL;
+		if (rc != EOK) {
+			return rc;
+		}
+		
+		rc = ext2_filesystem_get_inode_data_block_index(it->fs,
+		    it->inode_ref->inode, next_block_idx, &next_block_phys_idx);
+		if (rc != EOK) {
+			return rc;
+		}
+		
+		rc = block_get(&it->current_block, it->fs->device, next_block_phys_idx,
+		    BLOCK_FLAGS_NONE);
+		if (rc != EOK) {
+			it->current_block = NULL;
+			return rc;
+		}
+	}
+	
+	offset_in_block = (it->current_offset + skip) % block_size;
+	
+	// Ensure proper alignment
+	if ((offset_in_block % 4) != 0) {
+		it->current = NULL;
+		return EIO;
+	}
+	
+	// Ensure that the core of the entry does not overflow the block
+	if (offset_in_block > block_size - 8) {
+		it->current = NULL;
+		return EIO;
+	}
+		
+	it->current = it->current_block->data + offset_in_block;
+	it->current_offset += skip;
+	
+	// Ensure that the whole entry does not overflow the block
+	skip = ext2_directory_entry_ll_get_entry_length(it->current);
+	if (offset_in_block + skip > block_size) {
+		it->current = NULL;
+		return EIO;
+	}
+	
+	// Ensure the name length is not too large
+	if (ext2_directory_entry_ll_get_name_length(it->fs->superblock, 
+	    it->current) > skip-8) {
+		it->current = NULL;
+		return EIO;
+	}
+	
+	return EOK;
+}
+
+/**
+ * Release all resources asociated with the directory iterator
+ * 
+ * @param it pointer to iterator to initialize
+ * @return EOK on success or negative error code on failure
+ */
+int ext2_directory_iterator_fini(ext2_directory_iterator_t *it)
+{
+	int rc;
+	
+	it->fs = NULL;
+	it->inode_ref = NULL;
+	it->current = NULL;
+	
+	if (it->current_block) {
+		rc = block_put(it->current_block);
+		if (rc != EOK) {
+			return rc;
+		}
+	}
+	
+	return EOK;
+}
+
 /** @}
  */
Index: uspace/lib/ext2/libext2_directory.h
===================================================================
--- uspace/lib/ext2/libext2_directory.h	(revision 102d4000af331bdf964271ff6b88d5992d3e1f77)
+++ uspace/lib/ext2/libext2_directory.h	(revision a8e1aae104b85a6c46574dd3e25885e0a77e5c45)
@@ -38,4 +38,6 @@
 
 #include <libblock.h>
+#include "libext2_filesystem.h"
+#include "libext2_inode.h"
 
 /**
@@ -53,4 +55,12 @@
 } __attribute__ ((packed)) ext2_directory_entry_ll_t;
 
+typedef struct ext2_directory_iterator {
+	ext2_filesystem_t *fs;
+	ext2_inode_ref_t *inode_ref;
+	block_t *current_block;
+	aoff64_t current_offset;
+	ext2_directory_entry_ll_t *current;
+} ext2_directory_iterator_t;
+
 
 inline uint32_t	ext2_directory_entry_ll_get_inode(ext2_directory_entry_ll_t *);
@@ -60,4 +70,9 @@
     ext2_superblock_t *, ext2_directory_entry_ll_t *);
 
+extern int ext2_directory_iterator_init(ext2_directory_iterator_t *,
+    ext2_filesystem_t *, ext2_inode_ref_t *);
+extern int ext2_directory_iterator_next(ext2_directory_iterator_t *);
+extern int ext2_directory_iterator_fini(ext2_directory_iterator_t *);
+
 #endif
 
