Index: uspace/srv/fs/minixfs/Makefile
===================================================================
--- uspace/srv/fs/minixfs/Makefile	(revision f66d9030ebb758e6eb7f4f0a723049a727101489)
+++ uspace/srv/fs/minixfs/Makefile	(revision 953a823908dc5b5b2bd1b965af4c88c22897c626)
@@ -35,5 +35,5 @@
 SOURCES = \
 	mfs.c \
-	mfs_super.c \
+	mfs_ops.c \
 	mfs_utils.c
 
Index: uspace/srv/fs/minixfs/mfs.h
===================================================================
--- uspace/srv/fs/minixfs/mfs.h	(revision f66d9030ebb758e6eb7f4f0a723049a727101489)
+++ uspace/srv/fs/minixfs/mfs.h	(revision 953a823908dc5b5b2bd1b965af4c88c22897c626)
@@ -35,4 +35,6 @@
 
 #include <minix.h>
+#include <libblock.h>
+#include <adt/list.h>
 #include "../../vfs/vfs.h"
 
@@ -47,9 +49,33 @@
 typedef enum {
 	MFS_VERSION_V1 = 1,
-	MFS_VERSION_V1L,
 	MFS_VERSION_V2,
-	MFS_VERSION_V2L,
 	MFS_VERSION_V3
 } mfs_version_t;
+
+/*Generic MinixFS superblock*/
+struct mfs_sb_info {
+	uint32_t ninodes;
+	uint32_t nzones;
+	unsigned long ibmap_blocks;
+	unsigned long zbmap_blocks;
+	unsigned long firstdatazone;
+	unsigned long itable_size;
+	int log2_zone_size;
+	int ino_per_block;
+	int dirsize;
+	int block_size;
+	int fs_version;
+	uint32_t max_file_size;
+	uint16_t magic;
+	uint16_t state;
+	bool long_names;
+	bool native;
+};
+
+struct mfs_instance {
+	link_t link;
+	devmap_handle_t handle;
+	struct mfs_sb_info *sbi;
+};
 
 extern void mfs_mounted(ipc_callid_t rid, ipc_call_t *request);
Index: uspace/srv/fs/minixfs/mfs_ops.c
===================================================================
--- uspace/srv/fs/minixfs/mfs_ops.c	(revision 953a823908dc5b5b2bd1b965af4c88c22897c626)
+++ uspace/srv/fs/minixfs/mfs_ops.c	(revision 953a823908dc5b5b2bd1b965af4c88c22897c626)
@@ -0,0 +1,219 @@
+/*
+ * Copyright (c) 2011 Maurizio Lombardi
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup fs
+ * @{
+ */
+
+#include <libfs.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <libblock.h>
+#include <fibril_synch.h>
+#include <errno.h>
+#include <adt/list.h>
+#include "mfs.h"
+#include "mfs_utils.h"
+#include "../../vfs/vfs.h"
+
+static bool check_magic_number(uint16_t magic, bool *native,
+				mfs_version_t *version, bool *longfilenames);
+
+static LIST_INITIALIZE(inst_list);
+static FIBRIL_MUTEX_INITIALIZE(inst_list_mutex);
+
+void mfs_mounted(ipc_callid_t rid, ipc_call_t *request)
+{
+	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
+	enum cache_mode cmode;	
+	struct mfs_superblock *sb;
+	struct mfs3_superblock *sb3;
+	struct mfs_sb_info *sbi;
+	struct mfs_instance *instance;
+	bool native, longnames;
+	mfs_version_t version;
+	uint16_t magic;
+
+	/* Accept the mount options */
+	char *opts;
+	int rc = async_data_write_accept((void **) &opts, true, 0, 0, 0, NULL);
+	
+	if (rc != EOK) {
+		mfsdebug("Can't accept async data write\n");
+		async_answer_0(rid, rc);
+		return;
+	}
+
+	/* Check for option enabling write through. */
+	if (str_cmp(opts, "wtcache") == 0)
+		cmode = CACHE_MODE_WT;
+	else
+		cmode = CACHE_MODE_WB;
+
+	free(opts);
+
+	/* initialize libblock */
+	rc = block_init(devmap_handle, 1024);
+	if (rc != EOK) {
+		mfsdebug("libblock initialization failed\n");
+		async_answer_0(rid, rc);
+		return;
+	}
+
+	/*Allocate space for generic MFS superblock*/
+	sbi = (struct mfs_sb_info *) malloc(sizeof(struct mfs_sb_info));
+
+	if (!sbi) {
+		async_answer_0(rid, ENOMEM);
+		return;
+	}
+
+	/*Allocate space for filesystem instance*/
+	instance = (struct mfs_instance *) malloc(sizeof(struct mfs_instance));
+
+	if (!instance) {
+		async_answer_0(rid, ENOMEM);
+		return;
+	}
+
+	sb = (struct mfs_superblock *) malloc(MFS_SUPERBLOCK_SIZE);
+
+	if (!sb) {
+		async_answer_0(rid, ENOMEM);
+		return;
+	}
+
+	/* Read the superblock */
+	rc = block_read_direct(devmap_handle, MFS_SUPERBLOCK << 1, 1, sb);
+	if (rc != EOK) {
+		block_fini(devmap_handle);
+		async_answer_0(rid, rc);
+		return;
+	}
+
+	sb3 = (struct mfs3_superblock *) sb;
+
+	if (check_magic_number(sb->s_magic, &native, &version, &longnames)) {
+		magic = sb->s_magic;
+		goto recognized;
+	}
+
+	if (!check_magic_number(sb3->s_magic, &native, &version, &longnames)) {
+		mfsdebug("magic number not recognized\n");
+		block_fini(devmap_handle);
+		async_answer_0(rid, ENOTSUP);
+		return;
+	}
+
+	magic = sb3->s_magic;
+
+recognized:
+
+	mfsdebug("magic number recognized = %04x\n", magic);
+
+	/*Fill superblock info structure*/
+
+	sbi->fs_version = version;
+	sbi->long_names = longnames;
+	sbi->native = native;
+	sbi->magic = magic;
+
+	if (version == MFS_VERSION_V3) {
+		sbi->ninodes = conv32(native, sb3->s_ninodes);
+		sbi->ibmap_blocks = conv16(native, sb3->s_ibmap_blocks);
+		sbi->zbmap_blocks = conv16(native, sb3->s_zbmap_blocks);
+		sbi->firstdatazone = conv16(native, sb3->s_first_data_zone);
+		sbi->log2_zone_size = conv16(native, sb3->s_log2_zone_size);
+		sbi->max_file_size = conv32(native, sb3->s_max_file_size);
+		sbi->nzones = conv32(native, sb3->s_nzones);
+		sbi->block_size = conv16(native, sb3->s_block_size);
+	} else {
+		sbi->ninodes = conv16(native, sb->s_ninodes);
+		sbi->ibmap_blocks = conv16(native, sb->s_ibmap_blocks);
+		sbi->zbmap_blocks = conv16(native, sb->s_zbmap_blocks);
+		sbi->firstdatazone = conv16(native, sb->s_first_data_zone);
+		sbi->log2_zone_size = conv16(native, sb->s_log2_zone_size);
+		sbi->max_file_size = conv32(native, sb->s_max_file_size);
+		sbi->nzones = conv16(native, sb->s_nzones);
+		if (version == MFS_VERSION_V2)
+			sbi->nzones = conv32(native, sb->s_nzones2);
+	}
+ 
+	free(sb);
+
+	/*Initialize the instance structure and add it to the list*/
+	link_initialize(&instance->link);
+	instance->handle = devmap_handle;
+	instance->sbi = sbi;
+
+	fibril_mutex_lock(&inst_list_mutex);
+	list_append(&instance->link, &inst_list);
+	fibril_mutex_unlock(&inst_list_mutex);
+
+	mfsdebug("mount successful\n");
+
+	async_answer_0(rid, EOK);
+}
+
+static bool check_magic_number(uint16_t magic, bool *native,
+				mfs_version_t *version, bool *longfilenames)
+{
+	*longfilenames = false;
+
+	if (magic == MFS_MAGIC_V1 || magic == MFS_MAGIC_V1R) {
+		*native = magic == MFS_MAGIC_V1;
+		*version = MFS_VERSION_V1;
+		return true;
+	} else if (magic == MFS_MAGIC_V1L || magic == MFS_MAGIC_V1LR) {
+		*native = magic == MFS_MAGIC_V1L;
+		*version = MFS_VERSION_V1;
+		*longfilenames = true;
+		return true;
+	} else if (magic == MFS_MAGIC_V2 || magic == MFS_MAGIC_V2R) {
+		*native = magic == MFS_MAGIC_V2;
+		*version = MFS_VERSION_V2;
+		return true;
+	} else if (magic == MFS_MAGIC_V2L || magic == MFS_MAGIC_V2LR) {
+		*native = magic == MFS_MAGIC_V2L;
+		*version = MFS_VERSION_V2;
+		*longfilenames = true;
+		return true;
+	} else if (magic == MFS_MAGIC_V3 || magic == MFS_MAGIC_V3R) {
+		*native = magic == MFS_MAGIC_V3;
+		*version = MFS_VERSION_V3;
+		return true;
+	}
+
+	return false;
+}
+
+
+/**
+ * @}
+ */ 
+
Index: pace/srv/fs/minixfs/mfs_super.c
===================================================================
--- uspace/srv/fs/minixfs/mfs_super.c	(revision f66d9030ebb758e6eb7f4f0a723049a727101489)
+++ 	(revision )
@@ -1,150 +1,0 @@
-/*
- * Copyright (c) 2011 Maurizio Lombardi
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup fs
- * @{
- */
-
-#include <libfs.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <libblock.h>
-#include <errno.h>
-#include <str.h>
-#include "mfs.h"
-#include "mfs_utils.h"
-#include "../../vfs/vfs.h"
-
-static bool check_magic_number(uint16_t magic, bool *native,
-				mfs_version_t *version, bool *longfilenames);
-
-void mfs_mounted(ipc_callid_t rid, ipc_call_t *request)
-{
-	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
-	enum cache_mode cmode;	
-	struct mfs_superblock *sp;
-	struct mfs3_superblock *sp3;
-	bool native, longnames;
-	mfs_version_t version;
-	uint16_t magic;
-
-	/* Accept the mount options */
-	char *opts;
-	int rc = async_data_write_accept((void **) &opts, true, 0, 0, 0, NULL);
-	
-	if (rc != EOK) {
-		mfsdebug("Can't accept async data write\n");
-		async_answer_0(rid, rc);
-		return;
-	}
-
-	/* Check for option enabling write through. */
-	if (str_cmp(opts, "wtcache") == 0)
-		cmode = CACHE_MODE_WT;
-	else
-		cmode = CACHE_MODE_WB;
-
-	free(opts);
-
-	/* initialize libblock */
-	rc = block_init(devmap_handle, 1024);
-	if (rc != EOK) {
-		mfsdebug("libblock initialization failed\n");
-		async_answer_0(rid, rc);
-		return;
-	}
-
-	sp = (struct mfs_superblock *) malloc(MFS_SUPERBLOCK_SIZE);
-
-	/* Read the superblock */
-	rc = block_read_direct(devmap_handle, MFS_SUPERBLOCK << 1, 1, sp);
-	if (rc != EOK) {
-		block_fini(devmap_handle);
-		async_answer_0(rid, rc);
-		return;
-	}
-
-	if (check_magic_number(sp->s_magic, &native, &version, &longnames)) {
-		magic = sp->s_magic;
-		goto recognized;
-	}
-
-	sp3 = (struct mfs3_superblock *) sp;
-
-	if (!check_magic_number(sp3->s_magic, &native, &version, &longnames)) {
-		mfsdebug("magic number not recognized\n");
-		block_fini(devmap_handle);
-		async_answer_0(rid, ENOTSUP);
-		return;
-	}
-
-	magic = sp3->s_magic;
-
-recognized:
-
-	mfsdebug("magic number recognized = %04x\n", magic);
-	free(sp);
-}
-
-static bool check_magic_number(uint16_t magic, bool *native,
-				mfs_version_t *version, bool *longfilenames)
-{
-	*longfilenames = false;
-
-	if (magic == MFS_MAGIC_V1 || magic == MFS_MAGIC_V1R) {
-		*native = magic == MFS_MAGIC_V1;
-		*version = MFS_VERSION_V1;
-		return true;
-	} else if (magic == MFS_MAGIC_V1L || magic == MFS_MAGIC_V1LR) {
-		*native = magic == MFS_MAGIC_V1L;
-		*version = MFS_VERSION_V1;
-		*longfilenames = true;
-		return true;
-	} else if (magic == MFS_MAGIC_V2 || magic == MFS_MAGIC_V2R) {
-		*native = magic == MFS_MAGIC_V2;
-		*version = MFS_VERSION_V2;
-		return true;
-	} else if (magic == MFS_MAGIC_V2L || magic == MFS_MAGIC_V2LR) {
-		*native = magic == MFS_MAGIC_V2L;
-		*version = MFS_VERSION_V2;
-		*longfilenames = true;
-		return true;
-	} else if (magic == MFS_MAGIC_V3 || magic == MFS_MAGIC_V3R) {
-		*native = magic == MFS_MAGIC_V3;
-		*version = MFS_VERSION_V3;
-		return true;
-	}
-
-	return false;
-}
-
-
-/**
- * @}
- */ 
-
