Index: boot/Makefile.common
===================================================================
--- boot/Makefile.common	(revision ba519f76cabadd36696f234b3e5208daa288d2ea)
+++ boot/Makefile.common	(revision 3bd76491874404e82b12c2f83eff205011ad8881)
@@ -98,4 +98,5 @@
 	$(USPACE_PATH)/srv/fs/fat/fat \
 	$(USPACE_PATH)/srv/fs/pipefs/pipefs \
+	$(USPACE_PATH)/srv/fs/ext2/ext2 \
 	$(USPACE_PATH)/srv/taskmon/taskmon \
 	$(USPACE_PATH)/srv/hw/netif/dp8390/dp8390 \
Index: uspace/Makefile
===================================================================
--- uspace/Makefile	(revision ba519f76cabadd36696f234b3e5208daa288d2ea)
+++ uspace/Makefile	(revision 3bd76491874404e82b12c2f83eff205011ad8881)
@@ -70,4 +70,5 @@
 	srv/fs/devfs \
 	srv/fs/pipefs \
+	srv/fs/ext2 \
 	srv/hid/adb_mouse \
 	srv/hid/char_mouse \
@@ -140,5 +141,6 @@
 	lib/drv \
 	lib/packet \
-	lib/net
+	lib/net \
+	lib/ext2
 
 LIBC_BUILD = $(addsuffix .build,$(LIBC))
Index: uspace/Makefile.common
===================================================================
--- uspace/Makefile.common	(revision ba519f76cabadd36696f234b3e5208daa288d2ea)
+++ uspace/Makefile.common	(revision 3bd76491874404e82b12c2f83eff205011ad8881)
@@ -86,4 +86,6 @@
 LIBCLUI_PREFIX = $(LIB_PREFIX)/clui
 
+LIBEXT2_PREFIX = $(LIB_PREFIX)/ext2
+
 LIBDRV_PREFIX = $(LIB_PREFIX)/drv
 LIBPACKET_PREFIX = $(LIB_PREFIX)/packet
Index: uspace/lib/ext2/Makefile
===================================================================
--- uspace/lib/ext2/Makefile	(revision 3bd76491874404e82b12c2f83eff205011ad8881)
+++ uspace/lib/ext2/Makefile	(revision 3bd76491874404e82b12c2f83eff205011ad8881)
@@ -0,0 +1,37 @@
+#
+# Copyright (c) 2005 Martin Decky
+# Copyright (c) 2007 Jakub Jermar
+# Copyright (c) 2010 Martin Sucha
+# 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.
+#
+
+USPACE_PREFIX = ../..
+LIBRARY = libext2
+
+SOURCES = \
+	libext2.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/lib/ext2/libext2.c
===================================================================
--- uspace/lib/ext2/libext2.c	(revision 3bd76491874404e82b12c2f83eff205011ad8881)
+++ uspace/lib/ext2/libext2.c	(revision 3bd76491874404e82b12c2f83eff205011ad8881)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2010 Martin Sucha
+ * 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 libext2
+ * @{
+ */
+/**
+ * @file
+ */
+
+#include "libext2.h"
+#include <macros.h>
+#include <errno.h>
+
+/** @}
+ */
Index: uspace/lib/ext2/libext2.h
===================================================================
--- uspace/lib/ext2/libext2.h	(revision 3bd76491874404e82b12c2f83eff205011ad8881)
+++ uspace/lib/ext2/libext2.h	(revision 3bd76491874404e82b12c2f83eff205011ad8881)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2010 Martin Sucha
+ * 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 libext2
+ * @{
+ */
+/**
+ * @file
+ */
+
+#ifndef LIBEXT2_LIBEXT2_H_
+#define LIBEXT2_LIBEXT2_H_
+
+
+
+#endif
+
+/** @}
+ */
Index: uspace/srv/fs/ext2/Makefile
===================================================================
--- uspace/srv/fs/ext2/Makefile	(revision 3bd76491874404e82b12c2f83eff205011ad8881)
+++ uspace/srv/fs/ext2/Makefile	(revision 3bd76491874404e82b12c2f83eff205011ad8881)
@@ -0,0 +1,40 @@
+#
+# Copyright (c) 2005 Martin Decky
+# Copyright (c) 2007 Jakub Jermar
+# Copyright (c) 2010 Martin Sucha
+# 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.
+#
+
+USPACE_PREFIX = ../../..
+LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBFS_PREFIX)/libfs.a $(LIBEXT2_PREFIX)/libext2.a
+EXTRA_CFLAGS += -I$(LIBBLOCK_PREFIX) -I$(LIBFS_PREFIX) -I$(LIBEXT2_PREFIX)
+BINARY = ext2
+
+SOURCES = \
+	ext2.c \
+	ext2_ops.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/srv/fs/ext2/ext2.c
===================================================================
--- uspace/srv/fs/ext2/ext2.c	(revision 3bd76491874404e82b12c2f83eff205011ad8881)
+++ uspace/srv/fs/ext2/ext2.c	(revision 3bd76491874404e82b12c2f83eff205011ad8881)
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2006 Martin Decky
+ * Copyright (c) 2008 Jakub Jermar
+ * 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
+ * @{
+ */ 
+
+/**
+ * @file	ext2.c
+ * @brief	EXT2 file system driver for HelenOS.
+ */
+
+#include "ext2.h"
+#include <ipc/ipc.h>
+#include <ipc/services.h>
+#include <async.h>
+#include <errno.h>
+#include <unistd.h>
+#include <task.h>
+#include <stdio.h>
+#include <libfs.h>
+#include "../../vfs/vfs.h"
+
+#define NAME	"ext2"
+
+vfs_info_t ext2_vfs_info = {
+	.name = NAME,
+};
+
+fs_reg_t ext2_reg;
+
+/**
+ * This connection fibril processes VFS requests from VFS.
+ *
+ * In order to support simultaneous VFS requests, our design is as follows.
+ * The connection fibril accepts VFS requests from VFS. If there is only one
+ * instance of the fibril, VFS will need to serialize all VFS requests it sends
+ * to EXT2. To overcome this bottleneck, VFS can send EXT2 the IPC_M_CONNECT_ME_TO
+ * call. In that case, a new connection fibril will be created, which in turn
+ * will accept the call. Thus, a new phone will be opened for VFS.
+ *
+ * There are few issues with this arrangement. First, VFS can run out of
+ * available phones. In that case, VFS can close some other phones or use one
+ * phone for more serialized requests. Similarily, EXT2 can refuse to duplicate
+ * the connection. VFS should then just make use of already existing phones and
+ * route its requests through them. To avoid paying the fibril creation price 
+ * upon each request, EXT2 might want to keep the connections open after the
+ * request has been completed.
+ */
+static void ext2_connection(ipc_callid_t iid, ipc_call_t *icall)
+{
+	if (iid) {
+		/*
+		 * This only happens for connections opened by
+		 * IPC_M_CONNECT_ME_TO calls as opposed to callback connections
+		 * created by IPC_M_CONNECT_TO_ME.
+		 */
+		ipc_answer_0(iid, EOK);
+	}
+	
+	dprintf(NAME ": connection opened\n");
+	while (1) {
+		ipc_callid_t callid;
+		ipc_call_t call;
+	
+		callid = async_get_call(&call);
+		switch  (IPC_GET_METHOD(call)) {
+		case IPC_M_PHONE_HUNGUP:
+			return;
+		case VFS_OUT_MOUNTED:
+			ext2_mounted(callid, &call);
+			break;
+		case VFS_OUT_MOUNT:
+			ext2_mount(callid, &call);
+			break;
+		case VFS_OUT_UNMOUNTED:
+			ext2_unmounted(callid, &call);
+			break;
+		case VFS_OUT_UNMOUNT:
+			ext2_unmount(callid, &call);
+			break;
+		case VFS_OUT_LOOKUP:
+			ext2_lookup(callid, &call);
+			break;
+		case VFS_OUT_READ:
+			ext2_read(callid, &call);
+			break;
+		case VFS_OUT_WRITE:
+			ext2_write(callid, &call);
+			break;
+		case VFS_OUT_TRUNCATE:
+			ext2_truncate(callid, &call);
+			break;
+		case VFS_OUT_STAT:
+			ext2_stat(callid, &call);
+			break;
+		case VFS_OUT_CLOSE:
+			ext2_close(callid, &call);
+			break;
+		case VFS_OUT_DESTROY:
+			ext2_destroy(callid, &call);
+			break;
+		case VFS_OUT_OPEN_NODE:
+			ext2_open_node(callid, &call);
+			break;
+		case VFS_OUT_SYNC:
+			ext2_sync(callid, &call);
+			break;
+		default:
+			ipc_answer_0(callid, ENOTSUP);
+			break;
+		}
+	}
+}
+
+int main(int argc, char **argv)
+{
+	int vfs_phone;
+	int rc;
+
+	printf(NAME ": HelenOS EXT2 file system server\n");
+
+	vfs_phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_VFS, 0, 0);
+	if (vfs_phone < EOK) {
+		printf(NAME ": failed to connect to VFS\n");
+		return -1;
+	}
+	
+	rc = fs_register(vfs_phone, &ext2_reg, &ext2_vfs_info, ext2_connection);
+	
+	printf(NAME ": Accepting connections\n");
+	task_retval(0);
+	async_manager();
+	/* not reached */
+	return 0;
+}
+
+/**
+ * @}
+ */ 
Index: uspace/srv/fs/ext2/ext2.h
===================================================================
--- uspace/srv/fs/ext2/ext2.h	(revision 3bd76491874404e82b12c2f83eff205011ad8881)
+++ uspace/srv/fs/ext2/ext2.h	(revision 3bd76491874404e82b12c2f83eff205011ad8881)
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2008 Jakub Jermar
+ * 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
+ * @{
+ */ 
+
+#ifndef EXT2_EXT2_H_
+#define EXT2_EXT2_H_
+
+#include <libext2.h>
+#include <ipc/ipc.h>
+#include <fibril_synch.h>
+#include <libfs.h>
+#include <atomic.h>
+#include <sys/types.h>
+#include <bool.h>
+#include "../../vfs/vfs.h"
+
+#ifndef dprintf
+#define dprintf(...)	printf(__VA_ARGS__)
+#endif
+
+#define min(a, b)		((a) < (b) ? (a) : (b))
+
+extern fs_reg_t ext2_reg;
+
+extern void ext2_mounted(ipc_callid_t, ipc_call_t *);
+extern void ext2_mount(ipc_callid_t, ipc_call_t *);
+extern void ext2_unmounted(ipc_callid_t, ipc_call_t *);
+extern void ext2_unmount(ipc_callid_t, ipc_call_t *);
+extern void ext2_lookup(ipc_callid_t, ipc_call_t *);
+extern void ext2_read(ipc_callid_t, ipc_call_t *);
+extern void ext2_write(ipc_callid_t, ipc_call_t *);
+extern void ext2_truncate(ipc_callid_t, ipc_call_t *);
+extern void ext2_stat(ipc_callid_t, ipc_call_t *);
+extern void ext2_close(ipc_callid_t, ipc_call_t *);
+extern void ext2_destroy(ipc_callid_t, ipc_call_t *);
+extern void ext2_open_node(ipc_callid_t, ipc_call_t *);
+extern void ext2_stat(ipc_callid_t, ipc_call_t *);
+extern void ext2_sync(ipc_callid_t, ipc_call_t *);
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/srv/fs/ext2/ext2_ops.c
===================================================================
--- uspace/srv/fs/ext2/ext2_ops.c	(revision 3bd76491874404e82b12c2f83eff205011ad8881)
+++ uspace/srv/fs/ext2/ext2_ops.c	(revision 3bd76491874404e82b12c2f83eff205011ad8881)
@@ -0,0 +1,314 @@
+/*
+ * Copyright (c) 2008 Jakub Jermar
+ * 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
+ * @{
+ */ 
+
+/**
+ * @file	ext2_ops.c
+ * @brief	Implementation of VFS operations for the EXT2 file system server.
+ */
+
+#include "ext2.h"
+#include "../../vfs/vfs.h"
+#include <libfs.h>
+#include <libblock.h>
+#include <libext2.h>
+#include <ipc/ipc.h>
+#include <ipc/services.h>
+#include <ipc/devmap.h>
+#include <macros.h>
+#include <async.h>
+#include <errno.h>
+#include <str.h>
+#include <byteorder.h>
+#include <adt/hash_table.h>
+#include <adt/list.h>
+#include <assert.h>
+#include <fibril_synch.h>
+#include <sys/mman.h>
+#include <align.h>
+
+#define EXT2_NODE(node)	((node) ? (ext2_node_t *) (node)->data : NULL)
+#define FS_NODE(node)	((node) ? (node)->bp : NULL)
+
+/*
+ * Forward declarations of EXT2 libfs operations.
+ */
+static int ext2_root_get(fs_node_t **, devmap_handle_t);
+static int ext2_match(fs_node_t **, fs_node_t *, const char *);
+static int ext2_node_get(fs_node_t **, devmap_handle_t, fs_index_t);
+static int ext2_node_open(fs_node_t *);
+static int ext2_node_put(fs_node_t *);
+static int ext2_create_node(fs_node_t **, devmap_handle_t, int);
+static int ext2_destroy_node(fs_node_t *);
+static int ext2_link(fs_node_t *, fs_node_t *, const char *);
+static int ext2_unlink(fs_node_t *, fs_node_t *, const char *);
+static int ext2_has_children(bool *, fs_node_t *);
+static fs_index_t ext2_index_get(fs_node_t *);
+static aoff64_t ext2_size_get(fs_node_t *);
+static unsigned ext2_lnkcnt_get(fs_node_t *);
+static char ext2_plb_get_char(unsigned);
+static bool ext2_is_directory(fs_node_t *);
+static bool ext2_is_file(fs_node_t *node);
+static devmap_handle_t ext2_device_get(fs_node_t *node);
+
+/*
+ * EXT2 libfs operations.
+ */
+
+int ext2_root_get(fs_node_t **rfn, devmap_handle_t devmap_handle)
+{
+	// TODO
+	return 0;
+	//return ext2_node_get(rfn, devmap_handle, 0);
+}
+
+int ext2_match(fs_node_t **rfn, fs_node_t *pfn, const char *component)
+{
+	// TODO
+	return ENOTSUP;
+}
+
+/** Instantiate a EXT2 in-core node. */
+int ext2_node_get(fs_node_t **rfn, devmap_handle_t devmap_handle, fs_index_t index)
+{
+	// TODO
+	return ENOTSUP;
+}
+
+int ext2_node_open(fs_node_t *fn)
+{
+	/*
+	 * Opening a file is stateless, nothing
+	 * to be done here.
+	 */
+	return EOK;
+}
+
+int ext2_node_put(fs_node_t *fn)
+{
+	// TODO
+	return ENOTSUP;
+}
+
+int ext2_create_node(fs_node_t **rfn, devmap_handle_t devmap_handle, int flags)
+{
+	// TODO
+	return ENOTSUP;
+}
+
+int ext2_destroy_node(fs_node_t *fn)
+{
+	// TODO
+	return ENOTSUP;
+}
+
+int ext2_link(fs_node_t *pfn, fs_node_t *cfn, const char *name)
+{
+	// TODO
+	return ENOTSUP;
+}
+
+int ext2_unlink(fs_node_t *pfn, fs_node_t *cfn, const char *nm)
+{
+	// TODO
+	return ENOTSUP;
+}
+
+int ext2_has_children(bool *has_children, fs_node_t *fn)
+{
+	// TODO
+	return ENOTSUP;
+}
+
+
+fs_index_t ext2_index_get(fs_node_t *fn)
+{
+	// TODO
+	return 0;
+}
+
+aoff64_t ext2_size_get(fs_node_t *fn)
+{
+	// TODO
+	return 0;
+}
+
+unsigned ext2_lnkcnt_get(fs_node_t *fn)
+{
+	// TODO
+	return 0;
+}
+
+char ext2_plb_get_char(unsigned pos)
+{
+	return ext2_reg.plb_ro[pos % PLB_SIZE];
+}
+
+bool ext2_is_directory(fs_node_t *fn)
+{
+	// TODO
+	return false;
+}
+
+bool ext2_is_file(fs_node_t *fn)
+{
+	// TODO
+	return false;
+}
+
+devmap_handle_t ext2_device_get(fs_node_t *node)
+{
+	return 0;
+}
+
+/** libfs operations */
+libfs_ops_t ext2_libfs_ops = {
+	.root_get = ext2_root_get,
+	.match = ext2_match,
+	.node_get = ext2_node_get,
+	.node_open = ext2_node_open,
+	.node_put = ext2_node_put,
+	.create = ext2_create_node,
+	.destroy = ext2_destroy_node,
+	.link = ext2_link,
+	.unlink = ext2_unlink,
+	.has_children = ext2_has_children,
+	.index_get = ext2_index_get,
+	.size_get = ext2_size_get,
+	.lnkcnt_get = ext2_lnkcnt_get,
+	.plb_get_char = ext2_plb_get_char,
+	.is_directory = ext2_is_directory,
+	.is_file = ext2_is_file,
+	.device_get = ext2_device_get
+};
+
+/*
+ * VFS operations.
+ */
+
+void ext2_mounted(ipc_callid_t rid, ipc_call_t *request)
+{
+//	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
+	// TODO
+	ipc_answer_0(rid, ENOTSUP);
+}
+
+void ext2_mount(ipc_callid_t rid, ipc_call_t *request)
+{
+	libfs_mount(&ext2_libfs_ops, ext2_reg.fs_handle, rid, request);
+}
+
+void ext2_unmounted(ipc_callid_t rid, ipc_call_t *request)
+{
+//	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
+	// TODO
+	ipc_answer_0(rid, ENOTSUP);
+}
+
+void ext2_unmount(ipc_callid_t rid, ipc_call_t *request)
+{
+	libfs_unmount(&ext2_libfs_ops, rid, request);
+}
+
+void ext2_lookup(ipc_callid_t rid, ipc_call_t *request)
+{
+	libfs_lookup(&ext2_libfs_ops, ext2_reg.fs_handle, rid, request);
+}
+
+void ext2_read(ipc_callid_t rid, ipc_call_t *request)
+{
+//	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
+//	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
+//	aoff64_t pos =
+//	    (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request));
+	
+	// TODO
+	ipc_answer_0(rid, ENOTSUP);
+}
+
+void ext2_write(ipc_callid_t rid, ipc_call_t *request)
+{
+//	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
+//	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
+//	aoff64_t pos =
+//	    (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request));
+	
+	// TODO
+	ipc_answer_0(rid, ENOTSUP);
+}
+
+void ext2_truncate(ipc_callid_t rid, ipc_call_t *request)
+{
+//	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
+//	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
+//	aoff64_t size =
+//	    (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request));
+	
+	// TODO
+	ipc_answer_0(rid, ENOTSUP);
+}
+
+void ext2_close(ipc_callid_t rid, ipc_call_t *request)
+{
+	ipc_answer_0(rid, EOK);
+}
+
+void ext2_destroy(ipc_callid_t rid, ipc_call_t *request)
+{
+//	devmap_handle_t devmap_handle = (devmap_handle_t)IPC_GET_ARG1(*request);
+//	fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
+	
+	// TODO
+	ipc_answer_0(rid, ENOTSUP);
+}
+
+void ext2_open_node(ipc_callid_t rid, ipc_call_t *request)
+{
+	libfs_open_node(&ext2_libfs_ops, ext2_reg.fs_handle, rid, request);
+}
+
+void ext2_stat(ipc_callid_t rid, ipc_call_t *request)
+{
+	libfs_stat(&ext2_libfs_ops, ext2_reg.fs_handle, rid, request);
+}
+
+void ext2_sync(ipc_callid_t rid, ipc_call_t *request)
+{
+//	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
+//	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
+	
+	// TODO
+	ipc_answer_0(rid, ENOTSUP);
+}
+
+/**
+ * @}
+ */
