Index: uspace/srv/vfs/vfs_ops.c
===================================================================
--- uspace/srv/vfs/vfs_ops.c	(revision 228e490270cec3d6a6de666f61839f0d9ed5f193)
+++ uspace/srv/vfs/vfs_ops.c	(revision 4fe94c669d1b57c6e7167bd6698ff567b70797ca)
@@ -491,9 +491,4 @@
 void vfs_open(ipc_callid_t rid, ipc_call_t *request)
 {
-	if (!vfs_files_init()) {
-		ipc_answer_0(rid, ENOMEM);
-		return;
-	}
-	
 	/*
 	 * The POSIX interface is open(path, oflag, mode).
@@ -609,4 +604,5 @@
 	vfs_node_addref(node);
 	vfs_node_put(node);
+	vfs_file_put(file);
 	
 	/* Success! Return the new file descriptor to the client. */
@@ -617,9 +613,4 @@
 {
 	// FIXME: check for sanity of the supplied fs, dev and index
-	
-	if (!vfs_files_init()) {
-		ipc_answer_0(rid, ENOMEM);
-		return;
-	}
 	
 	/*
@@ -686,4 +677,5 @@
 	vfs_node_addref(node);
 	vfs_node_put(node);
+	vfs_file_put(file);
 	
 	/* Success! Return the new file descriptor to the client. */
@@ -721,5 +713,6 @@
 	vfs_release_phone(file->node->fs_handle, fs_phone);
 	fibril_mutex_unlock(&file->lock);
-	
+
+	vfs_file_put(file);
 	ipc_answer_0(rid, rc);
 }
@@ -775,4 +768,5 @@
 		ipc_answer_0(rid, ret);
 	
+	vfs_file_put(file);
 	ret = vfs_fd_free(fd);
 	ipc_answer_0(rid, ret);
@@ -875,5 +869,6 @@
 		file->pos += bytes;
 	fibril_mutex_unlock(&file->lock);
-	
+	vfs_file_put(file);	
+
 	/*
 	 * FS server's reply is the final result of the whole operation we
@@ -915,4 +910,5 @@
 			file->pos = (aoff64_t) off;
 			fibril_mutex_unlock(&file->lock);
+			vfs_file_put(file);
 			ipc_answer_1(rid, EOK, off);
 			return;
@@ -922,4 +918,5 @@
 		if ((off >= 0) && (file->pos + off < file->pos)) {
 			fibril_mutex_unlock(&file->lock);
+			vfs_file_put(file);
 			ipc_answer_0(rid, EOVERFLOW);
 			return;
@@ -928,4 +925,5 @@
 		if ((off < 0) && (file->pos < (aoff64_t) -off)) {
 			fibril_mutex_unlock(&file->lock);
+			vfs_file_put(file);
 			ipc_answer_0(rid, EOVERFLOW);
 			return;
@@ -936,4 +934,5 @@
 		
 		fibril_mutex_unlock(&file->lock);
+		vfs_file_put(file);
 		ipc_answer_2(rid, EOK, LOWER32(newoff),
 		    UPPER32(newoff));
@@ -946,4 +945,5 @@
 			fibril_rwlock_read_unlock(&file->node->contents_rwlock);
 			fibril_mutex_unlock(&file->lock);
+			vfs_file_put(file);
 			ipc_answer_0(rid, EOVERFLOW);
 			return;
@@ -953,4 +953,5 @@
 			fibril_rwlock_read_unlock(&file->node->contents_rwlock);
 			fibril_mutex_unlock(&file->lock);
+			vfs_file_put(file);
 			ipc_answer_0(rid, EOVERFLOW);
 			return;
@@ -962,4 +963,5 @@
 		fibril_rwlock_read_unlock(&file->node->contents_rwlock);
 		fibril_mutex_unlock(&file->lock);
+		vfs_file_put(file);
 		ipc_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff));
 		return;
@@ -967,4 +969,5 @@
 	
 	fibril_mutex_unlock(&file->lock);
+	vfs_file_put(file);
 	ipc_answer_0(rid, EINVAL);
 }
@@ -1005,4 +1008,5 @@
 
 	fibril_mutex_unlock(&file->lock);
+	vfs_file_put(file);
 	ipc_answer_0(rid, (sysarg_t)rc);
 }
@@ -1021,4 +1025,5 @@
 	ipc_callid_t callid;
 	if (!async_data_read_receive(&callid, NULL)) {
+		vfs_file_put(file);
 		ipc_answer_0(callid, EINVAL);
 		ipc_answer_0(rid, EINVAL);
@@ -1038,4 +1043,5 @@
 
 	fibril_mutex_unlock(&file->lock);
+	vfs_file_put(file);
 	ipc_answer_0(rid, rc);
 }
@@ -1339,14 +1345,14 @@
 	int newfd = IPC_GET_ARG2(*request);
 	
+	/* If the file descriptors are the same, do nothing. */
+	if (oldfd == newfd) {
+		ipc_answer_1(rid, EOK, newfd);
+		return;
+	}
+	
 	/* Lookup the file structure corresponding to oldfd. */
 	vfs_file_t *oldfile = vfs_file_get(oldfd);
 	if (!oldfile) {
 		ipc_answer_0(rid, EBADF);
-		return;
-	}
-	
-	/* If the file descriptors are the same, do nothing. */
-	if (oldfd == newfd) {
-		ipc_answer_1(rid, EOK, newfd);
 		return;
 	}
@@ -1365,4 +1371,6 @@
 		if (ret != EOK) {
 			fibril_mutex_unlock(&oldfile->lock);
+			vfs_file_put(oldfile);
+			vfs_file_put(newfile);
 			ipc_answer_0(rid, ret);
 			return;
@@ -1372,7 +1380,10 @@
 		if (ret != EOK) {
 			fibril_mutex_unlock(&oldfile->lock);
+			vfs_file_put(oldfile);
+			vfs_file_put(newfile);
 			ipc_answer_0(rid, ret);
 			return;
 		}
+		vfs_file_put(newfile);
 	}
 	
@@ -1380,4 +1391,5 @@
 	int ret = vfs_fd_assign(oldfile, newfd);
 	fibril_mutex_unlock(&oldfile->lock);
+	vfs_file_put(oldfile);
 	
 	if (ret != EOK)
