Index: uspace/lib/ext4/libext4_balloc.c
===================================================================
--- uspace/lib/ext4/libext4_balloc.c	(revision 7856d096ccea34cfe2f6cdd077ec231776bed992)
+++ uspace/lib/ext4/libext4_balloc.c	(revision 27644979c1153424ab3d385f930054e40aeae800)
@@ -264,8 +264,7 @@
  *
  */
-static uint32_t ext4_balloc_find_goal(ext4_inode_ref_t *inode_ref)
+static int ext4_balloc_find_goal(ext4_inode_ref_t *inode_ref, uint32_t *goal)
 {
-	uint32_t goal = 0;
-	
+	*goal = 0;
 	ext4_superblock_t *sb = inode_ref->fs->superblock;
 	
@@ -280,11 +279,11 @@
 	if (inode_block_count > 0) {
 		int rc = ext4_filesystem_get_inode_data_block_index(inode_ref,
-		    inode_block_count - 1, &goal);
+		    inode_block_count - 1, goal);
 		if (rc != EOK)
-			return 0;
+			return rc;
 		
 		if (goal != 0) {
-			goal++;
-			return goal;
+			(*goal)++;
+			return EOK;
 		}
 		
@@ -302,5 +301,5 @@
 	    block_group, &bg_ref);
 	if (rc != EOK)
-		return 0;
+		return rc;
 	
 	/* Compute indexes */
@@ -327,9 +326,9 @@
 		inode_table_blocks++;
 	
-	goal = inode_table_first_block + inode_table_blocks;
+	*goal = inode_table_first_block + inode_table_blocks;
 	
 	ext4_filesystem_put_block_group_ref(bg_ref);
 	
-	return goal;
+	return EOK;
 }
 
@@ -349,10 +348,13 @@
 	block_t *bitmap_block;
 	uint32_t rel_block_idx = 0;
+	uint32_t goal;
 	
 	/* Find GOAL */
-	uint32_t goal = ext4_balloc_find_goal(inode_ref);
-	if (goal == 0) {
+	int rc = ext4_balloc_find_goal(inode_ref, &goal);
+	if (rc != EOK)
+		return rc;
+	else if (goal == 0) {
 		/* no goal found => partition is full */
-		return ENOSPC;
+		return ENOMEM;
 	}
 	
@@ -366,5 +368,5 @@
 	/* Load block group reference */
 	ext4_block_group_ref_t *bg_ref;
-	int rc = ext4_filesystem_get_block_group_ref(inode_ref->fs,
+	rc = ext4_filesystem_get_block_group_ref(inode_ref->fs,
 	    block_group, &bg_ref);
 	if (rc != EOK)
