Index: uspace/lib/ext4/src/ops.c
===================================================================
--- uspace/lib/ext4/src/ops.c	(revision 1b20da07baaa3e3c424f62c927274e676e4295cd)
+++ uspace/lib/ext4/src/ops.c	(revision a35b458e9db1ca95e679799dc7c1b12c83359ca3)
@@ -117,5 +117,5 @@
 	node_key_t *key = (node_key_t *)key_arg;
 	ext4_node_t *enode = hash_table_get_inst(item, ext4_node_t, link);
-	
+
 	return key->service_id == enode->instance->service_id
 		&& key->index == enode->inode_ref->index;
@@ -142,5 +142,5 @@
 	if (!hash_table_create(&open_nodes, 0, 0, &open_nodes_ops))
 		return ENOMEM;
-	
+
 	return EOK;
 }
@@ -173,10 +173,10 @@
 {
 	fibril_mutex_lock(&instance_list_mutex);
-	
+
 	if (list_empty(&instance_list)) {
 		fibril_mutex_unlock(&instance_list_mutex);
 		return EINVAL;
 	}
-	
+
 	list_foreach(instance_list, link, ext4_instance_t, tmp) {
 		if (tmp->service_id == service_id) {
@@ -186,5 +186,5 @@
 		}
 	}
-	
+
 	fibril_mutex_unlock(&instance_list_mutex);
 	return EINVAL;
@@ -219,9 +219,9 @@
 	ext4_node_t *eparent = EXT4_NODE(pfn);
 	ext4_filesystem_t *fs = eparent->instance->filesystem;
-	
+
 	if (!ext4_inode_is_type(fs->superblock, eparent->inode_ref->inode,
 	    EXT4_INODE_MODE_DIRECTORY))
 		return ENOTDIR;
-	
+
 	/* Try to find entry */
 	ext4_directory_search_result_t result;
@@ -233,8 +233,8 @@
 			return EOK;
 		}
-		
-		return rc;
-	}
-	
+
+		return rc;
+	}
+
 	/* Load node from search result */
 	uint32_t inode = ext4_directory_entry_ll_get_inode(result.dentry);
@@ -268,5 +268,5 @@
 	if (rc != EOK)
 		return rc;
-	
+
 	return ext4_node_get_core(rfn, inst, index);
 }
@@ -285,5 +285,5 @@
 {
 	fibril_mutex_lock(&open_nodes_lock);
-	
+
 	/* Check if the node is not already open */
 	node_key_t key = {
@@ -291,5 +291,5 @@
 		.index = index
 	};
-	
+
 	ht_link_t *already_open = hash_table_find(&open_nodes, &key);
 	ext4_node_t *enode = NULL;
@@ -298,9 +298,9 @@
 		*rfn = enode->fs_node;
 		enode->references++;
-		
+
 		fibril_mutex_unlock(&open_nodes_lock);
 		return EOK;
 	}
-	
+
 	/* Prepare new enode */
 	enode = malloc(sizeof(ext4_node_t));
@@ -309,5 +309,5 @@
 		return ENOMEM;
 	}
-	
+
 	/* Prepare new fs_node and initialize */
 	fs_node_t *fs_node = malloc(sizeof(fs_node_t));
@@ -317,7 +317,7 @@
 		return ENOMEM;
 	}
-	
+
 	fs_node_initialize(fs_node);
-	
+
 	/* Load i-node from filesystem */
 	ext4_inode_ref_t *inode_ref;
@@ -330,5 +330,5 @@
 		return rc;
 	}
-	
+
 	/* Initialize enode */
 	enode->inode_ref = inode_ref;
@@ -336,13 +336,13 @@
 	enode->references = 1;
 	enode->fs_node = fs_node;
-	
+
 	fs_node->data = enode;
 	*rfn = fs_node;
-	
+
 	hash_table_insert(&open_nodes, &enode->link);
 	inst->open_nodes_count++;
-	
+
 	fibril_mutex_unlock(&open_nodes_lock);
-	
+
 	return EOK;
 }
@@ -360,14 +360,14 @@
 	assert(enode->instance->open_nodes_count > 0);
 	enode->instance->open_nodes_count--;
-	
+
 	/* Put inode back in filesystem */
 	errno_t rc = ext4_filesystem_put_inode_ref(enode->inode_ref);
 	if (rc != EOK)
 		return rc;
-	
+
 	/* Destroy data structure */
 	free(enode->fs_node);
 	free(enode);
-	
+
 	return EOK;
 }
@@ -399,5 +399,5 @@
 {
 	fibril_mutex_lock(&open_nodes_lock);
-	
+
 	ext4_node_t *enode = EXT4_NODE(fn);
 	assert(enode->references > 0);
@@ -410,7 +410,7 @@
 		}
 	}
-	
+
 	fibril_mutex_unlock(&open_nodes_lock);
-	
+
 	return EOK;
 }
@@ -432,5 +432,5 @@
 	if (enode == NULL)
 		return ENOMEM;
-	
+
 	/* Allocate fs_node */
 	fs_node_t *fs_node;
@@ -440,5 +440,5 @@
 		return ENOMEM;
 	}
-	
+
 	/* Load instance */
 	ext4_instance_t *inst;
@@ -449,5 +449,5 @@
 		return rc;
 	}
-	
+
 	/* Allocate new i-node in filesystem */
 	ext4_inode_ref_t *inode_ref;
@@ -458,22 +458,22 @@
 		return rc;
 	}
-	
+
 	/* Do some interconnections in references */
 	enode->inode_ref = inode_ref;
 	enode->instance = inst;
 	enode->references = 1;
-	
+
 	fibril_mutex_lock(&open_nodes_lock);
 	hash_table_insert(&open_nodes, &enode->link);
 	fibril_mutex_unlock(&open_nodes_lock);
 	inst->open_nodes_count++;
-	
+
 	enode->inode_ref->dirty = true;
-	
+
 	fs_node_initialize(fs_node);
 	fs_node->data = enode;
 	enode->fs_node = fs_node;
 	*rfn = fs_node;
-	
+
 	return EOK;
 }
@@ -495,13 +495,13 @@
 		return rc;
 	}
-	
+
 	if (has_children) {
 		ext4_node_put(fn);
 		return EINVAL;
 	}
-	
+
 	ext4_node_t *enode = EXT4_NODE(fn);
 	ext4_inode_ref_t *inode_ref = enode->inode_ref;
-	
+
 	/* Release data blocks */
 	rc = ext4_filesystem_truncate_inode(inode_ref, 0);
@@ -510,5 +510,5 @@
 		return rc;
 	}
-	
+
 	/*
 	 * TODO: Sset real deletion time when it will be supported.
@@ -517,5 +517,5 @@
 	ext4_inode_set_deletion_time(inode_ref->inode, 0xdeadbeef);
 	inode_ref->dirty = true;
-	
+
 	/* Free inode */
 	rc = ext4_filesystem_free_inode(inode_ref);
@@ -524,5 +524,5 @@
 		return rc;
 	}
-	
+
 	return ext4_node_put(fn);
 }
@@ -542,9 +542,9 @@
 	if (str_size(name) > EXT4_DIRECTORY_FILENAME_LEN)
 		return ENAMETOOLONG;
-	
+
 	ext4_node_t *parent = EXT4_NODE(pfn);
 	ext4_node_t *child = EXT4_NODE(cfn);
 	ext4_filesystem_t *fs = parent->instance->filesystem;
-	
+
 	/* Add entry to parent directory */
 	errno_t rc = ext4_directory_add_entry(parent->inode_ref, name,
@@ -552,5 +552,5 @@
 	if (rc != EOK)
 		return rc;
-	
+
 	/* Fill new dir -> add '.' and '..' entries */
 	if (ext4_inode_is_type(fs->superblock, child->inode_ref->inode,
@@ -562,5 +562,5 @@
 			return rc;
 		}
-		
+
 		rc = ext4_directory_add_entry(child->inode_ref, "..",
 		    parent->inode_ref);
@@ -570,5 +570,5 @@
 			return rc;
 		}
-		
+
 		/* Initialize directory index if supported */
 		if (ext4_superblock_has_feature_compatible(fs->superblock,
@@ -577,25 +577,25 @@
 			if (rc != EOK)
 				return rc;
-			
+
 			ext4_inode_set_flag(child->inode_ref->inode,
 			    EXT4_INODE_FLAG_INDEX);
 			child->inode_ref->dirty = true;
 		}
-	
+
 		uint16_t parent_links =
 		    ext4_inode_get_links_count(parent->inode_ref->inode);
 		parent_links++;
 		ext4_inode_set_links_count(parent->inode_ref->inode, parent_links);
-		
+
 		parent->inode_ref->dirty = true;
 	}
-	
+
 	uint16_t child_links =
 	    ext4_inode_get_links_count(child->inode_ref->inode);
 	child_links++;
 	ext4_inode_set_links_count(child->inode_ref->inode, child_links);
-	
+
 	child->inode_ref->dirty = true;
-	
+
 	return EOK;
 }
@@ -616,9 +616,9 @@
 	if (rc != EOK)
 		return rc;
-	
+
 	/* Cannot unlink non-empty node */
 	if (has_children)
 		return ENOTEMPTY;
-	
+
 	/* Remove entry from parent directory */
 	ext4_inode_ref_t *parent = EXT4_NODE(pfn)->inode_ref;
@@ -626,26 +626,26 @@
 	if (rc != EOK)
 		return rc;
-	
+
 	/* Decrement links count */
 	ext4_inode_ref_t *child_inode_ref = EXT4_NODE(cfn)->inode_ref;
-	
+
 	uint32_t lnk_count =
 	    ext4_inode_get_links_count(child_inode_ref->inode);
 	lnk_count--;
-	
+
 	/* If directory - handle links from parent */
 	if ((lnk_count <= 1) && (ext4_is_directory(cfn))) {
 		assert(lnk_count == 1);
-		
+
 		lnk_count--;
-		
+
 		ext4_inode_ref_t *parent_inode_ref = EXT4_NODE(pfn)->inode_ref;
-		
+
 		uint32_t parent_lnk_count = ext4_inode_get_links_count(
 		    parent_inode_ref->inode);
-		
+
 		parent_lnk_count--;
 		ext4_inode_set_links_count(parent_inode_ref->inode, parent_lnk_count);
-		
+
 		parent->dirty = true;
 	}
@@ -659,5 +659,5 @@
 	 * parent->dirty = true;
 	 */
-	
+
 	/*
 	 * TODO: Update timestamp for inode.
@@ -666,8 +666,8 @@
 	 *     (uint32_t) now);
 	 */
-	
+
 	ext4_inode_set_links_count(child_inode_ref->inode, lnk_count);
 	child_inode_ref->dirty = true;
-	
+
 	return EOK;
 }
@@ -687,5 +687,5 @@
 	ext4_node_t *enode = EXT4_NODE(fn);
 	ext4_filesystem_t *fs = enode->instance->filesystem;
-	
+
 	/* Check if node is directory */
 	if (!ext4_inode_is_type(fs->superblock, enode->inode_ref->inode,
@@ -694,10 +694,10 @@
 		return EOK;
 	}
-	
+
 	ext4_directory_iterator_t it;
 	errno_t rc = ext4_directory_iterator_init(&it, enode->inode_ref, 0);
 	if (rc != EOK)
 		return rc;
-	
+
 	/* Find a non-empty directory entry */
 	bool found = false;
@@ -712,5 +712,5 @@
 			}
 		}
-		
+
 		rc = ext4_directory_iterator_next(&it);
 		if (rc != EOK) {
@@ -719,11 +719,11 @@
 		}
 	}
-	
+
 	rc = ext4_directory_iterator_fini(&it);
 	if (rc != EOK)
 		return rc;
-	
+
 	*has_children = found;
-	
+
 	return EOK;
 }
@@ -767,5 +767,5 @@
 	ext4_node_t *enode = EXT4_NODE(fn);
 	uint32_t lnkcnt = ext4_inode_get_links_count(enode->inode_ref->inode);
-	
+
 	if (ext4_is_directory(fn)) {
 		if (lnkcnt > 1)
@@ -774,5 +774,5 @@
 			return 0;
 	}
-	
+
 	/* For regular files return real links count */
 	return lnkcnt;
@@ -790,5 +790,5 @@
 	ext4_node_t *enode = EXT4_NODE(fn);
 	ext4_superblock_t *sb = enode->instance->filesystem->superblock;
-	
+
 	return ext4_inode_is_type(sb, enode->inode_ref->inode,
 	    EXT4_INODE_MODE_DIRECTORY);
@@ -806,5 +806,5 @@
 	ext4_node_t *enode = EXT4_NODE(fn);
 	ext4_superblock_t *sb = enode->instance->filesystem->superblock;
-	
+
 	return ext4_inode_is_type(sb, enode->inode_ref->inode,
 	    EXT4_INODE_MODE_FILE);
@@ -928,5 +928,5 @@
 {
 	ext4_filesystem_t *fs;
-	
+
 	/* Allocate instance structure */
 	ext4_instance_t *inst = (ext4_instance_t *)
@@ -934,5 +934,5 @@
 	if (inst == NULL)
 		return ENOMEM;
-	
+
 	enum cache_mode cmode;
 	if (str_cmp(opts, "wtcache") == 0)
@@ -940,10 +940,10 @@
 	else
 		cmode = CACHE_MODE_WB;
-	
+
 	/* Initialize instance */
 	link_initialize(&inst->link);
 	inst->service_id = service_id;
 	inst->open_nodes_count = 0;
-	
+
 	/* Initialize the filesystem */
 	aoff64_t rnsize;
@@ -953,13 +953,13 @@
 		return rc;
 	}
-	
+
 	/* Add instance to the list */
 	fibril_mutex_lock(&instance_list_mutex);
 	list_append(&inst->link, &instance_list);
 	fibril_mutex_unlock(&instance_list_mutex);
-	
+
 	*index = EXT4_INODE_ROOT_INDEX;
 	*size = rnsize;
-	
+
 	return EOK;
 }
@@ -980,19 +980,19 @@
 	if (rc != EOK)
 		return rc;
-	
+
 	fibril_mutex_lock(&open_nodes_lock);
-	
+
 	if (inst->open_nodes_count != 0) {
 		fibril_mutex_unlock(&open_nodes_lock);
 		return EBUSY;
 	}
-	
+
 	/* Remove the instance from the list */
 	fibril_mutex_lock(&instance_list_mutex);
 	list_remove(&inst->link);
 	fibril_mutex_unlock(&instance_list_mutex);
-	
+
 	fibril_mutex_unlock(&open_nodes_lock);
-	
+
 	rc = ext4_filesystem_close(inst->filesystem);
 	if (rc != EOK) {
@@ -1028,5 +1028,5 @@
 		return EINVAL;
 	}
-	
+
 	ext4_instance_t *inst;
 	errno_t rc = ext4_instance_get(service_id, &inst);
@@ -1035,5 +1035,5 @@
 		return rc;
 	}
-	
+
 	/* Load i-node */
 	ext4_inode_ref_t *inode_ref;
@@ -1043,5 +1043,5 @@
 		return rc;
 	}
-	
+
 	/* Read from i-node by type */
 	if (ext4_inode_is_type(inst->filesystem->superblock, inode_ref->inode,
@@ -1058,7 +1058,7 @@
 		rc = ENOTSUP;
 	}
-	
+
 	errno_t const rc2 = ext4_filesystem_put_inode_ref(inode_ref);
-	
+
 	return rc == EOK ? rc2 : rc;
 }
@@ -1076,8 +1076,8 @@
 	if ((name_size == 1) && (name[0] == '.'))
 		return true;
-	
+
 	if ((name_size == 2) && (name[0] == '.') && (name[1] == '.'))
 		return true;
-	
+
 	return false;
 }
@@ -1104,5 +1104,5 @@
 		return rc;
 	}
-	
+
 	/*
 	 * Find next interesting directory entry.
@@ -1114,12 +1114,12 @@
 		if (it.current->inode == 0)
 			goto skip;
-		
+
 		uint16_t name_size = ext4_directory_entry_ll_get_name_length(
 		    inst->filesystem->superblock, it.current);
-		
+
 		/* Skip . and .. */
 		if (ext4_is_dots(it.current->name, name_size))
 			goto skip;
-		
+
 		/*
 		 * The on-disk entry does not contain \0 at the end
@@ -1133,13 +1133,13 @@
 			return ENOMEM;
 		}
-		
+
 		memcpy(buf, &it.current->name, name_size);
 		*(buf + name_size) = 0;
 		found = true;
-		
+
 		(void) async_data_read_finalize(callid, buf, name_size + 1);
 		free(buf);
 		break;
-		
+
 skip:
 		rc = ext4_directory_iterator_next(&it);
@@ -1150,5 +1150,5 @@
 		}
 	}
-	
+
 	uint64_t next;
 	if (found) {
@@ -1156,12 +1156,12 @@
 		if (rc != EOK)
 			return rc;
-		
+
 		next = it.current_offset;
 	}
-	
+
 	rc = ext4_directory_iterator_fini(&it);
 	if (rc != EOK)
 		return rc;
-	
+
 	/* Prepare return values */
 	if (found) {
@@ -1191,5 +1191,5 @@
 	ext4_superblock_t *sb = inst->filesystem->superblock;
 	uint64_t file_size = ext4_inode_get_size(sb, inode_ref->inode);
-	
+
 	if (pos >= file_size) {
 		/* Read 0 bytes successfully */
@@ -1198,5 +1198,5 @@
 		return EOK;
 	}
-	
+
 	/* For now, we only read data from one block at a time */
 	uint32_t block_size = ext4_superblock_get_block_size(sb);
@@ -1204,9 +1204,9 @@
 	uint32_t offset_in_block = pos % block_size;
 	uint32_t bytes = min(block_size - offset_in_block, size);
-	
+
 	/* Handle end of file */
 	if (pos + bytes > file_size)
 		bytes = file_size - pos;
-	
+
 	/* Get the real block number */
 	uint32_t fs_block;
@@ -1217,5 +1217,5 @@
 		return rc;
 	}
-	
+
 	/*
 	 * Check for sparse file.
@@ -1231,14 +1231,14 @@
 			return ENOMEM;
 		}
-		
+
 		memset(buffer, 0, bytes);
-		
+
 		rc = async_data_read_finalize(callid, buffer, bytes);
 		*rbytes = bytes;
-		
+
 		free(buffer);
 		return rc;
 	}
-	
+
 	/* Usual case - we need to read a block from device */
 	block_t *block;
@@ -1248,5 +1248,5 @@
 		return rc;
 	}
-	
+
 	assert(offset_in_block + bytes <= block_size);
 	rc = async_data_read_finalize(callid, block->data + offset_in_block, bytes);
@@ -1255,9 +1255,9 @@
 		return rc;
 	}
-	
+
 	rc = block_put(block);
 	if (rc != EOK)
 		return rc;
-	
+
 	*rbytes = bytes;
 	return EOK;
@@ -1282,5 +1282,5 @@
 	if (rc != EOK)
 		return rc;
-	
+
 	ipc_callid_t callid;
 	size_t len;
@@ -1290,20 +1290,20 @@
 		goto exit;
 	}
-	
+
 	ext4_node_t *enode = EXT4_NODE(fn);
 	ext4_filesystem_t *fs = enode->instance->filesystem;
-	
+
 	uint32_t block_size = ext4_superblock_get_block_size(fs->superblock);
-	
+
 	/* Prevent writing to more than one block */
 	uint32_t bytes = min(len, block_size - (pos % block_size));
-	
+
 	int flags = BLOCK_FLAGS_NONE;
 	if (bytes == block_size)
 		flags = BLOCK_FLAGS_NOREAD;
-	
+
 	uint32_t iblock =  pos / block_size;
 	uint32_t fblock;
-	
+
 	/* Load inode */
 	ext4_inode_ref_t *inode_ref = enode->inode_ref;
@@ -1314,5 +1314,5 @@
 		goto exit;
 	}
-	
+
 	/* Check for sparse file */
 	if (fblock == 0) {
@@ -1323,5 +1323,5 @@
 			    ext4_inode_get_size(fs->superblock, inode_ref->inode) /
 			    block_size;
-			
+
 			while (last_iblock < iblock) {
 				rc = ext4_extent_append_block(inode_ref, &last_iblock,
@@ -1332,5 +1332,5 @@
 				}
 			}
-			
+
 			rc = ext4_extent_append_block(inode_ref, &last_iblock,
 			    &fblock, false);
@@ -1345,5 +1345,5 @@
 				goto exit;
 			}
-			
+
 			rc = ext4_filesystem_set_inode_data_block_index(inode_ref,
 			    iblock, fblock);
@@ -1354,9 +1354,9 @@
 			}
 		}
-		
+
 		flags = BLOCK_FLAGS_NOREAD;
 		inode_ref->dirty = true;
 	}
-	
+
 	/* Load target block */
 	block_t *write_block;
@@ -1366,5 +1366,5 @@
 		goto exit;
 	}
-	
+
 	if (flags == BLOCK_FLAGS_NOREAD)
 		memset(write_block->data, 0, block_size);
@@ -1419,11 +1419,11 @@
 	if (rc != EOK)
 		return rc;
-	
+
 	ext4_node_t *enode = EXT4_NODE(fn);
 	ext4_inode_ref_t *inode_ref = enode->inode_ref;
-	
+
 	rc = ext4_filesystem_truncate_inode(inode_ref, new_size);
 	errno_t const rc2 = ext4_node_put(fn);
-	
+
 	return rc == EOK ? rc2 : rc;
 }
@@ -1456,5 +1456,5 @@
 	if (rc != EOK)
 		return rc;
-	
+
 	/* Destroy the inode */
 	return ext4_destroy_node(fn);
@@ -1473,8 +1473,8 @@
 	if (rc != EOK)
 		return rc;
-	
+
 	ext4_node_t *enode = EXT4_NODE(fn);
 	enode->inode_ref->dirty = true;
-	
+
 	return ext4_node_put(fn);
 }
