Index: uspace/lib/ext4/include/ext4/filesystem.h
===================================================================
--- uspace/lib/ext4/include/ext4/filesystem.h	(revision 71fe4723dd438456a0dc65b2244582550f643a9c)
+++ uspace/lib/ext4/include/ext4/filesystem.h	(revision 4bfad3422afe1c140899057793076c94f3bd77db)
@@ -36,10 +36,10 @@
 
 #include <block.h>
+#include "ext4/fstypes.h"
 #include "ext4/types.h"
 
-extern int ext4_filesystem_init(ext4_filesystem_t *, service_id_t,
-    enum cache_mode);
+extern int ext4_filesystem_init(ext4_filesystem_t *, ext4fs_instance_t *,
+    service_id_t, enum cache_mode, aoff64_t *);
 extern int ext4_filesystem_fini(ext4_filesystem_t *);
-extern int ext4_filesystem_check_features(ext4_filesystem_t *, bool *);
 extern uint32_t ext4_filesystem_blockaddr2_index_in_group(ext4_superblock_t *,
     uint32_t);
Index: uspace/lib/ext4/include/ext4/ops.h
===================================================================
--- uspace/lib/ext4/include/ext4/ops.h	(revision 71fe4723dd438456a0dc65b2244582550f643a9c)
+++ uspace/lib/ext4/include/ext4/ops.h	(revision 4bfad3422afe1c140899057793076c94f3bd77db)
@@ -35,4 +35,5 @@
 
 #include <libfs.h>
+#include "ext4/fstypes.h"
 
 extern vfs_out_ops_t ext4fs_ops;
@@ -42,4 +43,7 @@
 extern int ext4fs_global_fini(void);
 
+extern int ext4fs_node_get_core(fs_node_t **, ext4fs_instance_t *, fs_index_t);
+extern int ext4fs_node_put(fs_node_t *);
+
 
 #endif
Index: uspace/lib/ext4/src/balloc.c
===================================================================
--- uspace/lib/ext4/src/balloc.c	(revision 71fe4723dd438456a0dc65b2244582550f643a9c)
+++ uspace/lib/ext4/src/balloc.c	(revision 4bfad3422afe1c140899057793076c94f3bd77db)
@@ -31,5 +31,5 @@
  */
 /**
- * @file  libext4_balloc.c
+ * @file  balloc.c
  * @brief Physical block allocator.
  */
Index: uspace/lib/ext4/src/bitmap.c
===================================================================
--- uspace/lib/ext4/src/bitmap.c	(revision 71fe4723dd438456a0dc65b2244582550f643a9c)
+++ uspace/lib/ext4/src/bitmap.c	(revision 4bfad3422afe1c140899057793076c94f3bd77db)
@@ -31,5 +31,5 @@
  */
 /**
- * @file  libext4_bitmap.c
+ * @file  bitmap.c
  * @brief Ext4 bitmap operations.
  */
Index: uspace/lib/ext4/src/block_group.c
===================================================================
--- uspace/lib/ext4/src/block_group.c	(revision 71fe4723dd438456a0dc65b2244582550f643a9c)
+++ uspace/lib/ext4/src/block_group.c	(revision 4bfad3422afe1c140899057793076c94f3bd77db)
@@ -32,5 +32,5 @@
  */
 /**
- * @file  libext4_block_group.c
+ * @file  block_group.c
  * @brief Ext4 block group structure operations.
  */
Index: uspace/lib/ext4/src/directory.c
===================================================================
--- uspace/lib/ext4/src/directory.c	(revision 71fe4723dd438456a0dc65b2244582550f643a9c)
+++ uspace/lib/ext4/src/directory.c	(revision 4bfad3422afe1c140899057793076c94f3bd77db)
@@ -32,5 +32,5 @@
  */
 /**
- * @file  libext4_directory.c
+ * @file  directory.c
  * @brief Ext4 directory structure operations.
  */
Index: uspace/lib/ext4/src/directory_index.c
===================================================================
--- uspace/lib/ext4/src/directory_index.c	(revision 71fe4723dd438456a0dc65b2244582550f643a9c)
+++ uspace/lib/ext4/src/directory_index.c	(revision 4bfad3422afe1c140899057793076c94f3bd77db)
@@ -31,5 +31,5 @@
  */
 /**
- * @file  libext4_directory_index.c
+ * @file  directory_index.c
  * @brief Ext4 directory index operations.
  */
Index: uspace/lib/ext4/src/extent.c
===================================================================
--- uspace/lib/ext4/src/extent.c	(revision 71fe4723dd438456a0dc65b2244582550f643a9c)
+++ uspace/lib/ext4/src/extent.c	(revision 4bfad3422afe1c140899057793076c94f3bd77db)
@@ -31,5 +31,5 @@
  */
 /**
- * @file  libext4_extent.c
+ * @file  extent.c
  * @brief Ext4 extent structures operations.
  */
Index: uspace/lib/ext4/src/filesystem.c
===================================================================
--- uspace/lib/ext4/src/filesystem.c	(revision 71fe4723dd438456a0dc65b2244582550f643a9c)
+++ uspace/lib/ext4/src/filesystem.c	(revision 4bfad3422afe1c140899057793076c94f3bd77db)
@@ -32,5 +32,5 @@
  */
 /**
- * @file  libext4_filesystem.c
+ * @file  filesystem.c
  * @brief More complex filesystem operations.
  */
@@ -42,4 +42,5 @@
 #include <crypto.h>
 #include <ipc/vfs.h>
+#include <libfs.h>
 #include <stdlib.h>
 #include "ext4/balloc.h"
@@ -50,5 +51,8 @@
 #include "ext4/ialloc.h"
 #include "ext4/inode.h"
+#include "ext4/ops.h"
 #include "ext4/superblock.h"
+
+static int ext4_filesystem_check_features(ext4_filesystem_t *, bool *);
 
 /** Initialize filesystem and read all needed data.
@@ -56,10 +60,15 @@
  * @param fs         Filesystem instance to be initialized
  * @param service_id Identifier if device with the filesystem
- *
- * @return Error code
- *
- */
-int ext4_filesystem_init(ext4_filesystem_t *fs, service_id_t service_id,
-    enum cache_mode cmode)
+ * @param cmode      Cache mode
+ * @param read_only  Place to store read only flag
+ * @param index      Output value - index of root node
+ * @param size       Output value - size of root node
+ * @param lnkcnt     Output value - link count of root node
+ *
+ * @return Error code
+ *
+ */
+int ext4_filesystem_init(ext4_filesystem_t *fs, ext4fs_instance_t *inst,
+    service_id_t service_id, enum cache_mode cmode, aoff64_t *size)
 {
 	int rc;
@@ -118,15 +127,33 @@
 		goto err_2;
 
+	/* Check flags */
+	bool read_only;
+	rc = ext4_filesystem_check_features(fs, &read_only);
+	if (rc != EOK)
+		goto err_2;
+
+	/* Read root node */
+	fs_node_t *root_node;
+	rc = ext4fs_node_get_core(&root_node, inst, EXT4_INODE_ROOT_INDEX);
+	if (rc != EOK)
+		goto err_2;
+
 	/* Mark system as mounted */
 	ext4_superblock_set_state(fs->superblock, EXT4_SUPERBLOCK_STATE_ERROR_FS);
 	rc = ext4_superblock_write_direct(fs->device, fs->superblock);
 	if (rc != EOK)
-		goto err_2;
+		goto err_3;
 
 	uint16_t mnt_count = ext4_superblock_get_mount_count(fs->superblock);
 	ext4_superblock_set_mount_count(fs->superblock, mnt_count + 1);
 
+	ext4fs_node_t *enode = EXT4FS_NODE(root_node);
+	
+	*size = ext4_inode_get_size(fs->superblock, enode->inode_ref->inode);
+
+	ext4fs_node_put(root_node);
 	return EOK;
-
+err_3:
+	ext4fs_node_put(root_node);
 err_2:
 	block_cache_fini(fs->device);
@@ -169,10 +196,12 @@
  *
  * @param fs        Filesystem to be checked
- * @param read_only Flag if filesystem should be mounted only for reading
- *
- * @return Error code
- *
- */
-int ext4_filesystem_check_features(ext4_filesystem_t *fs, bool *read_only)
+ * @param read_only Place to write flag saying whether filesystem
+ *                  should be mounted only for reading
+ *
+ * @return Error code
+ *
+ */
+static int ext4_filesystem_check_features(ext4_filesystem_t *fs,
+    bool *read_only)
 {
 	/* Feature flags are present only in higher revisions */
Index: uspace/lib/ext4/src/hash.c
===================================================================
--- uspace/lib/ext4/src/hash.c	(revision 71fe4723dd438456a0dc65b2244582550f643a9c)
+++ uspace/lib/ext4/src/hash.c	(revision 4bfad3422afe1c140899057793076c94f3bd77db)
@@ -31,5 +31,5 @@
  */
 /**
- * @file  libext4_hash.c
+ * @file  hash.c
  * @brief Hashing algorithms for ext4 HTree.
  */
Index: uspace/lib/ext4/src/ialloc.c
===================================================================
--- uspace/lib/ext4/src/ialloc.c	(revision 71fe4723dd438456a0dc65b2244582550f643a9c)
+++ uspace/lib/ext4/src/ialloc.c	(revision 4bfad3422afe1c140899057793076c94f3bd77db)
@@ -31,5 +31,5 @@
  */
 /**
- * @file  libext4_ialloc.c
+ * @file  ialloc.c
  * @brief I-node (de)allocation operations.
  */
Index: uspace/lib/ext4/src/inode.c
===================================================================
--- uspace/lib/ext4/src/inode.c	(revision 71fe4723dd438456a0dc65b2244582550f643a9c)
+++ uspace/lib/ext4/src/inode.c	(revision 4bfad3422afe1c140899057793076c94f3bd77db)
@@ -32,5 +32,5 @@
  */
 /**
- * @file  libext4_inode.c
+ * @file  inode.c
  * @brief Ext4 i-node structure operations.
  */
Index: uspace/lib/ext4/src/ops.c
===================================================================
--- uspace/lib/ext4/src/ops.c	(revision 71fe4723dd438456a0dc65b2244582550f643a9c)
+++ uspace/lib/ext4/src/ops.c	(revision 4bfad3422afe1c140899057793076c94f3bd77db)
@@ -32,5 +32,5 @@
  */
 /**
- * @file  ext4fs_ops.c
+ * @file  ops.c
  * @brief Operations for ext4 filesystem.
  */
@@ -46,29 +46,5 @@
 #include <ipc/loc.h>
 #include "ext4/ops.h"
-//#include "../../vfs/vfs.h"
-
-#define EXT4FS_NODE(node) \
-	((node) ? (ext4fs_node_t *) (node)->data : NULL)
-
-/**
- * Type for holding an instance of mounted partition.
- */
-typedef struct ext4fs_instance {
-	link_t link;
-	service_id_t service_id;
-	ext4_filesystem_t *filesystem;
-	unsigned int open_nodes_count;
-} ext4fs_instance_t;
-
-/**
- * Type for wrapping common fs_node and add some useful pointers.
- */
-typedef struct ext4fs_node {
-	ext4fs_instance_t *instance;
-	ext4_inode_ref_t *inode_ref;
-	fs_node_t *fs_node;
-	ht_link_t link;
-	unsigned int references;
-} ext4fs_node_t;
+#include "ext4/fstypes.h"
 
 /* Forward declarations of auxiliary functions */
@@ -80,6 +56,4 @@
 static bool ext4fs_is_dots(const uint8_t *, size_t);
 static int ext4fs_instance_get(service_id_t, ext4fs_instance_t **);
-static int ext4fs_node_get_core(fs_node_t **, ext4fs_instance_t *, fs_index_t);
-static int ext4fs_node_put_core(ext4fs_node_t *);
 
 /* Forward declarations of ext4 libfs operations. */
@@ -89,5 +63,5 @@
 static int ext4fs_node_get(fs_node_t **, service_id_t, fs_index_t);
 static int ext4fs_node_open(fs_node_t *);
-static int ext4fs_node_put(fs_node_t *);
+       int ext4fs_node_put(fs_node_t *);
 static int ext4fs_create_node(fs_node_t **, service_id_t, int);
 static int ext4fs_destroy_node(fs_node_t *);
@@ -373,5 +347,5 @@
  *
  */
-int ext4fs_node_put_core(ext4fs_node_t *enode)
+static int ext4fs_node_put_core(ext4fs_node_t *enode)
 {
 	hash_table_remove_item(&open_nodes, &enode->link);
@@ -966,22 +940,4 @@
 		cmode = CACHE_MODE_WB;
 	
-	/* Initialize the filesystem */
-	int rc = ext4_filesystem_init(fs, service_id, cmode);
-	if (rc != EOK) {
-		free(fs);
-		free(inst);
-		return rc;
-	}
-	
-	/* Check flags */
-	bool read_only;
-	rc = ext4_filesystem_check_features(fs, &read_only);
-	if (rc != EOK) {
-		ext4_filesystem_fini(fs);
-		free(fs);
-		free(inst);
-		return rc;
-	}
-	
 	/* Initialize instance */
 	link_initialize(&inst->link);
@@ -990,9 +946,8 @@
 	inst->open_nodes_count = 0;
 	
-	/* Read root node */
-	fs_node_t *root_node;
-	rc = ext4fs_node_get_core(&root_node, inst, EXT4_INODE_ROOT_INDEX);
-	if (rc != EOK) {
-		ext4_filesystem_fini(fs);
+	/* Initialize the filesystem */
+	aoff64_t rnsize;
+	int rc = ext4_filesystem_init(fs, inst, service_id, cmode, &rnsize);
+	if (rc != EOK) {
 		free(fs);
 		free(inst);
@@ -1005,11 +960,9 @@
 	fibril_mutex_unlock(&instance_list_mutex);
 	
-	ext4fs_node_t *enode = EXT4FS_NODE(root_node);
-	
 	*index = EXT4_INODE_ROOT_INDEX;
-	*size = ext4_inode_get_size(fs->superblock, enode->inode_ref->inode);
+	*size = rnsize;
 	*lnkcnt = 1;
 	
-	return ext4fs_node_put(root_node);
+	return EOK;
 }
 
Index: uspace/lib/ext4/src/superblock.c
===================================================================
--- uspace/lib/ext4/src/superblock.c	(revision 71fe4723dd438456a0dc65b2244582550f643a9c)
+++ uspace/lib/ext4/src/superblock.c	(revision 4bfad3422afe1c140899057793076c94f3bd77db)
@@ -33,5 +33,5 @@
 
 /**
- * @file  libext4_superblock.c
+ * @file  superblock.c
  * @brief Ext4 superblock operations.
  */
