Index: uspace/lib/ext2/libext2_directory.c
===================================================================
--- uspace/lib/ext2/libext2_directory.c	(revision d7c3367c0f6cf7deff74357b6ecff7d79cd6b7fc)
+++ uspace/lib/ext2/libext2_directory.c	(revision 95afd72f52757783ce7bd0a289996deb89601fcf)
@@ -40,4 +40,7 @@
 #include <assert.h>
 
+static int ext2_directory_iterator_set(ext2_directory_iterator_t *it,
+    uint32_t block_size);
+
 /**
  * Get inode number for the directory entry
@@ -126,5 +129,4 @@
 	uint32_t next_block_phys_idx;
 	uint32_t block_size;
-	uint32_t offset_in_block;
 	
 	assert(it->current != NULL);
@@ -175,9 +177,18 @@
 	}
 	
-	offset_in_block = (it->current_offset + skip) % block_size;
+	it->current_offset += skip;
+	
+	return ext2_directory_iterator_set(it, block_size);
+}
+
+static int ext2_directory_iterator_set(ext2_directory_iterator_t *it,
+    uint32_t block_size)
+{
+	uint32_t offset_in_block = it->current_offset % block_size;
+	
+	it->current = NULL;
 	
 	/* Ensure proper alignment */
 	if ((offset_in_block % 4) != 0) {
-		it->current = NULL;
 		return EIO;
 	}
@@ -185,15 +196,12 @@
 	/* 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;
+		return EIO;
+	}
+	
+	ext2_directory_entry_ll_t *entry = it->current_block->data + offset_in_block;
 	
 	/* 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;
+	uint16_t length = ext2_directory_entry_ll_get_entry_length(entry);
+	if (offset_in_block + length > block_size) {
 		return EIO;
 	}
@@ -201,9 +209,9 @@
 	/* 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;
-	}
-	
+	    entry) > length-8) {
+		return EIO;
+	}
+	
+	it->current = entry;
 	return EOK;
 }
