Index: boot/Makefile.common
===================================================================
--- boot/Makefile.common	(revision 60c6fe0bc7a9f915cda97036566ce48b351e2e45)
+++ boot/Makefile.common	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
@@ -106,4 +106,5 @@
 	$(USPACE_PATH)/srv/fs/exfat/exfat \
 	$(USPACE_PATH)/srv/fs/ext2fs/ext2fs \
+	$(USPACE_PATH)/srv/fs/ext4fs/ext4fs \
 	$(USPACE_PATH)/srv/taskmon/taskmon \
 	$(USPACE_PATH)/srv/hw/netif/ne2000/ne2000 \
Index: uspace/Makefile
===================================================================
--- uspace/Makefile	(revision 60c6fe0bc7a9f915cda97036566ce48b351e2e45)
+++ uspace/Makefile	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
@@ -88,4 +88,5 @@
 	srv/fs/locfs \
 	srv/fs/ext2fs \
+	srv/fs/ext4fs \
 	srv/hid/console \
 	srv/hid/s3c24xx_ts \
@@ -190,4 +191,5 @@
 	lib/net \
 	lib/ext2 \
+	lib/ext4 \
 	lib/usb \
 	lib/usbhost \
Index: uspace/Makefile.common
===================================================================
--- uspace/Makefile.common	(revision 60c6fe0bc7a9f915cda97036566ce48b351e2e45)
+++ uspace/Makefile.common	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
@@ -115,4 +115,5 @@
 
 LIBEXT2_PREFIX = $(LIB_PREFIX)/ext2
+LIBEXT4_PREFIX = $(LIB_PREFIX)/ext4
 
 LIBUSB_PREFIX = $(LIB_PREFIX)/usb
Index: uspace/lib/ext4/Makefile
===================================================================
--- uspace/lib/ext4/Makefile	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
+++ uspace/lib/ext4/Makefile	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
@@ -0,0 +1,42 @@
+#
+# Copyright (c) 2011 Frantisek Princ
+# 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 = libext4
+EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX)
+LIBS = $(LIBBLOCK_PREFIX)/libblock.a
+
+SOURCES = \
+	libext4_block_group.c \
+	libext4_directory.c \
+	libext4_filesystem.c \
+	libext4_inode.c \
+	libext4_superblock.c
+	
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/lib/ext4/libext4.h
===================================================================
--- uspace/lib/ext4/libext4.h	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
+++ uspace/lib/ext4/libext4.h	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2011 Frantisek Princ
+ * 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 libext4
+ * @{
+ */ 
+
+#ifndef LIBEXT4_LIBEXT4_H_
+#define LIBEXT4_LIBEXT4_H_
+
+#include "libext4_block_group.h"
+#include "libext4_directory.h"
+#include "libext4_filesystem.h"
+#include "libext4_inode.h"
+#include "libext4_superblock.h"
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/lib/ext4/libext4_block_group.c
===================================================================
--- uspace/lib/ext4/libext4_block_group.c	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
+++ uspace/lib/ext4/libext4_block_group.c	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2011 Frantisek Princ
+ * 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 libext4
+ * @{
+ */ 
+
+/**
+ * @file	libext4_block_group.c
+ * @brief	TODO
+ */
+
+#include "libext4_block_group.h"
+
+
+/**
+ * @}
+ */ 
Index: uspace/lib/ext4/libext4_block_group.h
===================================================================
--- uspace/lib/ext4/libext4_block_group.h	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
+++ uspace/lib/ext4/libext4_block_group.h	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2011 Frantisek Princ
+ * 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 libext4
+ * @{
+ */ 
+
+#ifndef LIBEXT4_LIBEXT4_BLOCK_GROUP_H_
+#define LIBEXT4_LIBEXT4_BLOCK_GROUP_H_
+
+#include <sys/types.h>
+
+/*
+ * Structure of a blocks group descriptor
+ */
+typedef struct ext4_block_group {
+	uint32_t bg_block_bitmap_lo; // Blocks bitmap block
+	uint32_t bg_inode_bitmap_lo; // Inodes bitmap block
+	uint32_t bg_inode_table_lo; // Inodes table block
+	uint16_t bg_free_blocks_count_lo; // Free blocks count
+	uint16_t bg_free_inodes_count_lo; // Free inodes count
+	uint16_t bg_used_dirs_count_lo; // Directories count
+	uint16_t bg_flags; // EXT4_BG_flags (INODE_UNINIT, etc)
+	uint32_t bg_reserved[2]; // Likely block/inode bitmap checksum
+	uint16_t bg_itable_unused_lo; // Unused inodes count
+	uint16_t bg_checksum; // crc16(sb_uuid+group+desc)
+	uint32_t bg_block_bitmap_hi; // Blocks bitmap block MSB
+	uint32_t bg_inode_bitmap_hi; // Inodes bitmap block MSB
+	uint32_t bg_inode_table_hi; // Inodes table block MSB
+	uint16_t bg_free_blocks_count_hi; // Free blocks count MSB
+	uint16_t bg_free_inodes_count_hi; // Free inodes count MSB
+	uint16_t bg_used_dirs_count_hi; // Directories count MSB
+	uint16_t bg_itable_unused_hi;  // Unused inodes count MSB
+	uint32_t bg_reserved2[3]; // Padding
+} ext4_group_desc_t;
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/lib/ext4/libext4_directory.c
===================================================================
--- uspace/lib/ext4/libext4_directory.c	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
+++ uspace/lib/ext4/libext4_directory.c	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2011 Frantisek Princ
+ * 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 libext4
+ * @{
+ */ 
+
+/**
+ * @file	libext4_directory.c
+ * @brief	TODO
+ */
+
+#include "libext4_directory.h"
+
+
+/**
+ * @}
+ */ 
Index: uspace/lib/ext4/libext4_directory.h
===================================================================
--- uspace/lib/ext4/libext4_directory.h	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
+++ uspace/lib/ext4/libext4_directory.h	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2011 Frantisek Princ
+ * 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 libext4
+ * @{
+ */ 
+
+#ifndef LIBEXT4_LIBEXT4_DIRECTORY_H_
+#define LIBEXT4_LIBEXT4_DIRECTORY_H_
+
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/lib/ext4/libext4_filesystem.c
===================================================================
--- uspace/lib/ext4/libext4_filesystem.c	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
+++ uspace/lib/ext4/libext4_filesystem.c	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2011 Frantisek Princ
+ * 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 libext4
+ * @{
+ */ 
+
+/**
+ * @file	libext4_filesystem.c
+ * @brief	TODO
+ */
+
+#include <errno.h>
+#include "libext4_filesystem.h"
+
+int ext4_filesystem_init(ext4_filesystem_t *fs, service_id_t service_id)
+{
+	// TODO
+	return EOK;
+}
+
+int ext4_filesystem_check_sanity(ext4_filesystem_t *fs)
+{
+	// TODO
+	return EOK;
+}
+
+int ext4_filesystem_check_flags(ext4_filesystem_t *fs, bool *o_read_only)
+{
+	// TODO
+	return EOK;
+}
+
+void ext4_filesystem_fini(ext4_filesystem_t *fs)
+{
+	// TODO
+}
+
+
+/**
+ * @}
+ */ 
Index: uspace/lib/ext4/libext4_filesystem.h
===================================================================
--- uspace/lib/ext4/libext4_filesystem.h	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
+++ uspace/lib/ext4/libext4_filesystem.h	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2011 Frantisek Princ
+ * 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 libext4
+ * @{
+ */ 
+
+#ifndef LIBEXT4_LIBEXT4_FILESYSTEM_H_
+#define LIBEXT4_LIBEXT4_FILESYSTEM_H_
+
+#include <libblock.h>
+#include "libext4_superblock.h"
+
+typedef struct ext4_filesystem {
+	service_id_t device;
+	ext4_superblock_t *	superblock;
+} ext4_filesystem_t;
+
+extern int ext4_filesystem_init(ext4_filesystem_t *, service_id_t);
+extern int ext4_filesystem_check_sanity(ext4_filesystem_t *fs);
+extern int ext4_filesystem_check_flags(ext4_filesystem_t *, bool *);
+extern void ext4_filesystem_fini(ext4_filesystem_t *fs);
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/lib/ext4/libext4_inode.c
===================================================================
--- uspace/lib/ext4/libext4_inode.c	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
+++ uspace/lib/ext4/libext4_inode.c	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2011 Frantisek Princ
+ * 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 libext4
+ * @{
+ */ 
+
+/**
+ * @file	libext4_inode.c
+ * @brief	Ext4 inode operations.
+ */
+
+#include "libext4_inode.h"
+
+// TODO check return type
+uint16_t ext4_inode_get_usage_count(ext4_inode_t *inode)
+{
+	// TODO
+	return 0;
+}
+
+
+/**
+ * @}
+ */ 
Index: uspace/lib/ext4/libext4_inode.h
===================================================================
--- uspace/lib/ext4/libext4_inode.h	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
+++ uspace/lib/ext4/libext4_inode.h	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2011 Frantisek Princ
+ * 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 libext4
+ * @{
+ */ 
+
+#ifndef LIBEXT4_LIBEXT4_INODE_H_
+#define LIBEXT4_LIBEXT4_INODE_H_
+
+#include <libblock.h>
+#include <sys/types.h>
+
+// TODO better constant definition !!!
+#define	EXT4_N_BLOCKS	15
+
+/*
+ * Structure of an inode on the disk
+ */
+typedef struct ext4_inode {
+	uint16_t i_mode; // File mode
+	uint16_t i_uid; // Low 16 bits of owner uid
+	uint32_t i_size_lo; // Size in bytes
+	uint32_t i_atime; // Access time
+	uint32_t i_ctime; // Inode change time
+	uint32_t i_mtime; // Modification time
+	uint32_t i_dtime; // Deletion time
+	uint16_t i_gid; // Low 16 bits of group id
+	uint16_t i_links_count; // Links count
+	uint32_t i_blocks_lo; // Blocks count
+	uint32_t i_flags; // File flags
+
+	/*
+        union {
+                struct {
+                        __le32  l_i_version;
+                } linux1;
+                struct {
+                        __u32  h_i_translator;
+                } hurd1;
+                struct {
+                        __u32  m_i_reserved1;
+                } masix1;
+        } osd1;
+	*/
+	uint32_t unused_osd1; // OS dependent - not used in HelenOS
+
+    uint32_t i_block[EXT4_N_BLOCKS]; // Pointers to blocks
+    uint32_t i_generation; // File version (for NFS)
+    uint32_t i_file_acl_lo; // File ACL
+    uint32_t i_size_high;
+    uint32_t i_obso_faddr; // Obsoleted fragment address
+
+    /*
+        union {
+                struct {
+                        __le16  l_i_blocks_high;
+                        __le16  l_i_file_acl_high;
+                        __le16  l_i_uid_high;
+                        __le16  l_i_gid_high;
+                        __u32   l_i_reserved2;
+                } linux2;
+                struct {
+                        __le16  h_i_reserved1;
+                        __u16   h_i_mode_high;
+                        __u16   h_i_uid_high;
+                        __u16   h_i_gid_high;
+                        __u32   h_i_author;
+                } hurd2;
+                struct {
+                        __le16  h_i_reserved1;
+                        __le16  m_i_file_acl_high;
+                        __u32   m_i_reserved2[2];
+                } masix2;
+        } osd2;
+        */
+
+        uint32_t unused_osd2[3]; // OS dependent - not used in HelenOS
+        uint16_t i_extra_isize;
+        uint16_t i_pad1;
+        uint32_t  i_ctime_extra; // Extra change time (nsec << 2 | epoch)
+        uint32_t i_mtime_extra; // Extra Modification time (nsec << 2 | epoch)
+        uint32_t i_atime_extra; // Extra Access time (nsec << 2 | epoch)
+        uint32_t i_crtime; // File creation time
+        uint32_t i_crtime_extra; // Extra file creation time (nsec << 2 | epoch)
+        uint32_t i_version_hi;   // High 32 bits for 64-bit version
+} __attribute__ ((packed)) ext4_inode_t;
+
+
+// TODO check value
+#define EXT4_INODE_ROOT_INDEX	2
+
+typedef struct ext4_inode_ref {
+	block_t *block; // Reference to a block containing this inode
+	ext4_inode_t *inode;
+	uint32_t index; // Index number of this inode
+} ext4_inode_ref_t;
+
+extern uint16_t ext4_inode_get_usage_count(ext4_inode_t *);
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/lib/ext4/libext4_superblock.c
===================================================================
--- uspace/lib/ext4/libext4_superblock.c	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
+++ uspace/lib/ext4/libext4_superblock.c	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2011 Frantisek Princ
+ * 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 libext4
+ * @{
+ */ 
+
+/**
+ * @file	libext4_superblock.c
+ * @brief	Ext4 superblock operations.
+ */
+
+#include "libext4_superblock.h"
+
+
+/**
+ * @}
+ */ 
Index: uspace/lib/ext4/libext4_superblock.h
===================================================================
--- uspace/lib/ext4/libext4_superblock.h	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
+++ uspace/lib/ext4/libext4_superblock.h	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2011 Frantisek Princ
+ * 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 libext4
+ * @{
+ */
+
+#ifndef LIBEXT4_LIBEXT4_SUPERBLOCK_H_
+#define LIBEXT4_LIBEXT4_SUPERBLOCK_H_
+
+#include <sys/types.h>
+
+/*
+ * Structure of the super block
+ */
+typedef struct ext4_superblock {
+	uint32_t s_inodes_count; // Inodes count
+	uint32_t s_blocks_count_lo; // Blocks count
+	uint32_t s_r_blocks_count_lo; // Reserved blocks count
+	uint32_t s_free_blocks_count_lo; // Free blocks count
+	uint32_t s_free_inodes_count; // Free inodes count
+	uint32_t s_first_data_block; // First Data Block
+	uint32_t s_log_block_size; // Block size
+	uint32_t s_obso_log_frag_size; // Obsoleted fragment size
+	uint32_t s_blocks_per_group; // Number of blocks per group
+	uint32_t s_obso_frags_per_group; // Obsoleted fragments per group
+	uint32_t s_inodes_per_group; // Number of inodes per group
+	uint32_t s_mtime; // Mount time
+	uint32_t s_wtime; // Write time
+	uint16_t s_mnt_count; // Mount count
+	uint16_t s_max_mnt_count; // Maximal mount count
+	uint16_t s_magic; // Magic signature
+	uint16_t s_state; // File system state
+	uint16_t s_errors; // Behaviour when detecting errors
+	uint16_t s_minor_rev_level; // Minor revision level
+	uint32_t s_lastcheck; // Time of last check
+	uint32_t s_checkinterval; // Maximum time between checks
+	uint32_t s_creator_os; // Creator OS
+	uint32_t s_rev_level; // Revision level
+	uint16_t s_def_resuid; // Default uid for reserved blocks
+	uint16_t s_def_resgid; // Default gid for reserved blocks
+
+	// Fields for EXT4_DYNAMIC_REV superblocks only.
+	uint32_t s_first_ino; // First non-reserved inode
+	uint16_t s_inode_size; // Size of inode structure
+	uint16_t s_block_group_nr; // Block group number of this superblock
+	uint32_t s_feature_compat; // Compatible feature set
+	uint32_t s_feature_incompat; // Incompatible feature set
+	uint32_t s_feature_ro_compat; // Readonly-compatible feature set
+	uint8_t s_uuid[16]; // 128-bit uuid for volume
+	char s_volume_name[16]; // Volume name
+	char s_last_mounted[64]; // Directory where last mounted
+	uint32_t s_algorithm_usage_bitmap; // For compression
+
+	/*
+	 * Performance hints. Directory preallocation should only
+	 * happen if the EXT4_FEATURE_COMPAT_DIR_PREALLOC flag is on.
+	 */
+	uint8_t s_prealloc_blocks; // Number of blocks to try to preallocate
+	uint8_t s_prealloc_dir_blocks; // Number to preallocate for dirs
+	uint16_t s_reserved_gdt_blocks; // Per group desc for online growth
+
+	/*
+	 * Journaling support valid if EXT4_FEATURE_COMPAT_HAS_JOURNAL set.
+	 */
+	uint8_t s_journal_uuid[16]; // UUID of journal superblock
+	uint32_t s_journal_inum; // Inode number of journal file
+	uint32_t s_journal_dev; // Device number of journal file
+	uint32_t s_last_orphan; // Head of list of inodes to delete
+	uint32_t s_hash_seed[4]; // HTREE hash seed
+	uint8_t s_def_hash_version; // Default hash version to use
+	uint8_t s_jnl_backup_type;
+	uint16_t s_desc_size; // Size of group descriptor
+	uint32_t s_default_mount_opts; // Default mount options
+	uint32_t s_first_meta_bg; // First metablock block group
+	uint32_t s_mkfs_time; // When the filesystem was created
+	uint32_t s_jnl_blocks[17]; // Backup of the journal inode
+
+	/* 64bit support valid if EXT4_FEATURE_COMPAT_64BIT */
+	uint32_t s_blocks_count_hi; // Blocks count
+	uint32_t s_r_blocks_count_hi; // Reserved blocks count
+	uint32_t s_free_blocks_count_hi; // Free blocks count
+	uint16_t s_min_extra_isize; // All inodes have at least # bytes
+	uint16_t s_want_extra_isize; // New inodes should reserve # bytes
+	uint32_t s_flags; // Miscellaneous flags
+	uint16_t s_raid_stride; // RAID stride
+	uint16_t s_mmp_interval; // # seconds to wait in MMP checking
+	uint64_t s_mmp_block; // Block for multi-mount protection
+	uint32_t s_raid_stripe_width; // blocks on all data disks (N*stride)
+	uint8_t s_log_groups_per_flex; // FLEX_BG group size
+	uint8_t s_reserved_char_pad;
+	uint16_t s_reserved_pad;
+	uint64_t s_kbytes_written; // Number of lifetime kilobytes written
+	uint32_t s_snapshot_inum; // Inode number of active snapshot
+	uint32_t s_snapshot_id; // Sequential ID of active snapshot
+	uint64_t s_snapshot_r_blocks_count; /* reserved blocks for active snapshot's future use */
+	uint32_t s_snapshot_list; // inode number of the head of the on-disk snapshot list
+
+	//#define EXT4_S_ERR_START offsetof(struct ext4_super_block, s_error_count)
+	uint32_t s_error_count; // number of fs errors
+	uint32_t s_first_error_time; // First time an error happened
+	uint32_t s_first_error_ino; // Inode involved in first error
+	uint64_t s_first_error_block; // block involved of first error
+	uint8_t s_first_error_func[32]; // Function where the error happened
+	uint32_t s_first_error_line; // Line number where error happened
+	uint32_t s_last_error_time; // Most recent time of an error
+	uint32_t s_last_error_ino; // Inode involved in last error
+	uint32_t s_last_error_line; // Line number where error happened
+	uint64_t s_last_error_block;     /* block involved of last error */
+	uint8_t s_last_error_func[32];  /* function where the error happened */
+	//#define EXT4_S_ERR_END offsetof(struct ext4_super_block, s_mount_opts)
+	uint8_t s_mount_opts[64];
+	uint32_t s_reserved[112]; // Padding to the end of the block
+
+} __attribute__((packed)) ext4_superblock_t;
+
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/srv/fs/ext4fs/Makefile
===================================================================
--- uspace/srv/fs/ext4fs/Makefile	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
+++ uspace/srv/fs/ext4fs/Makefile	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
@@ -0,0 +1,38 @@
+#
+# Copyright (c) 2011 Frantisek Princ
+# 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 $(LIBEXT4_PREFIX)/libext4.a
+EXTRA_CFLAGS += -I$(LIBBLOCK_PREFIX) -I$(LIBFS_PREFIX) -I$(LIBEXT4_PREFIX)
+BINARY = ext4fs
+
+SOURCES = \
+	ext4fs.c \
+	ext4fs_ops.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/srv/fs/ext4fs/ext4fs.c
===================================================================
--- uspace/srv/fs/ext4fs/ext4fs.c	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
+++ uspace/srv/fs/ext4fs/ext4fs.c	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2011 Frantisek Princ
+ * 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	ext4fs.c
+ * @brief	EXT4 file system driver for HelenOS.
+ */
+
+#include <async.h>
+#include <errno.h>
+#include <libfs.h>
+#include <ns.h>
+#include <stdio.h>
+#include <task.h>
+#include <ipc/services.h>
+#include "ext4fs.h"
+#include "../../vfs/vfs.h"
+
+#define NAME	"ext4fs"
+
+vfs_info_t ext4fs_vfs_info = {
+	.name = NAME,
+	.instance = 0,
+};
+
+int main(int argc, char **argv)
+{
+	printf(NAME ": HelenOS EXT4 file system server\n");
+
+	if (argc == 3) {
+		if (!str_cmp(argv[1], "--instance"))
+			ext4fs_vfs_info.instance = strtol(argv[2], NULL, 10);
+		else {
+			printf(NAME " Unrecognized parameters");
+			return -1;
+		}
+	}
+
+	async_sess_t *vfs_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
+		SERVICE_VFS, 0, 0);
+	if (!vfs_sess) {
+		printf(NAME ": failed to connect to VFS\n");
+		return -1;
+	}
+
+	int rc = ext4fs_global_init();
+	if (rc != EOK) {
+		printf(NAME ": Failed global initialization\n");
+		return 1;
+	}
+
+	rc = fs_register(vfs_sess, &ext4fs_vfs_info, &ext4fs_ops,
+	    &ext4fs_libfs_ops);
+	if (rc != EOK) {
+		fprintf(stdout, NAME ": Failed to register fs (%d)\n", rc);
+		return 1;
+	}
+
+	printf(NAME ": Accepting connections\n");
+	task_retval(0);
+	async_manager();
+	/* not reached */
+	return 0;
+}
+
+/**
+ * @}
+ */ 
Index: uspace/srv/fs/ext4fs/ext4fs.h
===================================================================
--- uspace/srv/fs/ext4fs/ext4fs.h	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
+++ uspace/srv/fs/ext4fs/ext4fs.h	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2011 Frantisek Princ
+ * 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 EXT4FS_EXT4FS_H_
+#define EXT4FS_EXT4FS_H_
+
+#include <libfs.h>
+
+extern vfs_out_ops_t ext4fs_ops;
+extern libfs_ops_t ext4fs_libfs_ops;
+
+extern int ext4fs_global_init(void);
+extern int ext4fs_global_fini(void);
+
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/srv/fs/ext4fs/ext4fs_ops.c
===================================================================
--- uspace/srv/fs/ext4fs/ext4fs_ops.c	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
+++ uspace/srv/fs/ext4fs/ext4fs_ops.c	(revision 54935cf6fe01590e96323ab8738b02418aaba26c)
@@ -0,0 +1,439 @@
+/*
+ * Copyright (c) 2011 Frantisek Princ
+ * 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	ext4fs_ops.c
+ * @brief	VFS operations for EXT4 filesystem.
+ */
+
+#include <errno.h>
+#include <fibril_synch.h>
+#include <libext4.h>
+#include <libfs.h>
+#include <malloc.h>
+#include <ipc/loc.h>
+#include "ext4fs.h"
+#include "../../vfs/vfs.h"
+
+#define EXT4FS_NODE(node)	((node) ? (ext4fs_node_t *) (node)->data : NULL)
+
+typedef struct ext4fs_instance {
+	link_t link;
+	service_id_t service_id;
+	ext4_filesystem_t *filesystem;
+	unsigned int open_nodes_count;
+} ext4fs_instance_t;
+
+typedef struct ext4fs_node {
+	ext4fs_instance_t *instance;
+	ext4_inode_ref_t *inode_ref;
+	fs_node_t *fs_node;
+	link_t link;
+	unsigned int references;
+} ext4fs_node_t;
+
+/*
+ * Forward declarations of auxiliary functions
+ */
+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);
+
+
+/*
+ * Forward declarations of EXT4 libfs operations.
+ */
+static int ext4fs_root_get(fs_node_t **, service_id_t);
+static int ext4fs_match(fs_node_t **, fs_node_t *, const char *);
+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 *);
+static int ext4fs_create_node(fs_node_t **, service_id_t, int);
+static int ext4fs_destroy_node(fs_node_t *);
+static int ext4fs_link(fs_node_t *, fs_node_t *, const char *);
+static int ext4fs_unlink(fs_node_t *, fs_node_t *, const char *);
+static int ext4fs_has_children(bool *, fs_node_t *);
+static fs_index_t ext4fs_index_get(fs_node_t *);
+static aoff64_t ext4fs_size_get(fs_node_t *);
+static unsigned ext4fs_lnkcnt_get(fs_node_t *);
+static bool ext4fs_is_directory(fs_node_t *);
+static bool ext4fs_is_file(fs_node_t *node);
+static service_id_t ext4fs_service_get(fs_node_t *node);
+
+/*
+ * Static variables
+ */
+static LIST_INITIALIZE(instance_list);
+static FIBRIL_MUTEX_INITIALIZE(instance_list_mutex);
+static FIBRIL_MUTEX_INITIALIZE(open_nodes_lock);
+
+
+/**
+ *	TODO comment
+ */
+int ext4fs_global_init(void)
+{
+	// TODO
+	return EOK;
+}
+
+int ext4fs_global_fini(void)
+{
+	// TODO
+	return EOK;
+}
+
+
+/*
+ * EXT4 libfs operations.
+ */
+
+int ext4fs_instance_get(service_id_t service_id, ext4fs_instance_t **inst)
+{
+	ext4fs_instance_t *tmp;
+
+	fibril_mutex_lock(&instance_list_mutex);
+
+	if (list_empty(&instance_list)) {
+		fibril_mutex_unlock(&instance_list_mutex);
+		return EINVAL;
+	}
+
+	list_foreach(instance_list, link) {
+		tmp = list_get_instance(link, ext4fs_instance_t, link);
+
+		if (tmp->service_id == service_id) {
+			*inst = tmp;
+			fibril_mutex_unlock(&instance_list_mutex);
+			return EOK;
+		}
+	}
+
+	fibril_mutex_unlock(&instance_list_mutex);
+	return EINVAL;
+}
+
+int ext4fs_root_get(fs_node_t **rfn, service_id_t service_id)
+{
+	// TODO
+	return 0;
+}
+
+int ext4fs_match(fs_node_t **rfn, fs_node_t *pfn, const char *component)
+{
+	// TODO
+	return EOK;
+}
+
+int ext4fs_node_get(fs_node_t **rfn, service_id_t service_id, fs_index_t index)
+{
+	// TODO
+	return 0;
+}
+
+int ext4fs_node_get_core(fs_node_t **rfn, ext4fs_instance_t *inst,
+		fs_index_t index)
+{
+	// TODO
+	return EOK;
+}
+
+int ext4fs_node_open(fs_node_t *fn)
+{
+	// TODO
+	return EOK;
+}
+
+int ext4fs_node_put(fs_node_t *fn)
+{
+	// TODO
+	return EOK;
+}
+
+int ext4fs_create_node(fs_node_t **rfn, service_id_t service_id, int flags)
+{
+	// TODO
+	return ENOTSUP;
+}
+
+int ext4fs_destroy_node(fs_node_t *fn)
+{
+	// TODO
+	return ENOTSUP;
+}
+
+int ext4fs_link(fs_node_t *pfn, fs_node_t *cfn, const char *name)
+{
+	// TODO
+	return ENOTSUP;
+}
+
+int ext4fs_unlink(fs_node_t *pfn, fs_node_t *cfn, const char *nm)
+{
+	// TODO
+	return ENOTSUP;
+}
+
+int ext4fs_has_children(bool *has_children, fs_node_t *fn)
+{
+	// TODO
+	return EOK;
+}
+
+
+fs_index_t ext4fs_index_get(fs_node_t *fn)
+{
+	// TODO
+	return 0;
+}
+
+aoff64_t ext4fs_size_get(fs_node_t *fn)
+{
+	// TODO
+	return 0;
+}
+
+unsigned ext4fs_lnkcnt_get(fs_node_t *fn)
+{
+	// TODO
+	return 0;
+}
+
+bool ext4fs_is_directory(fs_node_t *fn)
+{
+	// TODO
+	return false;
+}
+
+bool ext4fs_is_file(fs_node_t *fn)
+{
+	// TODO
+	return false;
+}
+
+service_id_t ext4fs_service_get(fs_node_t *fn)
+{
+	// TODO
+	return 0;
+}
+
+/*
+ * libfs operations.
+ */
+libfs_ops_t ext4fs_libfs_ops = {
+	.root_get = ext4fs_root_get,
+	.match = ext4fs_match,
+	.node_get = ext4fs_node_get,
+	.node_open = ext4fs_node_open,
+	.node_put = ext4fs_node_put,
+	.create = ext4fs_create_node,
+	.destroy = ext4fs_destroy_node,
+	.link = ext4fs_link,
+	.unlink = ext4fs_unlink,
+	.has_children = ext4fs_has_children,
+	.index_get = ext4fs_index_get,
+	.size_get = ext4fs_size_get,
+	.lnkcnt_get = ext4fs_lnkcnt_get,
+	.is_directory = ext4fs_is_directory,
+	.is_file = ext4fs_is_file,
+	.service_get = ext4fs_service_get
+};
+
+
+/*
+ * VFS operations.
+ */
+
+static int ext4fs_mounted(service_id_t service_id, const char *opts,
+   fs_index_t *index, aoff64_t *size, unsigned *lnkcnt)
+{
+
+	int rc;
+	ext4_filesystem_t *fs;
+	ext4fs_instance_t *inst;
+	bool read_only;
+
+	/* Allocate libext4 filesystem structure */
+	fs = (ext4_filesystem_t *) malloc(sizeof(ext4_filesystem_t));
+	if (fs == NULL) {
+		return ENOMEM;
+	}
+
+	/* Allocate instance structure */
+	inst = (ext4fs_instance_t *) malloc(sizeof(ext4fs_instance_t));
+	if (inst == NULL) {
+		free(fs);
+		return ENOMEM;
+	}
+
+	/* Initialize the filesystem  */
+	rc = ext4_filesystem_init(fs, service_id);
+	if (rc != EOK) {
+		free(fs);
+		free(inst);
+		return rc;
+	}
+
+	/* Do some sanity checking */
+	rc = ext4_filesystem_check_sanity(fs);
+	if (rc != EOK) {
+		ext4_filesystem_fini(fs);
+		free(fs);
+		free(inst);
+		return rc;
+	}
+
+	/* Check flags */
+	rc = ext4_filesystem_check_flags(fs, &read_only);
+	if (rc != EOK) {
+		ext4_filesystem_fini(fs);
+		free(fs);
+		free(inst);
+		return rc;
+	}
+
+	/* Initialize instance */
+	link_initialize(&inst->link);
+	inst->service_id = service_id;
+	inst->filesystem = fs;
+	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);
+		free(fs);
+		free(inst);
+		return rc;
+	}
+	ext4fs_node_t *enode = EXT4FS_NODE(root_node);
+
+	/* 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 = 0;
+	*lnkcnt = ext4_inode_get_usage_count(enode->inode_ref->inode);
+
+	ext4fs_node_put(root_node);
+
+	return EOK;
+}
+
+static int ext4fs_unmounted(service_id_t service_id)
+{
+
+	int rc;
+	ext4fs_instance_t *inst;
+
+	rc = ext4fs_instance_get(service_id, &inst);
+
+	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);
+
+	ext4_filesystem_fini(inst->filesystem);
+
+	return EOK;
+}
+
+static int
+ext4fs_read(service_id_t service_id, fs_index_t index, aoff64_t pos,
+    size_t *rbytes)
+{
+	// TODO
+	return 0;
+}
+
+static int
+ext4fs_write(service_id_t service_id, fs_index_t index, aoff64_t pos,
+    size_t *wbytes, aoff64_t *nsize)
+{
+	// TODO
+	return ENOTSUP;
+}
+
+static int
+ext4fs_truncate(service_id_t service_id, fs_index_t index, aoff64_t size)
+{
+	// TODO
+	return ENOTSUP;
+}
+
+static int ext4fs_close(service_id_t service_id, fs_index_t index)
+{
+	// TODO
+	return EOK;
+}
+
+static int ext4fs_destroy(service_id_t service_id, fs_index_t index)
+{
+	//TODO
+	return ENOTSUP;
+}
+
+static int ext4fs_sync(service_id_t service_id, fs_index_t index)
+{
+	// TODO
+	return ENOTSUP;
+}
+
+vfs_out_ops_t ext4fs_ops = {
+	.mounted = ext4fs_mounted,
+	.unmounted = ext4fs_unmounted,
+	.read = ext4fs_read,
+	.write = ext4fs_write,
+	.truncate = ext4fs_truncate,
+	.close = ext4fs_close,
+	.destroy = ext4fs_destroy,
+	.sync = ext4fs_sync,
+};
+
+/**
+ * @}
+ */ 
