Index: uspace/lib/ext2/Makefile
===================================================================
--- uspace/lib/ext2/Makefile	(revision d1538a1fa3100ff880b0dd2c1b9e79fdec6ea762)
+++ 	(revision )
@@ -1,43 +1,0 @@
-#
-# 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
-EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX)
-LIBS = $(LIBBLOCK_PREFIX)/libblock.a
-
-SOURCES = \
-	libext2_filesystem.c \
-	libext2_superblock.c \
-	libext2_block_group.c \
-	libext2_inode.c \
-	libext2_directory.c
-
-include $(USPACE_PREFIX)/Makefile.common
Index: uspace/lib/ext2/libext2.h
===================================================================
--- uspace/lib/ext2/libext2.h	(revision d1538a1fa3100ff880b0dd2c1b9e79fdec6ea762)
+++ 	(revision )
@@ -1,48 +1,0 @@
-/*
- * Copyright (c) 2011 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_
-
-#include "libext2_superblock.h"
-#include "libext2_block_group.h"
-#include "libext2_inode.h"
-#include "libext2_filesystem.h"
-#include "libext2_directory.h"
-
-#endif
-
-/** @}
- */
Index: uspace/lib/ext2/libext2_block_group.c
===================================================================
--- uspace/lib/ext2/libext2_block_group.c	(revision d1538a1fa3100ff880b0dd2c1b9e79fdec6ea762)
+++ 	(revision )
@@ -1,114 +1,0 @@
-/*
- * Copyright (c) 2011 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 "libext2_block_group.h"
-#include <byteorder.h>
-
-/**
- * Get block ID corresponding to the block bitmap of this block group
- * 
- * @param bg pointer to block group descriptor
- */
-uint32_t ext2_block_group_get_block_bitmap_block(ext2_block_group_t *bg)
-{
-	return uint32_t_le2host(bg->block_bitmap_block);
-}
-
-/**
- * Get block ID corresponding to the inode bitmap of this block group
- * 
- * @param bg pointer to block group descriptor
- */
-uint32_t ext2_block_group_get_inode_bitmap_block(ext2_block_group_t *bg)
-{
-	return uint32_t_le2host(bg->inode_bitmap_block);
-}
-
-/**
- * Get block ID of first block in inode table
- * 
- * @param bg pointer to block group descriptor
- */
-uint32_t ext2_block_group_get_inode_table_first_block(ext2_block_group_t *bg)
-{
-	return uint32_t_le2host(bg->inode_table_first_block);
-}
-
-/**
- * Get amount of free blocks in this block group
- * 
- * @param bg pointer to block group descriptor
- */
-uint16_t ext2_block_group_get_free_block_count(ext2_block_group_t *bg)
-{
-	return uint16_t_le2host(bg->free_block_count);
-}
-
-/**
- * Set amount of free blocks in this block group
- * 
- * @param bg pointer to block group descriptor
- * @param val new value
- */
-void ext2_block_group_set_free_block_count(ext2_block_group_t *bg,
-	uint16_t val)
-{
-	bg->free_block_count = host2uint16_t_le(val);
-}
-
-/**
- * Get amount of free inodes in this block group
- * 
- * @param bg pointer to block group descriptor
- */
-uint16_t ext2_block_group_get_free_inode_count(ext2_block_group_t *bg)
-{
-	return uint16_t_le2host(bg->free_inode_count);
-}
-
-/**
- * Get amount of inodes allocated for directories
- * 
- * @param bg pointer to block group descriptor
- */
-uint16_t ext2_block_group_get_directory_inode_count(ext2_block_group_t *bg)
-{
-	return uint16_t_le2host(bg->directory_inode_count);
-}
-
-
-/** @}
- */
Index: uspace/lib/ext2/libext2_block_group.h
===================================================================
--- uspace/lib/ext2/libext2_block_group.h	(revision d1538a1fa3100ff880b0dd2c1b9e79fdec6ea762)
+++ 	(revision )
@@ -1,69 +1,0 @@
-/*
- * Copyright (c) 2011 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_BLOCK_GROUP_H_
-#define LIBEXT2_LIBEXT2_BLOCK_GROUP_H_
-
-#include <block.h>
-
-typedef struct ext2_block_group {
-	uint32_t block_bitmap_block; // Block ID for block bitmap
-	uint32_t inode_bitmap_block; // Block ID for inode bitmap
-	uint32_t inode_table_first_block; // Block ID of first block of inode table 
-	uint16_t free_block_count; // Count of free blocks
-	uint16_t free_inode_count; // Count of free inodes
-	uint16_t directory_inode_count; // Number of inodes allocated to directories
-} ext2_block_group_t;
-
-typedef struct ext2_block_group_ref {
-	block_t *block; // Reference to a block containing this block group descr
-	ext2_block_group_t *block_group;
-} ext2_block_group_ref_t;
-
-#define EXT2_BLOCK_GROUP_DESCRIPTOR_SIZE 32
-
-extern uint32_t	ext2_block_group_get_block_bitmap_block(ext2_block_group_t *);
-extern uint32_t	ext2_block_group_get_inode_bitmap_block(ext2_block_group_t *);
-extern uint32_t	ext2_block_group_get_inode_table_first_block(ext2_block_group_t *);
-extern uint16_t	ext2_block_group_get_free_block_count(ext2_block_group_t *);
-extern uint16_t	ext2_block_group_get_free_inode_count(ext2_block_group_t *);
-extern uint16_t	ext2_block_group_get_directory_inode_count(ext2_block_group_t *);
-
-extern void	ext2_block_group_set_free_block_count(ext2_block_group_t *, uint16_t);
-
-#endif
-
-/** @}
- */
Index: uspace/lib/ext2/libext2_directory.c
===================================================================
--- uspace/lib/ext2/libext2_directory.c	(revision d1538a1fa3100ff880b0dd2c1b9e79fdec6ea762)
+++ 	(revision )
@@ -1,256 +1,0 @@
-/*
- * Copyright (c) 2011 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 "libext2_directory.h"
-#include <byteorder.h>
-#include <errno.h>
-#include <assert.h>
-
-static int ext2_directory_iterator_set(ext2_directory_iterator_t *it,
-    uint32_t block_size);
-
-/**
- * Get inode number for the directory entry
- * 
- * @param de pointer to linked list directory entry
- */
-uint32_t ext2_directory_entry_ll_get_inode(ext2_directory_entry_ll_t *de)
-{
-	return uint32_t_le2host(de->inode);
-}
-
-/**
- * Get length of the directory entry
- * 
- * @param de pointer to linked list directory entry
- */
-uint16_t ext2_directory_entry_ll_get_entry_length(
-    ext2_directory_entry_ll_t *de)
-{
-	return uint16_t_le2host(de->entry_length);
-}
-
-/**
- * Get length of the name stored in the directory entry
- * 
- * @param de pointer to linked list directory entry
- */
-uint16_t ext2_directory_entry_ll_get_name_length(
-    ext2_superblock_t *sb, ext2_directory_entry_ll_t *de)
-{
-	if (ext2_superblock_get_rev_major(sb) == 0 &&
-	    ext2_superblock_get_rev_minor(sb) < 5) {
-		return ((uint16_t)de->name_length_high) << 8 | 
-		    ((uint16_t)de->name_length);
-	}
-	return de->name_length;
-}
-
-/**
- * Initialize a directory iterator
- * 
- * @param it pointer to iterator to initialize
- * @param fs pointer to filesystem structure
- * @param inode pointer to inode reference structure
- * @param pos position within inode to start at, 0 is the first entry
- * @return EOK on success or negative error code on failure
- */
-int ext2_directory_iterator_init(ext2_directory_iterator_t *it,
-    ext2_filesystem_t *fs, ext2_inode_ref_t *inode_ref, aoff64_t pos)
-{	
-	it->inode_ref = inode_ref;
-	it->fs = fs;
-	it->current = NULL;
-	it->current_offset = 0;
-	it->current_block = NULL;
-	
-	return ext2_directory_iterator_seek(it, pos);
-}
-
-/**
- * Advance the directory iterator to the next entry
- * 
- * @param it pointer to iterator to initialize
- * @return EOK on success or negative error code on failure
- */
-int ext2_directory_iterator_next(ext2_directory_iterator_t *it)
-{
-	uint16_t skip;
-	
-	assert(it->current != NULL);
-	
-	skip = ext2_directory_entry_ll_get_entry_length(it->current);
-	
-	return ext2_directory_iterator_seek(it, it->current_offset + skip);
-}
-
-/**
- * Seek the directory iterator to the given byte offset within the inode.
- * 
- * @param it pointer to iterator to initialize
- * @return EOK on success or negative error code on failure
- */
-int ext2_directory_iterator_seek(ext2_directory_iterator_t *it, aoff64_t pos)
-{
-	int rc;
-	
-	uint64_t size;
-	aoff64_t current_block_idx;
-	aoff64_t next_block_idx;
-	uint32_t next_block_phys_idx;
-	uint32_t block_size;
-	
-	size = ext2_inode_get_size(it->fs->superblock, it->inode_ref->inode);
-	
-	/* The iterator is not valid until we seek to the desired position */
-	it->current = NULL;
-	
-	/* Are we at the end? */
-	if (pos >= size) {		
-		if (it->current_block) {
-			rc = block_put(it->current_block);
-			it->current_block = NULL;
-			if (rc != EOK) {
-				return rc;
-			}
-		}
-		
-		it->current_offset = pos;
-		return EOK;
-	}
-	
-	block_size = ext2_superblock_get_block_size(it->fs->superblock);
-	current_block_idx = it->current_offset / block_size;
-	next_block_idx = pos / block_size;
-	
-	/* If we don't have a block or are moving accross block boundary,
-	 * we need to get another block
-	 */
-	if (it->current_block == NULL || current_block_idx != next_block_idx) {		
-		if (it->current_block) {
-			rc = block_put(it->current_block);
-			it->current_block = NULL;
-			if (rc != EOK) {
-				return rc;
-			}
-		}
-		
-		rc = ext2_filesystem_get_inode_data_block_index(it->fs,
-		    it->inode_ref->inode, next_block_idx, &next_block_phys_idx);
-		if (rc != EOK) {
-			return rc;
-		}
-		
-		rc = block_get(&it->current_block, it->fs->device, next_block_phys_idx,
-		    BLOCK_FLAGS_NONE);
-		if (rc != EOK) {
-			it->current_block = NULL;
-			return rc;
-		}
-	}
-	
-	it->current_offset = pos;
-	return ext2_directory_iterator_set(it, block_size);
-}
-
-/** Setup the entry at the current iterator offset.
- * 
- * This function checks the validity of the directory entry,
- * before setting the data pointer.
- *
- * @return EOK on success or error code on failure 
- */
-static int ext2_directory_iterator_set(ext2_directory_iterator_t *it,
-    uint32_t block_size)
-{
-	uint32_t offset_in_block = it->current_offset % block_size;
-	
-	it->current = NULL;
-	
-	/* Ensure proper alignment */
-	if ((offset_in_block % 4) != 0) {
-		return EIO;
-	}
-	
-	/* Ensure that the core of the entry does not overflow the block */
-	if (offset_in_block > block_size - 8) {
-		return EIO;
-	}
-	
-	ext2_directory_entry_ll_t *entry = it->current_block->data + offset_in_block;
-	
-	/* Ensure that the whole entry does not overflow the block */
-	uint16_t length = ext2_directory_entry_ll_get_entry_length(entry);
-	if (offset_in_block + length > block_size) {
-		return EIO;
-	}
-	
-	/* Ensure the name length is not too large */
-	if (ext2_directory_entry_ll_get_name_length(it->fs->superblock, 
-	    entry) > length-8) {
-		return EIO;
-	}
-	
-	it->current = entry;
-	return EOK;
-}
-
-/**
- * Release all resources asociated with the directory iterator
- * 
- * @param it pointer to iterator to initialize
- * @return EOK on success or negative error code on failure
- */
-int ext2_directory_iterator_fini(ext2_directory_iterator_t *it)
-{
-	int rc;
-	
-	it->fs = NULL;
-	it->inode_ref = NULL;
-	it->current = NULL;
-	
-	if (it->current_block) {
-		rc = block_put(it->current_block);
-		if (rc != EOK) {
-			return rc;
-		}
-	}
-	
-	return EOK;
-}
-
-/** @}
- */
Index: uspace/lib/ext2/libext2_directory.h
===================================================================
--- uspace/lib/ext2/libext2_directory.h	(revision d1538a1fa3100ff880b0dd2c1b9e79fdec6ea762)
+++ 	(revision )
@@ -1,81 +1,0 @@
-/*
- * Copyright (c) 2011 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_DIRECTORY_H_
-#define LIBEXT2_LIBEXT2_DIRECTORY_H_
-
-#include <block.h>
-#include "libext2_filesystem.h"
-#include "libext2_inode.h"
-
-/**
- * Linked list directory entry structure
- */
-typedef struct ext2_directory_entry_ll {
-	uint32_t inode; // Inode for the entry
-	uint16_t entry_length; // Distance to the next directory entry
-	uint8_t name_length; // Lower 8 bits of name length
-	union {
-		uint8_t name_length_high; // Higher 8 bits of name length
-		uint8_t inode_type; // Type of referenced inode (in rev >= 0.5)
-	} __attribute__ ((packed));
-	uint8_t name; // First byte of name, if present
-} __attribute__ ((packed)) ext2_directory_entry_ll_t;
-
-typedef struct ext2_directory_iterator {
-	ext2_filesystem_t *fs;
-	ext2_inode_ref_t *inode_ref;
-	block_t *current_block;
-	aoff64_t current_offset;
-	ext2_directory_entry_ll_t *current;
-} ext2_directory_iterator_t;
-
-
-extern uint32_t	ext2_directory_entry_ll_get_inode(ext2_directory_entry_ll_t *);
-extern uint16_t	ext2_directory_entry_ll_get_entry_length(
-    ext2_directory_entry_ll_t *);
-extern uint16_t	ext2_directory_entry_ll_get_name_length(
-    ext2_superblock_t *, ext2_directory_entry_ll_t *);
-
-extern int ext2_directory_iterator_init(ext2_directory_iterator_t *,
-    ext2_filesystem_t *, ext2_inode_ref_t *, aoff64_t);
-extern int ext2_directory_iterator_next(ext2_directory_iterator_t *);
-extern int ext2_directory_iterator_seek(ext2_directory_iterator_t *, aoff64_t pos);
-extern int ext2_directory_iterator_fini(ext2_directory_iterator_t *);
-
-#endif
-
-/** @}
- */
Index: uspace/lib/ext2/libext2_filesystem.c
===================================================================
--- uspace/lib/ext2/libext2_filesystem.c	(revision d1538a1fa3100ff880b0dd2c1b9e79fdec6ea762)
+++ 	(revision )
@@ -1,532 +1,0 @@
-/*
- * Copyright (c) 2011 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_filesystem.h"
-#include "libext2_superblock.h"
-#include "libext2_block_group.h"
-#include "libext2_inode.h"
-#include <errno.h>
-#include <block.h>
-#include <malloc.h>
-#include <assert.h>
-#include <byteorder.h>
-
-/**
- * Initialize an instance of filesystem on the device.
- * This function reads superblock from the device and
- * initializes libblock cache with appropriate logical block size.
- * 
- * @param fs			Pointer to ext2_filesystem_t to initialize
- * @param service_id	Service ID of the block device
- * 
- * @return 		EOK on success or negative error code on failure
- */
-int ext2_filesystem_init(ext2_filesystem_t *fs, service_id_t service_id)
-{
-	int rc;
-	ext2_superblock_t *temp_superblock;
-	size_t block_size;
-	
-	fs->device = service_id;
-	
-	rc = block_init(EXCHANGE_SERIALIZE, fs->device, 2048);
-	if (rc != EOK) {
-		return rc;
-	}
-	
-	rc = ext2_superblock_read_direct(fs->device, &temp_superblock);
-	if (rc != EOK) {
-		block_fini(fs->device);
-		return rc;
-	}
-	
-	block_size = ext2_superblock_get_block_size(temp_superblock);
-	
-	if (block_size > EXT2_MAX_BLOCK_SIZE) {
-		block_fini(fs->device);
-		return ENOTSUP;
-	}
-	
-	rc = block_cache_init(service_id, block_size, 0, CACHE_MODE_WT);
-	if (rc != EOK) {
-		block_fini(fs->device);
-		return rc;
-	}
-	
-	fs->superblock = temp_superblock;
-	
-	return EOK; 
-}
-
-/**
- * Check filesystem for sanity
- * 
- * @param fs			Pointer to ext2_filesystem_t to check
- * @return 		EOK on success or negative error code on failure
- */
-int ext2_filesystem_check_sanity(ext2_filesystem_t *fs)
-{
-	int rc;
-	
-	rc = ext2_superblock_check_sanity(fs->superblock);
-	if (rc != EOK) {
-		return rc;
-	}
-	
-	return EOK;
-}
-
-/**
- * Check feature flags
- * 
- * @param fs Pointer to ext2_filesystem_t to check
- * @param read_only bool to set to true if the fs needs to be read-only
- * @return EOK on success or negative error code on failure
- */
-int ext2_filesystem_check_flags(ext2_filesystem_t *fs, bool *o_read_only)
-{
-	/* feature flags are present in rev 1 and later */
-	if (ext2_superblock_get_rev_major(fs->superblock) == 0) {
-		*o_read_only = false;
-		return EOK;
-	}
-	
-	uint32_t incompatible;
-	uint32_t read_only;
-	
-	incompatible = ext2_superblock_get_features_incompatible(fs->superblock);
-	read_only = ext2_superblock_get_features_read_only(fs->superblock);
-	
-	/* check whether we support all features
-	 * first unset any supported feature flags
-	 * and see whether any unspported feature remains */
-	incompatible &= ~EXT2_SUPPORTED_INCOMPATIBLE_FEATURES;
-	read_only &= ~EXT2_SUPPORTED_READ_ONLY_FEATURES;
-	
-	if (incompatible > 0) {
-		*o_read_only = true;
-		return ENOTSUP;
-	}
-	
-	if (read_only > 0) {
-		*o_read_only = true;
-	}
-	
-	return EOK;
-}
-
-/**
- * Get a reference to block descriptor
- * 
- * @param fs Pointer to filesystem information
- * @param bgid Index of block group to find
- * @param ref Pointer where to store pointer to block group reference
- * 
- * @return 		EOK on success or negative error code on failure
- */
-int ext2_filesystem_get_block_group_ref(ext2_filesystem_t *fs, uint32_t bgid,
-    ext2_block_group_ref_t **ref)
-{
-	int rc;
-	aoff64_t block_id;
-	uint32_t descriptors_per_block;
-	size_t offset;
-	ext2_block_group_ref_t *newref;
-	
-	newref = malloc(sizeof(ext2_block_group_ref_t));
-	if (newref == NULL) {
-		return ENOMEM;
-	}
-	
-	descriptors_per_block = ext2_superblock_get_block_size(fs->superblock)
-	    / EXT2_BLOCK_GROUP_DESCRIPTOR_SIZE;
-	
-	/* Block group descriptor table starts at the next block after superblock */
-	block_id = ext2_superblock_get_first_block(fs->superblock) + 1;
-	
-	/* Find the block containing the descriptor we are looking for */
-	block_id += bgid / descriptors_per_block;
-	offset = (bgid % descriptors_per_block) * EXT2_BLOCK_GROUP_DESCRIPTOR_SIZE;
-	
-	rc = block_get(&newref->block, fs->device, block_id, 0);
-	if (rc != EOK) {
-		free(newref);
-		return rc;
-	}
-	
-	newref->block_group = newref->block->data + offset;
-	
-	*ref = newref;
-	
-	return EOK;
-}
-
-/**
- * Free a reference to block group
- * 
- * @param ref Pointer to block group reference to free
- * 
- * @return 		EOK on success or negative error code on failure
- */
-int ext2_filesystem_put_block_group_ref(ext2_block_group_ref_t *ref)
-{
-	int rc;
-	
-	rc = block_put(ref->block);
-	free(ref);
-	
-	return rc;
-}
-
-/**
- * Get a reference to inode
- * 
- * @param fs Pointer to filesystem information
- * @param index The index number of the inode
- * @param ref Pointer where to store pointer to inode reference
- * 
- * @return 		EOK on success or negative error code on failure
- */
-int ext2_filesystem_get_inode_ref(ext2_filesystem_t *fs, uint32_t index,
-    ext2_inode_ref_t **ref)
-{
-	int rc;
-	aoff64_t block_id;
-	uint32_t block_group;
-	uint32_t offset_in_group;
-	uint32_t byte_offset_in_group;
-	size_t offset_in_block;
-	uint32_t inodes_per_group;
-	uint32_t inode_table_start;
-	uint16_t inode_size;
-	uint32_t block_size;
-	ext2_block_group_ref_t *bg_ref;
-	ext2_inode_ref_t *newref;
-	
-	newref = malloc(sizeof(ext2_inode_ref_t));
-	if (newref == NULL) {
-		return ENOMEM;
-	}
-	
-	inodes_per_group = ext2_superblock_get_inodes_per_group(fs->superblock);
-	
-	/* inode numbers are 1-based, but it is simpler to work with 0-based
-	 * when computing indices
-	 */
-	index -= 1;
-	block_group = index / inodes_per_group;
-	offset_in_group = index % inodes_per_group;
-	
-	rc = ext2_filesystem_get_block_group_ref(fs, block_group, &bg_ref);
-	if (rc != EOK) {
-		free(newref);
-		return rc;
-	}
-	
-	inode_table_start = ext2_block_group_get_inode_table_first_block(
-	    bg_ref->block_group);
-	
-	rc = ext2_filesystem_put_block_group_ref(bg_ref);
-	if (rc != EOK) {
-		free(newref);
-		return rc;
-	}
-
-	inode_size = ext2_superblock_get_inode_size(fs->superblock);
-	block_size = ext2_superblock_get_block_size(fs->superblock);
-	
-	byte_offset_in_group = offset_in_group * inode_size;
-	
-	block_id = inode_table_start + (byte_offset_in_group / block_size);
-	offset_in_block = byte_offset_in_group % block_size;
-	
-	rc = block_get(&newref->block, fs->device, block_id, 0);
-	if (rc != EOK) {
-		free(newref);
-		return rc;
-	}
-	
-	newref->inode = newref->block->data + offset_in_block;
-	/* we decremented index above, but need to store the original value
-	 * in the reference
-	 */
-	newref->index = index+1;
-	
-	*ref = newref;
-	
-	return EOK;
-}
-
-/**
- * Free a reference to inode
- * 
- * @param ref Pointer to inode reference to free
- * 
- * @return 		EOK on success or negative error code on failure
- */
-int ext2_filesystem_put_inode_ref(ext2_inode_ref_t *ref)
-{
-	int rc;
-	
-	rc = block_put(ref->block);
-	free(ref);
-	
-	return rc;
-}
-
-/**
- * Find a filesystem block number where iblock-th data block
- * of the given inode is located.
- * 
- * @param fblock the number of filesystem block, or 0 if no such block is allocated yet
- * 
- * @return 		EOK on success or negative error code on failure
- */
-int ext2_filesystem_get_inode_data_block_index(ext2_filesystem_t *fs, ext2_inode_t* inode,
-    aoff64_t iblock, uint32_t* fblock)
-{
-	int rc;
-	aoff64_t limits[4];
-	uint32_t block_ids_per_block;
-	aoff64_t blocks_per_level[4];
-	uint32_t offset_in_block;
-	uint32_t current_block;
-	aoff64_t block_offset_in_level;
-	int i;
-	int level;
-	block_t *block;
-	
-	/* Handle simple case when we are dealing with direct reference */ 
-	if (iblock < EXT2_INODE_DIRECT_BLOCKS) {
-		current_block = ext2_inode_get_direct_block(inode, (uint32_t)iblock);
-		*fblock = current_block;
-		return EOK;
-	}
-	
-	/* Compute limits for indirect block levels
-	 * TODO: compute this once when loading filesystem and store in ext2_filesystem_t
-	 */
-	block_ids_per_block = ext2_superblock_get_block_size(fs->superblock) / sizeof(uint32_t);
-	limits[0] = EXT2_INODE_DIRECT_BLOCKS;
-	blocks_per_level[0] = 1;
-	for (i = 1; i < 4; i++) {
-		blocks_per_level[i]  = blocks_per_level[i-1] *
-		    block_ids_per_block;
-		limits[i] = limits[i-1] + blocks_per_level[i];
-	}
-	
-	/* Determine the indirection level needed to get the desired block */
-	level = -1;
-	for (i = 1; i < 4; i++) {
-		if (iblock < limits[i]) {
-			level = i;
-			break;
-		}
-	}
-	
-	if (level == -1) {
-		return EIO;
-	}
-	
-	/* Compute offsets for the topmost level */
-	block_offset_in_level = iblock - limits[level-1];
-	current_block = ext2_inode_get_indirect_block(inode, level-1);
-	offset_in_block = block_offset_in_level / blocks_per_level[level-1];
-	
-	/* Navigate through other levels, until we find the block number
-	 * or find null reference meaning we are dealing with sparse file
-	 */
-	while (level > 0) {
-		rc = block_get(&block, fs->device, current_block, 0);
-		if (rc != EOK) {
-			return rc;
-		}
-		
-		assert(offset_in_block < block_ids_per_block);
-		current_block = uint32_t_le2host(((uint32_t*)block->data)[offset_in_block]);
-		
-		rc = block_put(block);
-		if (rc != EOK) {
-			return rc;
-		}
-		
-		if (current_block == 0) {
-			/* This is a sparse file */
-			*fblock = 0;
-			return EOK;
-		}
-		
-		level -= 1;
-		
-		/* If we are on the last level, break here as
-		 * there is no next level to visit
-		 */
-		if (level == 0) {
-			break;
-		}
-		
-		/* Visit the next level */
-		block_offset_in_level %= blocks_per_level[level];
-		offset_in_block = block_offset_in_level / blocks_per_level[level-1];
-	}
-	
-	*fblock = current_block;
-	
-	return EOK;
-}
-
-/**
- * Allocate a given number of blocks and store their ids in blocks
- * 
- * @todo TODO: This function is not finished and really has never been
- *             used (and tested) yet
- * 
- * @param fs pointer to filesystem
- * @param blocks array of count uint32_t values where store block ids
- * @param count number of blocks to allocate and elements in blocks array
- * @param preferred_bg preferred block group number
- * 
- * @return 		EOK on success or negative error code on failure
- */
-int ext2_filesystem_allocate_blocks(ext2_filesystem_t *fs, uint32_t *blocks,
-    size_t count, uint32_t preferred_bg)
-{
-	uint32_t bg_count = ext2_superblock_get_block_group_count(fs->superblock);
-	uint32_t bpg = ext2_superblock_get_blocks_per_group(fs->superblock);
-	uint32_t block_size = ext2_superblock_get_block_size(fs->superblock);
-	uint32_t block_group = preferred_bg;
-	uint32_t free_blocks_sb;
-	uint32_t block_groups_left;
-	size_t idx;
-	ext2_block_group_ref_t *bg;
-	int rc;
-	uint32_t bb_block;
-	block_t *block;
-	size_t bb_idx;
-	size_t bb_bit;
-	
-	free_blocks_sb = ext2_superblock_get_free_block_count(fs->superblock);
-	
-	if (count > free_blocks_sb) {
-		return EIO;
-	}
-	
-	block_groups_left = bg_count;
-	
-	idx = 0;
-	
-	/* Read the block group descriptor */
-	rc = ext2_filesystem_get_block_group_ref(fs, block_group, &bg);
-	if (rc != EOK) {
-		goto failed;
-	}
-	
-	while (idx < count && block_groups_left > 0) {
-		uint16_t fb = ext2_block_group_get_free_block_count(bg->block_group);
-		if (fb == 0) {
-			block_group = (block_group + 1) % bg_count;
-			block_groups_left -= 1;
-			
-			rc = ext2_filesystem_put_block_group_ref(bg);
-			if (rc != EOK) {
-				goto failed;
-			}
-			
-			rc = ext2_filesystem_get_block_group_ref(fs, block_group, &bg);
-			if (rc != EOK) {
-				goto failed;
-			}
-			continue;
-		}
-		
-		/* We found a block group with free block, let's look at the block bitmap */
-		bb_block = ext2_block_group_get_block_bitmap_block(bg->block_group);
-		
-		rc = block_get(&block, fs->device, bb_block, BLOCK_FLAGS_NONE);
-		if (rc != EOK) {
-			goto failed;
-		}
-		
-		/* Use all blocks from this block group */
-		for (bb_idx = 0; bb_idx < block_size && idx < count; bb_idx++) {
-			uint8_t *data = (uint8_t *) block->data;
-			if (data[bb_idx] == 0xff) {
-				continue;
-			}
-			/* find an empty bit */
-			uint8_t mask;
-			for (mask = 1, bb_bit = 0;
-				 bb_bit < 8 && idx < count; 
-				 bb_bit++, mask = mask << 1) {
-				if ((data[bb_idx] & mask) == 0) {
-					// free block found
-					blocks[idx] = block_group * bpg + bb_idx*8 + bb_bit;
-					data[bb_idx] |= mask;
-					idx += 1;
-					fb -= 1;
-					ext2_block_group_set_free_block_count(bg->block_group, fb);
-				}
-			}
-		}
-	}
-	
-	rc = ext2_filesystem_put_block_group_ref(bg);
-	if (rc != EOK) {
-		goto failed;
-	}
-	
-	// TODO update superblock
-	
-	return EOK;
-failed:
-	// TODO deallocate already allocated blocks, if possible
-	
-	return rc;
-}
-
-/**
- * Finalize an instance of filesystem
- * 
- * @param fs Pointer to ext2_filesystem_t to finalize
- */
-void ext2_filesystem_fini(ext2_filesystem_t *fs)
-{
-	free(fs->superblock);
-	block_fini(fs->device);
-}
-
-
-/** @}
- */
Index: uspace/lib/ext2/libext2_filesystem.h
===================================================================
--- uspace/lib/ext2/libext2_filesystem.h	(revision d1538a1fa3100ff880b0dd2c1b9e79fdec6ea762)
+++ 	(revision )
@@ -1,78 +1,0 @@
-/*
- * Copyright (c) 2011 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_FILESYSTEM_H_
-#define LIBEXT2_LIBEXT2_FILESYSTEM_H_
-
-#include <block.h>
-#include "libext2_superblock.h"
-#include "libext2_block_group.h"
-#include "libext2_inode.h"
-
-typedef struct ext2_filesystem {
-	service_id_t		device;
-	ext2_superblock_t *	superblock;
-} ext2_filesystem_t;
-
-// allow maximum this block size
-#define EXT2_MAX_BLOCK_SIZE			8096
-#define EXT2_REV0_FIRST_INODE		11
-#define EXT2_REV0_INODE_SIZE		128
-
-#define EXT2_FEATURE_RO_SPARSE_SUPERBLOCK	1
-#define EXT2_FEATURE_RO_LARGE_FILE			2
-#define EXT2_FEATURE_I_TYPE_IN_DIR			2
-
-#define EXT2_SUPPORTED_INCOMPATIBLE_FEATURES EXT2_FEATURE_I_TYPE_IN_DIR
-#define EXT2_SUPPORTED_READ_ONLY_FEATURES 0
-
-extern int ext2_filesystem_init(ext2_filesystem_t *, service_id_t);
-extern int ext2_filesystem_check_sanity(ext2_filesystem_t *);
-extern int ext2_filesystem_check_flags(ext2_filesystem_t *, bool *);
-extern int ext2_filesystem_get_block_group_ref(ext2_filesystem_t *, uint32_t, 
-    ext2_block_group_ref_t **);
-extern int ext2_filesystem_put_block_group_ref(ext2_block_group_ref_t *);
-extern int ext2_filesystem_get_inode_ref(ext2_filesystem_t *, uint32_t,
-    ext2_inode_ref_t **);
-extern int ext2_filesystem_put_inode_ref(ext2_inode_ref_t *);
-extern int ext2_filesystem_get_inode_data_block_index(ext2_filesystem_t *, ext2_inode_t*,
-    aoff64_t, uint32_t*);
-extern int ext2_filesystem_allocate_blocks(ext2_filesystem_t *, uint32_t *, size_t, uint32_t);
-extern void ext2_filesystem_fini(ext2_filesystem_t *);
-
-#endif
-
-/** @}
- */
Index: uspace/lib/ext2/libext2_inode.c
===================================================================
--- uspace/lib/ext2/libext2_inode.c	(revision d1538a1fa3100ff880b0dd2c1b9e79fdec6ea762)
+++ 	(revision )
@@ -1,192 +1,0 @@
-/*
- * Copyright (c) 2011 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 "libext2_inode.h"
-#include "libext2_superblock.h"
-#include <byteorder.h>
-#include <assert.h>
-
-/**
- * Get mode stored in the inode
- * 
- * @param inode pointer to inode
- */
-uint32_t ext2_inode_get_mode(ext2_superblock_t *sb, ext2_inode_t *inode)
-{
-	if (ext2_superblock_get_os(sb) == EXT2_SUPERBLOCK_OS_HURD) {
-		return ((uint32_t)uint16_t_le2host(inode->mode_high)) << 16 |
-		    ((uint32_t)uint16_t_le2host(inode->mode));
-	}
-	return uint16_t_le2host(inode->mode);
-}
-
-/**
- * Check whether inode is of given type
- * 
- * @param sb pointer to superblock structure
- * @param inode pointer to inode
- * @param type EXT2_INODE_MODE_TYPE_* constant to check
- */
-bool ext2_inode_is_type(ext2_superblock_t *sb, ext2_inode_t *inode, uint32_t type)
-{
-	uint32_t mode = ext2_inode_get_mode(sb, inode);
-	return (mode & EXT2_INODE_MODE_TYPE_MASK) == type;
-}
-
-/**
- * Get uid this inode is belonging to
- * 
- * @param inode pointer to inode
- */
-uint32_t ext2_inode_get_user_id(ext2_superblock_t *sb, ext2_inode_t *inode)
-{
-	uint32_t os = ext2_superblock_get_os(sb);
-	if (os == EXT2_SUPERBLOCK_OS_LINUX || os == EXT2_SUPERBLOCK_OS_HURD) {
-		return ((uint32_t)uint16_t_le2host(inode->user_id_high)) << 16 |
-		    ((uint32_t)uint16_t_le2host(inode->user_id));
-	}
-	return uint16_t_le2host(inode->user_id);
-}
-
-/**
- * Get size of file
- * 
- * For regular files in revision 1 and later, the high 32 bits of
- * file size are stored in inode->size_high and are 0 otherwise
- * 
- * @param inode pointer to inode
- */
-uint64_t ext2_inode_get_size(ext2_superblock_t *sb, ext2_inode_t *inode)
-{
-	uint32_t major_rev = ext2_superblock_get_rev_major(sb);
-	
-	if (major_rev > 0 && ext2_inode_is_type(sb, inode, EXT2_INODE_MODE_FILE)) {
-		return ((uint64_t)uint32_t_le2host(inode->size_high)) << 32 |
-		    ((uint64_t)uint32_t_le2host(inode->size));
-	}
-	return uint32_t_le2host(inode->size);
-}
-
-/**
- * Get gid this inode belongs to
- * 
- * For Linux and Hurd, the high 16 bits are stored in OS dependent part
- * of inode structure
- * 
- * @param inode pointer to inode
- */
-uint32_t ext2_inode_get_group_id(ext2_superblock_t *sb, ext2_inode_t *inode)
-{
-	uint32_t os = ext2_superblock_get_os(sb);
-	if (os == EXT2_SUPERBLOCK_OS_LINUX || os == EXT2_SUPERBLOCK_OS_HURD) {
-		return ((uint32_t)uint16_t_le2host(inode->group_id_high)) << 16 |
-		    ((uint32_t)uint16_t_le2host(inode->group_id));
-	}
-	return uint16_t_le2host(inode->group_id);
-}
-
-/**
- * Get usage count (i.e. hard link count)
- * A value of 1 is common, while 0 means that the inode should be freed
- * 
- * @param inode pointer to inode
- */
-uint16_t ext2_inode_get_usage_count(ext2_inode_t *inode)
-{
-	return uint16_t_le2host(inode->usage_count);
-}
-
-/**
- * Get number of 512-byte data blocks allocated for contents of the file
- * represented by this inode.
- * This should be multiple of block size unless fragments are used.
- * 
- * @param inode pointer to inode
- */
-uint32_t ext2_inode_get_reserved_512_blocks(ext2_inode_t *inode)
-{
-	return uint32_t_le2host(inode->reserved_512_blocks);
-}
-
-/**
- * Get number of blocks allocated for contents of the file
- * represented by this inode.
- * 
- * @param inode pointer to inode
- */
-uint32_t ext2_inode_get_reserved_blocks(ext2_superblock_t *sb,
-    ext2_inode_t *inode)
-{
-	return ext2_inode_get_reserved_512_blocks(inode) /
-	    (ext2_superblock_get_block_size(sb) / 512);
-}
-
-/**
- * Get inode flags
- * 
- * @param inode pointer to inode
- */
-uint32_t ext2_inode_get_flags(ext2_inode_t *inode) {
-	return uint32_t_le2host(inode->flags);
-}
-
-/**
- * Get direct block ID
- * 
- * @param inode pointer to inode
- * @param idx Index to block. Valid values are 0 <= idx < 12
- */
-uint32_t ext2_inode_get_direct_block(ext2_inode_t *inode, uint8_t idx)
-{
-	assert(idx < EXT2_INODE_DIRECT_BLOCKS);
-	return uint32_t_le2host(inode->direct_blocks[idx]);
-}
-
-/**
- * Get indirect block ID
- * 
- * @param inode pointer to inode
- * @param idx Indirection level. Valid values are 0 <= idx < 3, where 0 is
- *            singly-indirect block and 2 is triply-indirect-block
- */
-uint32_t ext2_inode_get_indirect_block(ext2_inode_t *inode, uint8_t idx)
-{
-	assert(idx < 3);
-	return uint32_t_le2host(inode->indirect_blocks[idx]);
-}
-
-/** @}
- */
Index: uspace/lib/ext2/libext2_inode.h
===================================================================
--- uspace/lib/ext2/libext2_inode.h	(revision d1538a1fa3100ff880b0dd2c1b9e79fdec6ea762)
+++ 	(revision )
@@ -1,103 +1,0 @@
-/*
- * Copyright (c) 2011 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_INODE_H_
-#define LIBEXT2_LIBEXT2_INODE_H_
-
-#include <block.h>
-#include "libext2_superblock.h"
-
-typedef struct ext2_inode {
-	uint16_t mode;
-	uint16_t user_id;
-	uint32_t size;
-	uint8_t unused[16];
-	uint16_t group_id;
-	uint16_t usage_count; // Hard link count, when 0 the inode is to be freed
-	uint32_t reserved_512_blocks; // Size of this inode in 512-byte blocks
-	uint32_t flags;
-	uint8_t unused2[4];
-	uint32_t direct_blocks[12]; // Direct block ids stored in this inode
-	uint32_t indirect_blocks[3];
-	uint32_t version;
-	uint32_t file_acl;
-	union {
-		uint32_t dir_acl;
-		uint32_t size_high; // For regular files in version >= 1
-	} __attribute__ ((packed));
-	uint8_t unused3[6];
-	uint16_t mode_high; // Hurd only
-	uint16_t user_id_high; // Linux/Hurd only
-	uint16_t group_id_high; // Linux/Hurd only
-} __attribute__ ((packed)) ext2_inode_t;
-
-#define EXT2_INODE_MODE_FIFO		0x1000
-#define EXT2_INODE_MODE_CHARDEV		0x2000
-#define EXT2_INODE_MODE_DIRECTORY	0x4000
-#define EXT2_INODE_MODE_BLOCKDEV	0x6000
-#define EXT2_INODE_MODE_FILE		0x8000
-#define EXT2_INODE_MODE_SOFTLINK	0xA000
-#define EXT2_INODE_MODE_SOCKET		0xC000
-#define EXT2_INODE_MODE_ACCESS_MASK	0x0FFF
-#define EXT2_INODE_MODE_TYPE_MASK	0xF000
-#define EXT2_INODE_DIRECT_BLOCKS	12
-
-#define EXT2_INODE_ROOT_INDEX		2
-
-typedef struct ext2_inode_ref {
-	block_t *block; // Reference to a block containing this inode
-	ext2_inode_t *inode;
-	uint32_t index; // Index number of this inode
-} ext2_inode_ref_t;
-
-extern uint32_t ext2_inode_get_mode(ext2_superblock_t *, ext2_inode_t *);
-extern bool ext2_inode_is_type(ext2_superblock_t *, ext2_inode_t *, uint32_t);
-extern uint32_t ext2_inode_get_user_id(ext2_superblock_t *, ext2_inode_t *);
-extern uint64_t ext2_inode_get_size(ext2_superblock_t *, ext2_inode_t *);
-extern uint32_t ext2_inode_get_group_id(ext2_superblock_t *, ext2_inode_t *);
-extern uint16_t ext2_inode_get_usage_count(ext2_inode_t *);
-extern uint32_t ext2_inode_get_reserved_512_blocks(ext2_inode_t *);
-extern uint32_t ext2_inode_get_reserved_blocks(ext2_superblock_t *, 
-    ext2_inode_t *);
-extern uint32_t ext2_inode_get_flags(ext2_inode_t *);
-extern uint32_t ext2_inode_get_direct_block(ext2_inode_t *, uint8_t);
-extern uint32_t ext2_inode_get_indirect_block(ext2_inode_t *, uint8_t level);
-
-
-
-#endif
-
-/** @}
- */
Index: uspace/lib/ext2/libext2_superblock.c
===================================================================
--- uspace/lib/ext2/libext2_superblock.c	(revision d1538a1fa3100ff880b0dd2c1b9e79fdec6ea762)
+++ 	(revision )
@@ -1,409 +1,0 @@
-/*
- * Copyright (c) 2011 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 <errno.h>
-#include <malloc.h>
-#include <block.h>
-#include <byteorder.h>
-
-/**
- * Return a magic number from ext2 superblock, this should be equal to
- * EXT_SUPERBLOCK_MAGIC for valid ext2 superblock
- * 
- * @param sb pointer to superblock
- */
-uint16_t ext2_superblock_get_magic(ext2_superblock_t *sb)
-{
-	return uint16_t_le2host(sb->magic);
-}
-
-/**
- * Get the position of first ext2 data block (i.e. the block number
- * containing main superblock)
- * 
- * @param sb pointer to superblock
- */
-uint32_t ext2_superblock_get_first_block(ext2_superblock_t *sb)
-{
-	return uint32_t_le2host(sb->first_block);
-}
-
-/**
- * Get the number of bits to shift a value of 1024 to the left necessary
- * to get the size of a block
- * 
- * @param sb pointer to superblock
- */
-uint32_t ext2_superblock_get_block_size_log2(ext2_superblock_t *sb)
-{
-	return uint32_t_le2host(sb->block_size_log2);
-}
-
-/**
- * Get the size of a block, in bytes 
- * 
- * @param sb pointer to superblock
- */
-uint32_t ext2_superblock_get_block_size(ext2_superblock_t *sb)
-{
-	return 1024 << ext2_superblock_get_block_size_log2(sb);
-}
-
-/**
- * Get the number of bits to shift a value of 1024 to the left necessary
- * to get the size of a fragment (note that this is a signed integer and
- * if negative, the value should be shifted to the right instead)
- * 
- * @param sb pointer to superblock
- */
-int32_t ext2_superblock_get_fragment_size_log2(ext2_superblock_t *sb)
-{
-	return uint32_t_le2host(sb->fragment_size_log2);
-}
-
-/**
- * Get the size of a fragment, in bytes 
- * 
- * @param sb pointer to superblock
- */
-uint32_t ext2_superblock_get_fragment_size(ext2_superblock_t *sb)
-{
-	int32_t log = ext2_superblock_get_fragment_size_log2(sb);
-	if (log >= 0) {
-		return 1024 << log;
-	}
-	else {
-		return 1024 >> -log;
-	}
-}
-
-/**
- * Get number of blocks per block group
- * 
- * @param sb pointer to superblock
- */
-uint32_t ext2_superblock_get_blocks_per_group(ext2_superblock_t *sb)
-{
-	return uint32_t_le2host(sb->blocks_per_group);
-}
-
-/**
- * Get number of fragments per block group
- * 
- * @param sb pointer to superblock
- */
-uint32_t ext2_superblock_get_fragments_per_group(ext2_superblock_t *sb)
-{
-	return uint32_t_le2host(sb->fragments_per_group);
-}
-
-/**
- * Get filesystem state
- * 
- * @param sb pointer to superblock
- */
-uint16_t ext2_superblock_get_state(ext2_superblock_t *sb)
-{
-	return uint16_t_le2host(sb->state);
-}
-
-/**
- * Get minor revision number
- * 
- * @param sb pointer to superblock
- */
-uint16_t ext2_superblock_get_rev_minor(ext2_superblock_t *sb)
-{
-	return uint16_t_le2host(sb->rev_minor);
-}
-
-/**
- * Get major revision number
- * 
- * @param sb pointer to superblock
- */
-uint32_t ext2_superblock_get_rev_major(ext2_superblock_t *sb)
-{
-	return uint32_t_le2host(sb->rev_major);
-}
-
-/**
- * Get index of first regular inode
- * 
- * @param sb pointer to superblock
- */
-uint32_t ext2_superblock_get_first_inode(ext2_superblock_t *sb)
-{
-	if (ext2_superblock_get_rev_major(sb) == 0) {
-		return EXT2_REV0_FIRST_INODE;
-	}
-	return uint32_t_le2host(sb->first_inode);
-}
-
-/**
- * Get size of inode
- * 
- * @param sb pointer to superblock
- */
-uint16_t ext2_superblock_get_inode_size(ext2_superblock_t *sb)
-{
-	if (ext2_superblock_get_rev_major(sb) == 0) {
-		return EXT2_REV0_INODE_SIZE;
-	}
-	return uint16_t_le2host(sb->inode_size);
-}
-
-/**
- * Get total inode count
- * 
- * @param sb pointer to superblock
- */
-uint32_t ext2_superblock_get_total_inode_count(ext2_superblock_t *sb)
-{
-	return uint32_t_le2host(sb->total_inode_count);
-}
-
-/**
- * Get total block count
- * 
- * @param sb pointer to superblock
- */
-uint32_t ext2_superblock_get_total_block_count(ext2_superblock_t *sb)
-{
-	return uint32_t_le2host(sb->total_block_count);
-}
-
-/**
- * Get amount of blocks reserved for the superuser
- * 
- * @param sb pointer to superblock
- */
-uint32_t ext2_superblock_get_reserved_block_count(ext2_superblock_t *sb)
-{
-	return uint32_t_le2host(sb->reserved_block_count);
-}
-
-/**
- * Get amount of free blocks
- * 
- * @param sb pointer to superblock
- */
-uint32_t ext2_superblock_get_free_block_count(ext2_superblock_t *sb)
-{
-	return uint32_t_le2host(sb->free_block_count);
-}
-
-/**
- * Get amount of free inodes
- * 
- * @param sb pointer to superblock
- */
-uint32_t ext2_superblock_get_free_inode_count(ext2_superblock_t *sb)
-{
-	return uint32_t_le2host(sb->free_inode_count);
-}
-
-/**
- * Get id of operating system that created the filesystem
- * 
- * @param sb pointer to superblock
- */
-uint32_t ext2_superblock_get_os(ext2_superblock_t *sb)
-{
-	return uint32_t_le2host(sb->os);
-}
-
-/**
- * Get count of inodes per block group
- * 
- * @param sb pointer to superblock
- */
-uint32_t ext2_superblock_get_inodes_per_group(ext2_superblock_t *sb)
-{
-	return uint32_t_le2host(sb->inodes_per_group);
-}
-
-/**
- * Get compatible features flags
- * 
- * @param sb pointer to superblock
- */
-uint32_t ext2_superblock_get_features_compatible(ext2_superblock_t *sb)
-{
-	return uint32_t_le2host(sb->features_compatible);
-}
-
-/**
- * Get incompatible features flags
- * 
- * @param sb pointer to superblock
- */
-uint32_t ext2_superblock_get_features_incompatible(ext2_superblock_t *sb)
-{
-	return uint32_t_le2host(sb->features_incompatible);
-}
-
-/**
- * Get read-only compatible features flags
- * 
- * @param sb pointer to superblock
- */
-uint32_t ext2_superblock_get_features_read_only(ext2_superblock_t *sb)
-{
-	return uint32_t_le2host(sb->features_read_only);
-}
-
-/**
- * Compute count of block groups present in the filesystem
- * 
- * Note: This function works only for correct filesystem,
- *       i.e. it assumes that total block count > 0 and
- *       blocks per group > 0
- * 
- * Example:
- *   If there are 3 blocks per group, the result should be as follows:
- *   Total blocks	Result
- *   1				1
- *   2				1
- *   3				1
- *   4				2
- * 
- * 
- * @param sb pointer to superblock
- */
-uint32_t ext2_superblock_get_block_group_count(ext2_superblock_t *sb)
-{
-	/* We add one to the result because e.g. 2/3 = 0, while to store
-	 *  2 blocks in 3-block group we need one (1) block group
-	 * 
-	 * We subtract one first because of special case that to store e.g.
-	 *  3 blocks in a 3-block group we need only one group
-	 *  (and 3/3 yields one - this is one more that we want as we
-	 *   already add one at the end)
-	 */ 
-	return ((ext2_superblock_get_total_block_count(sb)-1) / 
-	    ext2_superblock_get_blocks_per_group(sb))+1;
-}
-
-/** Read a superblock directly from device (i.e. no libblock cache)
- * 
- * @param service_id	Service ID of the block device.
- * @param superblock	Pointer where to store pointer to new superblock
- * 
- * @return		EOK on success or negative error code on failure.
- */
-int ext2_superblock_read_direct(service_id_t service_id,
-    ext2_superblock_t **superblock)
-{
-	void *data;
-	int rc;
-	
-	data = malloc(EXT2_SUPERBLOCK_SIZE);
-	if (data == NULL) {
-		return ENOMEM;
-	}
-	
-	rc = block_read_bytes_direct(service_id, EXT2_SUPERBLOCK_OFFSET,
-	    EXT2_SUPERBLOCK_SIZE, data);
-	if (rc != EOK) {
-		free(data);
-		return rc;
-	}
-	
-	(*superblock) = data;
-	return EOK;
-}
-
-/** Check a superblock for sanity
- * 
- * @param sb	Pointer to superblock
- * 
- * @return		EOK on success or negative error code on failure.
- */
-int ext2_superblock_check_sanity(ext2_superblock_t *sb)
-{
-	if (ext2_superblock_get_magic(sb) != EXT2_SUPERBLOCK_MAGIC) {
-		return ENOTSUP;
-	}
-	
-	if (ext2_superblock_get_rev_major(sb) > 1) {
-		return ENOTSUP;
-	}
-	
-	if (ext2_superblock_get_total_inode_count(sb) == 0) {
-		return ENOTSUP;
-	}
-	
-	if (ext2_superblock_get_total_block_count(sb) == 0) {
-		return ENOTSUP;
-	}
-	
-	if (ext2_superblock_get_blocks_per_group(sb) == 0) {
-		return ENOTSUP;
-	}
-	
-	if (ext2_superblock_get_fragments_per_group(sb) == 0) {
-		return ENOTSUP;
-	}
-	
-	/* We don't support fragments smaller than block */
-	if (ext2_superblock_get_block_size(sb) != 
-		    ext2_superblock_get_fragment_size(sb)) {
-		return ENOTSUP;
-	}
-	if (ext2_superblock_get_blocks_per_group(sb) !=
-		    ext2_superblock_get_fragments_per_group(sb)) {
-		return ENOTSUP;
-	}
-	
-	if (ext2_superblock_get_inodes_per_group(sb) == 0) {
-		return ENOTSUP;
-	}
-	
-	if (ext2_superblock_get_inode_size(sb) < 128) {
-		return ENOTSUP;
-	}
-	
-	if (ext2_superblock_get_first_inode(sb) < 11) {
-		return ENOTSUP;
-	}
-	
-	return EOK;
-}
-
-
-/** @}
- */
Index: uspace/lib/ext2/libext2_superblock.h
===================================================================
--- uspace/lib/ext2/libext2_superblock.h	(revision d1538a1fa3100ff880b0dd2c1b9e79fdec6ea762)
+++ 	(revision )
@@ -1,118 +1,0 @@
-/*
- * Copyright (c) 2011 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_SUPERBLOCK_H_
-#define LIBEXT2_LIBEXT2_SUPERBLOCK_H_
-
-#include <block.h>
-
-typedef struct ext2_superblock {
-	uint32_t	total_inode_count; // Total number of inodes
-	uint32_t	total_block_count; // Total number of blocks
-	uint32_t	reserved_block_count; // Total number of reserved blocks
-	uint32_t	free_block_count; // Total number of free blocks
-	uint32_t	free_inode_count; // Total number of free inodes
-	uint32_t	first_block; // Block containing the superblock (either 0 or 1)
-	uint32_t	block_size_log2; // log_2(block_size)
-	int32_t		fragment_size_log2; // log_2(fragment size)
-	uint32_t	blocks_per_group; // Number of blocks in one block group
-	uint32_t	fragments_per_group; // Number of fragments per block group
-	uint32_t	inodes_per_group; // Number of inodes per block group
-	uint8_t		unused2[12];
-	uint16_t	magic; // Magic value
-	uint16_t	state; // State (mounted/unmounted)
-	uint16_t	error_behavior; // What to do when errors are encountered
-	uint16_t	rev_minor; // Minor revision level
-	uint8_t		unused3[8];
-	uint32_t	os; // OS that created the filesystem
-	uint32_t	rev_major; // Major revision level
-	uint8_t		unused4[4];
-	
-	// Following is for ext2 revision 1 only
-	uint32_t	first_inode;
-	uint16_t	inode_size;
-	uint16_t	unused5;
-	uint32_t	features_compatible;
-	uint32_t	features_incompatible;
-	uint32_t	features_read_only;
-	uint8_t		uuid[16]; // UUID TODO: Create a library for UUIDs
-	uint8_t		volume_name[16];
-
-// TODO: add __attribute__((aligned(...)) for better performance?
-//       (it is necessary to ensure the superblock is correctly aligned then
-//        though)
-} __attribute__ ((packed)) ext2_superblock_t;
-
-#define EXT2_SUPERBLOCK_MAGIC		0xEF53
-#define EXT2_SUPERBLOCK_SIZE		1024
-#define EXT2_SUPERBLOCK_OFFSET		1024
-#define EXT2_SUPERBLOCK_LAST_BYTE	(EXT2_SUPERBLOCK_OFFSET + \
-									 EXT2_SUPERBLOCK_SIZE -1)
-#define EXT2_SUPERBLOCK_OS_LINUX	0
-#define EXT2_SUPERBLOCK_OS_HURD		1
-
-
-extern uint16_t	ext2_superblock_get_magic(ext2_superblock_t *);
-extern uint32_t	ext2_superblock_get_first_block(ext2_superblock_t *);
-extern uint32_t	ext2_superblock_get_block_size_log2(ext2_superblock_t *);
-extern uint32_t	ext2_superblock_get_block_size(ext2_superblock_t *);
-extern int32_t	ext2_superblock_get_fragment_size_log2(ext2_superblock_t *);
-extern uint32_t	ext2_superblock_get_fragment_size(ext2_superblock_t *);
-extern uint32_t	ext2_superblock_get_blocks_per_group(ext2_superblock_t *);
-extern uint32_t	ext2_superblock_get_fragments_per_group(ext2_superblock_t *);
-extern uint16_t	ext2_superblock_get_state(ext2_superblock_t *);
-extern uint16_t	ext2_superblock_get_rev_minor(ext2_superblock_t *);
-extern uint32_t	ext2_superblock_get_rev_major(ext2_superblock_t *);
-extern uint32_t	ext2_superblock_get_os(ext2_superblock_t *);
-extern uint32_t	ext2_superblock_get_first_inode(ext2_superblock_t *);
-extern uint16_t	ext2_superblock_get_inode_size(ext2_superblock_t *);
-extern uint32_t	ext2_superblock_get_total_inode_count(ext2_superblock_t *);
-extern uint32_t	ext2_superblock_get_total_block_count(ext2_superblock_t *);
-extern uint32_t	ext2_superblock_get_reserved_block_count(ext2_superblock_t *);
-extern uint32_t	ext2_superblock_get_free_block_count(ext2_superblock_t *);
-extern uint32_t	ext2_superblock_get_free_inode_count(ext2_superblock_t *);
-extern uint32_t	ext2_superblock_get_block_group_count(ext2_superblock_t *);
-extern uint32_t	ext2_superblock_get_inodes_per_group(ext2_superblock_t *);
-extern uint32_t	ext2_superblock_get_features_compatible(ext2_superblock_t *);
-extern uint32_t	ext2_superblock_get_features_incompatible(ext2_superblock_t *);
-extern uint32_t	ext2_superblock_get_features_read_only(ext2_superblock_t *);
-
-extern int ext2_superblock_read_direct(service_id_t, ext2_superblock_t **);
-extern int ext2_superblock_check_sanity(ext2_superblock_t *);
-
-#endif
-
-/** @}
- */
