Index: .bzrignore
===================================================================
--- .bzrignore	(revision cffa82aac31c77f5d26f954922753c58edfef5f7)
+++ .bzrignore	(revision f71b93841daab94be37cbab4f471444712807695)
@@ -183,5 +183,4 @@
 uspace/dist/srv/fat
 uspace/dist/srv/file_bd
-uspace/dist/srv/g_part
 uspace/dist/srv/hound
 uspace/dist/srv/i8259
@@ -191,5 +190,4 @@
 uspace/dist/srv/locfs
 uspace/dist/srv/loopip
-uspace/dist/srv/mbr_part
 uspace/dist/srv/mfs
 uspace/dist/srv/output
@@ -256,6 +254,4 @@
 uspace/srv/audio/hound/hound
 uspace/srv/bd/file_bd/file_bd
-uspace/srv/bd/part/guid_part/g_part
-uspace/srv/bd/part/mbr_part/mbr_part
 uspace/srv/bd/rd/rd
 uspace/srv/bd/sata_bd/sata_bd
@@ -319,6 +315,4 @@
 uspace/app/viewer/viewer
 uspace/dist/app/viewer
-uspace/app/hdisk/hdisk
-uspace/dist/app/hdisk
 uspace/app/untar/untar
 uspace/dist/app/untar
Index: boot/Makefile.common
===================================================================
--- boot/Makefile.common	(revision cffa82aac31c77f5d26f954922753c58edfef5f7)
+++ boot/Makefile.common	(revision f71b93841daab94be37cbab4f471444712807695)
@@ -101,6 +101,4 @@
 RD_SRVS_NON_ESSENTIAL = \
 	$(USPACE_PATH)/srv/bd/file_bd/file_bd \
-	$(USPACE_PATH)/srv/bd/part/guid_part/g_part \
-	$(USPACE_PATH)/srv/bd/part/mbr_part/mbr_part \
 	$(USPACE_PATH)/srv/bd/sata_bd/sata_bd \
 	$(USPACE_PATH)/srv/bd/vbd/vbd \
@@ -185,5 +183,4 @@
 	$(USPACE_PATH)/app/edit/edit \
 	$(USPACE_PATH)/app/fdisk/fdisk \
-	$(USPACE_PATH)/app/hdisk/hdisk \
 	$(USPACE_PATH)/app/inet/inet \
 	$(USPACE_PATH)/app/kill/kill \
Index: uspace/Makefile
===================================================================
--- uspace/Makefile	(revision cffa82aac31c77f5d26f954922753c58edfef5f7)
+++ uspace/Makefile	(revision f71b93841daab94be37cbab4f471444712807695)
@@ -48,5 +48,4 @@
 	app/fontviewer \
 	app/getterm \
-	app/hdisk \
 	app/init \
 	app/inet \
@@ -113,6 +112,4 @@
 	srv/bd/file_bd \
 	srv/bd/rd \
-	srv/bd/part/guid_part \
-	srv/bd/part/mbr_part \
 	srv/bd/vbd \
 	srv/fs/exfat \
@@ -249,6 +246,4 @@
 	lib/bithenge \
 	lib/posix \
-	lib/mbr \
-	lib/gpt \
 	lib/ieee80211
 
Index: uspace/Makefile.common
===================================================================
--- uspace/Makefile.common	(revision cffa82aac31c77f5d26f954922753c58edfef5f7)
+++ uspace/Makefile.common	(revision f71b93841daab94be37cbab4f471444712807695)
@@ -157,6 +157,4 @@
 LIBURI_PREFIX = $(LIB_PREFIX)/uri
 
-LIBMBR_PREFIX = $(LIB_PREFIX)/mbr
-LIBGPT_PREFIX = $(LIB_PREFIX)/gpt
 LIBNETTL_PREFIX = $(LIB_PREFIX)/nettl
 
Index: pace/app/hdisk/Makefile
===================================================================
--- uspace/app/hdisk/Makefile	(revision cffa82aac31c77f5d26f954922753c58edfef5f7)
+++ 	(revision )
@@ -1,44 +1,0 @@
-#
-# Copyright (c) 2005 Martin Decky
-# Copyright (c) 2007 Jakub Jermar
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-USPACE_PREFIX = ../..
-LIBS = $(LIBMBR_PREFIX)/libmbr.a $(LIBGPT_PREFIX)/libgpt.a \
-	$(LIBBLOCK_PREFIX)/libblock.a $(LIBCLUI_PREFIX)/libclui.a \
-	$(LIBC_PREFIX)/libc.a
-EXTRA_CFLAGS = -I$(LIBMBR_PREFIX) -I$(LIBGPT_PREFIX) -I$(LIBBLOCK_PREFIX) -I$(LIBCLUI_PREFIX)
-BINARY = hdisk
-
-SOURCES = \
-	hdisk.c \
-	input.c \
-	func_none.c \
-	func_mbr.c \
-	func_gpt.c
-
-include $(USPACE_PREFIX)/Makefile.common
Index: pace/app/hdisk/common.h
===================================================================
--- uspace/app/hdisk/common.h	(revision cffa82aac31c77f5d26f954922753c58edfef5f7)
+++ 	(revision )
@@ -1,68 +1,0 @@
-/*
- * Copyright (c) 2012-2013 Dominik Taborsky
- * 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 hdisk
- * @{
- */
-/** @file
- */
-
-#ifndef __COMMON_H__
-#define __COMMON_H__
-
-#include <libmbr.h>
-#include <libgpt.h>
-
-typedef enum {
-	LYT_NONE,
-	LYT_MBR,
-	LYT_GPT,
-} layouts_t;
-
-typedef union {
-	mbr_label_t *mbr;
-	gpt_label_t *gpt;
-} label_data_t;
-
-typedef struct label {
-	layouts_t layout;
-	aoff64_t blocks;
-	service_id_t device;
-	label_data_t data;
-	unsigned int alignment;
-	int (* destroy_label)(struct label *);
-	int (* add_part)(struct label *, tinput_t *);
-	int (* delete_part)(struct label *, tinput_t *);
-	int (* new_label)(struct label *);
-	int (* print_parts)(struct label *);
-	int (* read_parts)(struct label *);
-	int (* write_parts)(struct label *);
-	int (* extra_funcs)(struct label *, tinput_t *);
-} label_t;
-
-#endif
Index: pace/app/hdisk/func_gpt.c
===================================================================
--- uspace/app/hdisk/func_gpt.c	(revision cffa82aac31c77f5d26f954922753c58edfef5f7)
+++ 	(revision )
@@ -1,221 +1,0 @@
-/*
- * Copyright (c) 2012-2013 Dominik Taborsky
- * 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 hdisk
- * @{
- */
-/** @file
- */
-
-#include <stdio.h>
-#include <str.h>
-#include <errno.h>
-#include <str_error.h>
-#include <sys/types.h>
-#include <sys/typefmt.h>
-#include "func_gpt.h"
-#include "input.h"
-
-static void print_part_types(void);
-static int set_gpt_partition(tinput_t *, gpt_part_t *, label_t *);
-
-int construct_gpt_label(label_t *this)
-{
-	this->layout = LYT_GPT;
-	this->alignment = 1;
-	
-	this->add_part = add_gpt_part;
-	this->delete_part = delete_gpt_part;
-	this->destroy_label = destroy_gpt_label;
-	this->new_label = new_gpt_label;
-	this->print_parts = print_gpt_parts;
-	this->read_parts = read_gpt_parts;
-	this->write_parts = write_gpt_parts;
-	this->extra_funcs = extra_gpt_funcs;
-	
-	return this->new_label(this);
-}
-
-int add_gpt_part(label_t *this, tinput_t *in)
-{
-	gpt_part_t *partition = gpt_get_partition(this->data.gpt);
-	if (partition == NULL)
-		return ENOMEM;
-	
-	return set_gpt_partition(in, partition, this);
-}
-
-int delete_gpt_part(label_t *this, tinput_t *in)
-{
-	printf("Index of the partition to delete (counted from 0): ");
-	size_t idx = get_input_size_t(in);
-	
-	int rc = gpt_remove_partition(this->data.gpt, idx);
-	if (rc == ENOMEM) {
-		printf("Warning: Running out on memory, not resizing.\n");
-		return rc;
-	} else if (rc == EINVAL) {
-		printf("Invalid index.\n");
-		return rc;
-	}
-	
-	return EOK;
-}
-
-int destroy_gpt_label(label_t *this)
-{
-	gpt_free_label(this->data.gpt);
-	return EOK;
-}
-
-int new_gpt_label(label_t *this)
-{
-	this->data.gpt = gpt_alloc_label();
-	return EOK;
-}
-
-int print_gpt_parts(label_t *this)
-{
-	printf("Current partition scheme: GPT\n");
-	printf("Number of blocks: %" PRIu64 "\n", this->blocks);
-	
-	size_t i = 0;
-	gpt_part_foreach (this->data.gpt, iter) {
-		if (gpt_get_part_type(iter) == GPT_PTE_UNUSED)
-			continue;
-		
-		if (i % 20 == 0)
-			printf("%15s %10s %10s Type: Name:\n",
-			    "Start:", "End:", "Length:");
-		
-		printf("%3zu  %10" PRIu64 " %10" PRIu64 " %10" PRIu64 "    %3zu %s\n",
-		   i, gpt_get_start_lba(iter), gpt_get_end_lba(iter),
-		   gpt_get_end_lba(iter) - gpt_get_start_lba(iter), 
-		   gpt_get_part_type(iter), gpt_get_part_name(iter));
-		
-		i++;
-	}
-	
-	return EOK;
-}
-
-int read_gpt_parts(label_t *this)
-{
-	int rc = gpt_read_header(this->data.gpt, this->device);
-	if (rc != EOK) {
-		printf("Error: Reading header failed: %d (%s)\n", rc,
-		    str_error(rc));
-		return rc;
-	}
-	
-	rc = gpt_read_partitions(this->data.gpt);
-	if (rc != EOK) {
-		printf("Error: Reading partitions failed: %d (%s)\n", rc,
-		    str_error(rc));
-		return rc;
-	}
-	
-	return EOK;
-}
-
-int write_gpt_parts(label_t *this)
-{
-	int rc = gpt_write_partitions(this->data.gpt, this->device);
-	if (rc != EOK) {
-		printf("Error: Writing partitions failed: %d (%s)\n", rc,
-		    str_error(rc));
-		return rc;
-	}
-	
-	return EOK;
-}
-
-int extra_gpt_funcs(label_t *this, tinput_t *in)
-{
-	printf("Not implemented.\n");
-	return EOK;
-}
-
-static int set_gpt_partition(tinput_t *in, gpt_part_t *partition, label_t *this)
-{
-	printf("Set starting address: ");
-	uint64_t sa = get_input_uint64(in);
-	if ((this->alignment != 0) && (this->alignment != 1) &&
-	    (sa % this->alignment != 0))
-		sa = gpt_get_next_aligned(sa, this->alignment);
-	
-	printf("Set end address (max: %" PRIu64 "): ", this->blocks);
-	uint64_t ea = get_input_uint64(in);
-	
-	if (ea <= sa) {
-		printf("Invalid value.\n");
-		return EINVAL;
-	}
-	
-	gpt_set_start_lba(partition, sa);
-	gpt_set_end_lba(partition, ea);
-	
-	printf("Choose type: ");
-	print_part_types();
-	printf("Set type (1 for HelenOS System): ");
-	size_t idx = get_input_size_t(in);
-	gpt_set_part_type(partition, idx);
-	
-	gpt_set_random_uuid(partition->part_id);
-	
-	printf("Name the partition: ");
-	char *name;
-	int rc = get_input_line(in, &name);
-	if (rc != EOK) {
-		printf("Error reading name: %d (%s)\n", rc, str_error(rc));
-		return rc;
-	}
-	
-	gpt_set_part_name(partition, name, str_size(name));
-	
-	return EOK;
-}
-
-static void print_part_types(void)
-{
-	unsigned int count = 0;
-	const partition_type_t *ptype = gpt_ptypes;
-	
-	do {
-		printf("%u: %s\n", count, ptype->desc);
-		count++;
-		ptype++;
-		
-		if (count % 10 == 0) {
-			printf("Print (more) partition types? (y/n)\n");
-			int c = getchar();
-			if (c == 'n')
-				return;
-		}
-	} while (ptype->guid != NULL);
-}
Index: pace/app/hdisk/func_gpt.h
===================================================================
--- uspace/app/hdisk/func_gpt.h	(revision cffa82aac31c77f5d26f954922753c58edfef5f7)
+++ 	(revision )
@@ -1,53 +1,0 @@
-/*
- * Copyright (c) 2012-2013 Dominik Taborsky
- * 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 hdisk
- * @{
- */
-/** @file
- */
-
-#ifndef __FUNC_GPT_H__
-#define __FUNC_GPT_H__
-
-#include <loc.h>
-#include <tinput.h>
-#include <libgpt.h>
-#include "common.h"
-
-extern int construct_gpt_label(label_t *);
-extern int add_gpt_part(label_t *, tinput_t *);
-extern int delete_gpt_part(label_t *, tinput_t *);
-extern int destroy_gpt_label(label_t *);
-extern int new_gpt_label(label_t *);
-extern int print_gpt_parts(label_t *);
-extern int read_gpt_parts(label_t *);
-extern int write_gpt_parts(label_t *);
-extern int extra_gpt_funcs(label_t *, tinput_t *);
-
-#endif
Index: pace/app/hdisk/func_mbr.c
===================================================================
--- uspace/app/hdisk/func_mbr.c	(revision cffa82aac31c77f5d26f954922753c58edfef5f7)
+++ 	(revision )
@@ -1,232 +1,0 @@
-/*
- * Copyright (c) 2012-2013 Dominik Taborsky
- * 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 hdisk
- * @{
- */
-/** @file
- */
-
-#include <stdio.h>
-#include <errno.h>
-#include <str_error.h>
-#include <sys/types.h>
-#include "func_mbr.h"
-#include "input.h"
-
-static int set_mbr_partition(tinput_t *, mbr_part_t *, label_t *);
-
-int construct_mbr_label(label_t *this)
-{
-	this->layout = LYT_MBR;
-	this->alignment = 1;
-	
-	this->add_part      = add_mbr_part;
-	this->delete_part   = delete_mbr_part;
-	this->destroy_label = destroy_mbr_label;
-	this->new_label     = new_mbr_label;
-	this->print_parts   = print_mbr_parts;
-	this->read_parts    = read_mbr_parts;
-	this->write_parts   = write_mbr_parts;
-	this->extra_funcs   = extra_mbr_funcs;
-	
-	return this->new_label(this);
-}
-
-int add_mbr_part(label_t *this, tinput_t *in)
-{
-	mbr_part_t *partition = mbr_alloc_partition();
-	if (partition == NULL)
-		return ENOMEM;
-	
-	int rc = set_mbr_partition(in, partition, this);
-	if (rc != EOK)
-		return rc;
-	
-	rc = mbr_add_partition(this->data.mbr, partition);
-	if (rc != ERR_OK)
-		printf("Error adding partition: %d\n", rc);
-	
-	return EOK;
-}
-
-int delete_mbr_part(label_t *this, tinput_t *in)
-{
-	printf("Index of the partition to delete (counted from 0): ");
-	size_t idx = get_input_size_t(in);
-	
-	if ((idx == 0) && (errno != EOK))
-		return errno;
-	
-	int rc = mbr_remove_partition(this->data.mbr, idx);
-	if (rc != EOK)
-		printf("Error: partition does not exist?\n");
-	
-	return EOK;
-}
-
-int destroy_mbr_label(label_t *this)
-{
-	mbr_free_label(this->data.mbr);
-	return EOK;
-}
-
-int new_mbr_label(label_t *this)
-{
-	this->data.mbr = mbr_alloc_label();
-	if (this->data.mbr == NULL)
-		return ENOMEM;
-	
-	mbr_set_device(this->data.mbr, this->device);
-	return EOK;
-}
-
-int print_mbr_parts(label_t *this)
-{
-	printf("Current partition scheme: MBR\n");
-	printf("Number of blocks: %" PRIu64 "\n", this->blocks);
-	printf("\t\t%10s  %10s %10s %10s %7s\n",
-	    "Bootable:", "Start:", "End:", "Length:", "Type:");
-	
-	unsigned int num = 0;
-	mbr_part_t *it;
-	for (it = mbr_get_first_partition(this->data.mbr); it != NULL;
-	     it = mbr_get_next_partition(this->data.mbr, it)) {
-		if (it->type == PT_UNUSED)
-			continue;
-		
-		printf("\tP%u:\t", num);
-		if (mbr_get_flag(it, ST_BOOT))
-			printf("*");
-		else
-			printf(" ");
-		
-		printf("\t%10u %10u %10u %7u\n", it->start_addr,
-		    it->start_addr + it->length, it->length, it->type);
-		
-		num++;
-	}
-	
-	printf("%u partitions found.\n", num);
-	
-	return EOK;
-}
-
-int read_mbr_parts(label_t *this)
-{
-	int rc = mbr_read_mbr(this->data.mbr, this->device);
-	if (rc != EOK)
-		return rc;
-	
-	if (!mbr_is_mbr(this->data.mbr))
-		return EINVAL;
-	
-	rc = mbr_read_partitions(this->data.mbr);
-	if (rc != EOK)
-		return rc;
-	
-	return EOK;
-}
-
-int write_mbr_parts(label_t *this)
-{
-	int rc = mbr_write_partitions(this->data.mbr, this->device);
-	if (rc != EOK)
-		printf("Error occured during writing: ERR: %d: %s\n", rc,
-		    str_error(rc));
-	
-	return rc;
-}
-
-int extra_mbr_funcs(label_t *this, tinput_t *in)
-{
-	printf("Not implemented.\n");
-	return EOK;
-}
-
-static int set_mbr_partition(tinput_t *in, mbr_part_t *partition, label_t *this)
-{
-	printf("Primary (p) or logical (l): ");
-	int c = getchar();
-	printf("%c\n", c);
-
-	switch (c) {
-	case 'p':
-		mbr_set_flag(partition, ST_LOGIC, false);
-		break;
-	case 'l':
-		mbr_set_flag(partition, ST_LOGIC, true);
-		break;
-	default:
-		printf("Invalid type. Cancelled.\n");
-		return EINVAL;
-	}
-	
-	printf("Set type (0 - 255): ");
-	uint8_t type = get_input_uint8(in);
-	if ((type == 0) && (errno != EOK))
-		return errno;
-	
-	// FIXME: Make sure there is at most one bootable partition
-	printf("Bootable? (y/n): ");
-	c = getchar();
-	if ((c != 'y') && (c != 'Y') && (c != 'n') && (c != 'N')) {
-		printf("Invalid value. Cancelled.");
-		return EINVAL;
-	}
-	
-	printf("%c\n", c);
-	mbr_set_flag(partition, ST_BOOT, (c == 'y' || c == 'Y') ? true : false);
-	
-	printf("Set starting address: ");
-	uint32_t sa = get_input_uint32(in);
-	if ((sa == 0) && (errno != EOK))
-		return errno;
-	
-	if ((this->alignment != 0) && (this->alignment != 1) &&
-	    (sa % this->alignment != 0)) {
-		sa = mbr_get_next_aligned(sa, this->alignment);
-		printf("Starting address was aligned to %" PRIu32 ".\n", sa);
-	}
-	
-	printf("Set end addres (max: %" PRIu64 "): ", this->blocks);
-	uint32_t ea = get_input_uint32(in);
-	if ((ea == 0) && (errno != EOK))
-		return errno;
-	
-	if (ea < sa) {
-		printf("Invalid value. Canceled.\n");
-		return EINVAL;
-	}
-	
-	partition->type = type;
-	partition->start_addr = sa;
-	partition->length = ea - sa;
-	
-	return EOK;
-}
Index: pace/app/hdisk/func_mbr.h
===================================================================
--- uspace/app/hdisk/func_mbr.h	(revision cffa82aac31c77f5d26f954922753c58edfef5f7)
+++ 	(revision )
@@ -1,53 +1,0 @@
-/*
- * Copyright (c) 2012-2013 Dominik Taborsky
- * 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 hdisk
- * @{
- */
-/** @file
- */
-
-#ifndef __FUNC_MBR_H__
-#define __FUNC_MBR_H__
-
-#include <loc.h>
-#include <tinput.h>
-#include <libmbr.h>
-#include "common.h"
-
-extern int construct_mbr_label(label_t *);
-extern int add_mbr_part(label_t *, tinput_t *);
-extern int delete_mbr_part(label_t *, tinput_t *);
-extern int destroy_mbr_label(label_t *);
-extern int new_mbr_label(label_t *);
-extern int print_mbr_parts(label_t *);
-extern int read_mbr_parts(label_t *);
-extern int write_mbr_parts(label_t *);
-extern int extra_mbr_funcs(label_t *, tinput_t *);
-
-#endif
Index: pace/app/hdisk/func_none.c
===================================================================
--- uspace/app/hdisk/func_none.c	(revision cffa82aac31c77f5d26f954922753c58edfef5f7)
+++ 	(revision )
@@ -1,106 +1,0 @@
-/*
- * Copyright (c) 2012-2013 Dominik Taborsky
- * 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 hdisk
- * @{
- */
-/** @file
- */
-
-#include <errno.h>
-#include "func_none.h"
-
-static void not_implemented(void);
-
-int construct_none_label(label_t *this)
-{
-	this->layout = LYT_NONE;
-	
-	this->add_part = add_none_part;
-	this->delete_part = delete_none_part;
-	this->destroy_label = destroy_none_label;
-	this->new_label = new_none_label;
-	this->print_parts = print_none_parts;
-	this->read_parts = read_none_parts;
-	this->write_parts = write_none_parts;
-	this->extra_funcs = extra_none_funcs;
-	
-	return EOK;
-}
-
-int add_none_part(label_t *this, tinput_t *in)
-{
-	not_implemented();
-	return EOK;
-}
-
-int delete_none_part(label_t *this, tinput_t *in)
-{
-	not_implemented();
-	return EOK;
-}
-
-int destroy_none_label(label_t *this)
-{
-	return EOK;
-}
-
-int new_none_label(label_t *this)
-{
-	not_implemented();
-	return EOK;
-}
-
-int print_none_parts(label_t *this)
-{
-	not_implemented();
-	return EOK;
-}
-
-int read_none_parts(label_t *this)
-{
-	not_implemented();
-	return EOK;
-}
-
-int write_none_parts(label_t *this)
-{
-	not_implemented();
-	return EOK;
-}
-
-int extra_none_funcs(label_t *this, tinput_t * in)
-{
-	not_implemented();
-	return EOK;
-}
-
-static void not_implemented(void)
-{
-	printf("No format selected.\n");
-}
Index: pace/app/hdisk/func_none.h
===================================================================
--- uspace/app/hdisk/func_none.h	(revision cffa82aac31c77f5d26f954922753c58edfef5f7)
+++ 	(revision )
@@ -1,52 +1,0 @@
-/*
- * Copyright (c) 2012-2013 Dominik Taborsky
- * 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 hdisk
- * @{
- */
-/** @file
- */
-
-#ifndef __FUNC_NONE_H__
-#define __FUNC_NONE_H__
-
-#include <loc.h>
-#include <tinput.h>
-#include "common.h"
-
-extern int construct_none_label(label_t *);
-extern int add_none_part(label_t *, tinput_t *);
-extern int delete_none_part(label_t *, tinput_t *);
-extern int destroy_none_label(label_t *);
-extern int new_none_label(label_t *);
-extern int print_none_parts(label_t *);
-extern int read_none_parts(label_t *);
-extern int write_none_parts(label_t *);
-extern int extra_none_funcs(label_t *, tinput_t *);
-
-#endif
Index: pace/app/hdisk/hdisk.c
===================================================================
--- uspace/app/hdisk/hdisk.c	(revision cffa82aac31c77f5d26f954922753c58edfef5f7)
+++ 	(revision )
@@ -1,264 +1,0 @@
-/*
- * Copyright (c) 2012-2013 Dominik Taborsky
- * 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 hdisk
- * @{
- */
-/** @file
- */
-
-#include <ipc/bd.h>
-#include <loc.h>
-#include <async.h>
-#include <stdio.h>
-#include <ipc/services.h>
-#include <block.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <str.h>
-#include <libmbr.h>
-#include <libgpt.h>
-#include <tinput.h>
-#include <str_error.h>
-#include "hdisk.h"
-#include "input.h"
-#include "func_gpt.h"
-#include "func_mbr.h"
-#include "func_none.h"
-
-static int interact(void);
-static void print_help(void);
-static void select_label_format(tinput_t *);
-static void construct_label(layouts_t);
-static void free_label(void);
-static int try_read(void);
-static int try_read_mbr(void);
-static int try_read_gpt(void);
-static void set_alignment(tinput_t *);
-
-static label_t label;
-
-int main(int argc, char *argv[])
-{
-	if (argc == 1) {
-		printf("Missing argument. Please specify a device to operate on.\n");
-		return 1;
-	}
-	
-	service_id_t dev_handle;
-	int rc = loc_service_get_id(argv[1], &dev_handle, IPC_FLAG_BLOCKING);
-	if (rc != EOK) {
-		printf("Unknown device. Exiting.\n");
-		return 2;
-	}
-	
-	init_label();
-	label.device = dev_handle;
-	
-	rc = block_init(dev_handle, 512);
-	if (rc != EOK) {
-		printf("Error during libblock init: %d - %s.\n", rc, str_error(rc));
-		return 3;
-	}
-	
-	aoff64_t blocks;
-	rc = block_get_nblocks(dev_handle, &blocks);
-	block_fini(dev_handle);
-	if (rc != EOK) {
-		printf("Error while getting number of blocks: %d - %s.\n",
-		    rc, str_error(rc));
-		return 4;
-	}
-	
-	label.blocks = blocks;
-	
-	rc = try_read_mbr();
-	if (rc == EOK)
-		goto interact;
-	
-	free_label();
-	
-	rc = try_read_gpt();
-	if (rc == EOK)
-		goto interact;
-	
-	printf("No label recognized. Create a new one.\n");
-	construct_label(LYT_NONE);
-	
-interact:
-	return interact();
-}
-
-/** Interact with user */
-int interact(void)
-{
-	tinput_t *in = tinput_new();
-	if (in == NULL) {
-		printf("Failed initing input. Free some memory.\n");
-		return ENOMEM;
-	}
-	tinput_set_prompt(in, "");
-	
-	printf("Welcome to hdisk.\nType 'h' for help.\n");
-	
-	while (true) {
-		printf("# ");
-		int input = getchar();
-		printf("%c\n", input);
-		
-		switch (input) {
-		case 'a':
-			label.add_part(&label, in);
-			break;
-		case 'd':
-			label.delete_part(&label, in);
-			break;
-		case 'e':
-			label.extra_funcs(&label, in);
-			break;
-		case 'f':
-			free_label();
-			select_label_format(in);
-			break;
-		case 'h':
-			print_help();
-			break;
-		case 'l':
-			set_alignment(in);
-			break;
-		case 'n':
-			printf("Discarding label...\n");
-			free_label();
-			label.new_label(&label);
-			break;
-		case 'p':
-			label.print_parts(&label);
-			break;
-		case 'q':
-			putchar('\n');
-			free_label();
-			goto end;
-		case 'r':
-			label.read_parts(&label);
-		case 'w':
-			label.write_parts(&label);
-			break;
-		default:
-			printf("Unknown command. Try 'h' for help.\n");
-			break;
-		}
-	}
-	
-end:
-	tinput_destroy(in);
-	return EOK;
-}
-
-void print_help(void)
-{
-	printf(
-	    "\t 'a' \t\t Add partition.\n"
-	    "\t 'd' \t\t Delete partition.\n"
-	    "\t 'e' \t\t Extra functions (per label format).\n"
-	    "\t 'f' \t\t Switch the format of the partition label.\n"
-	    "\t 'h' \t\t Prints help. See help for more.\n"
-	    "\t 'l' \t\t Set alignment.\n"
-	    "\t 'n' \t\t Create new label (discarding the old one).\n"
-	    "\t 'p' \t\t Prints label contents.\n"
-	    "\t 'q' \t\t Quit.\n"
-	    "\t 'r' \t\t Read label from disk.\n"
-	    "\t 'w' \t\t Write label to disk.\n");
-}
-
-void select_label_format(tinput_t *in)
-{
-	printf("Available formats are: \n"
-	    "1) MBR\n"
-	    "2) GPT\n");
-	
-	uint8_t val = get_input_uint8(in);
-	switch (val) {
-	case 1:
-		construct_label(LYT_MBR);
-		break;
-	case 2:
-		construct_label(LYT_GPT);
-		break;
-	default:
-		construct_label(LYT_NONE);
-		break;
-	}
-}
-
-void construct_label(layouts_t layout)
-{
-	switch (layout) {
-	case LYT_MBR:
-		label.layout = LYT_MBR;
-		construct_mbr_label(&label);
-		break;
-	case LYT_GPT:
-		label.layout = LYT_GPT;
-		construct_gpt_label(&label);
-		break;
-	default:
-		label.layout = LYT_NONE;
-		construct_none_label(&label);
-		break;
-	}
-}
-
-void free_label(void)
-{
-	label.destroy_label(&label);
-}
-
-int try_read(void)
-{
-	return label.read_parts(&label);
-}
-
-int try_read_mbr(void)
-{
-	construct_label(LYT_MBR);
-	return try_read();
-}
-
-int try_read_gpt(void)
-{
-	construct_label(LYT_GPT);
-	return try_read();
-}
-
-void set_alignment(tinput_t *in)
-{
-	printf("Set alignment to sectors: ");
-	label.alignment = get_input_uint32(in);
-	printf("Alignment set to %u sectors.\n", label.alignment);
-}
Index: pace/app/hdisk/hdisk.h
===================================================================
--- uspace/app/hdisk/hdisk.h	(revision cffa82aac31c77f5d26f954922753c58edfef5f7)
+++ 	(revision )
@@ -1,43 +1,0 @@
-/*
- * Copyright (c) 2012-2013 Dominik Taborsky
- * 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 hdisk
- * @{
- */
-/** @file
- */
-
-#ifndef __HDISK_H__
-#define __HDISK_H__
-
-#include "common.h"
-
-#define init_label() \
-	label.layout = LYT_NONE
-
-#endif
Index: pace/app/hdisk/input.c
===================================================================
--- uspace/app/hdisk/input.c	(revision cffa82aac31c77f5d26f954922753c58edfef5f7)
+++ 	(revision )
@@ -1,130 +1,0 @@
-/*
- * Copyright (c) 2012-2013 Dominik Taborsky
- * 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 hdisk
- * @{
- */
-/** @file
- */
-
-#include <str.h>
-#include <errno.h>
-#include <stdlib.h>
-#include "input.h"
-
-typedef int (*conv_f)(const char *, char **, unsigned int, bool, void *);
-
-static int convert(tinput_t *, conv_f, void *);
-
-int get_input_line(tinput_t *in, char **str)
-{
-	int rc = tinput_read(in, str);
-	if (rc == ENOENT)
-		return EINTR;
-	
-	if (rc != EOK)
-		return rc;
-	
-	/* Check for empty input. */
-	if (str_cmp(*str, "") == 0) {
-		free(*str);
-		*str = NULL;
-		return EINVAL;
-	}
-	
-	return EOK;
-}
-
-uint8_t get_input_uint8(tinput_t *in)
-{
-	uint32_t val;
-	int rc = convert(in, (conv_f) str_uint8_t, &val);
-	if (rc != EOK) {
-		errno = rc;
-		return 0;
-	}
-	
-	errno = EOK;
-	return val;
-}
-
-uint32_t get_input_uint32(tinput_t *in)
-{
-	uint32_t val;
-	int rc = convert(in, (conv_f) str_uint32_t, &val);
-	if (rc != EOK) {
-		errno = rc;
-		return 0;
-	}
-	
-	errno = EOK;
-	return val;
-}
-
-uint64_t get_input_uint64(tinput_t *in)
-{
-	uint64_t val;
-	int rc = convert(in, (conv_f) str_uint64_t, &val);
-	if (rc != EOK) {
-		errno = rc;
-		return 0;
-	}
-	
-	errno = EOK;
-	return val;
-}
-
-size_t get_input_size_t(tinput_t *in)
-{
-	size_t val;
-	int rc = convert(in, (conv_f) str_size_t, &val);
-	if (rc != EOK) {
-		errno = rc;
-		return 0;
-	}
-	
-	errno = EOK;
-	return val;
-}
-
-static int convert(tinput_t *in, conv_f str_f, void *val)
-{
-	char *str;
-	int rc = get_input_line(in, &str);
-	if (rc != EOK) {
-		printf("Error reading input.\n");
-		return rc;
-	}
-	
-	rc = str_f(str, NULL, 10, true, val);
-	if (rc != EOK)
-		printf("Invalid value.\n");
-	
-	free(str);
-	return rc;
-}
Index: pace/app/hdisk/input.h
===================================================================
--- uspace/app/hdisk/input.h	(revision cffa82aac31c77f5d26f954922753c58edfef5f7)
+++ 	(revision )
@@ -1,46 +1,0 @@
-/*
- * Copyright (c) 2012-2013 Dominik Taborsky
- * 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 hdisk
- * @{
- */
-/** @file
- */
-
-#ifndef __INPUT_H__
-#define __INPUT_H__
-
-#include <tinput.h>
-
-extern int get_input_line(tinput_t *, char **);
-extern uint8_t get_input_uint8(tinput_t *);
-extern uint32_t get_input_uint32(tinput_t *);
-extern uint64_t get_input_uint64(tinput_t *);
-extern size_t get_input_size_t(tinput_t *);
-
-#endif
Index: pace/lib/gpt/Makefile
===================================================================
--- uspace/lib/gpt/Makefile	(revision cffa82aac31c77f5d26f954922753c58edfef5f7)
+++ 	(revision )
@@ -1,37 +1,0 @@
-#
-# Copyright (c) 2011 Dominik Taborsky
-# 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 = ../..
-EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX) -I$(LIBMBR_PREFIX)
-LIBRARY = libgpt
-
-SOURCES = \
-	libgpt.c \
-	global.c
-
-include $(USPACE_PREFIX)/Makefile.common
Index: pace/lib/gpt/global.c
===================================================================
--- uspace/lib/gpt/global.c	(revision cffa82aac31c77f5d26f954922753c58edfef5f7)
+++ 	(revision )
@@ -1,111 +1,0 @@
-/*
- * Copyright (c) 2011-2013 Dominik Taborsky
- * 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 libgpt
- * @{
- */
-/** @file
- */
-
-#include "libgpt.h"
-
-/** GPT header signature ("EFI PART" in ASCII) */
-const uint8_t efi_signature[8] = {
-	0x45, 0x46, 0x49, 0x20, 0x50, 0x41, 0x52, 0x54
-};
-
-const uint8_t revision[4] = {
-	00, 00, 01, 00
-};
-
-const partition_type_t gpt_ptypes[] = {
-	{ "unused entry",                 "00000000" "0000" "0000" "0000000000000000" }, /* 0 */
-	{ "HelenOS System",               "3dc61fa0" "cf7a" "3ad8" "ac57615029d81a6b" }, /* "HelenOS System" encoded as RFC 4122 UUID, version 3 (MD5 name-based) */
-	{ "MBR partition scheme",         "024dee41" "33e7" "11d3" "9d690008c781f39f" },
-	{ "EFI System",                   "c12a7328" "f81f" "11d2" "ba4b00a0c93ec93b" },
-	{ "BIOS Boot",                    "21686148" "6449" "6e6f" "744e656564454649" },
-	{ "Windows Reserved",             "e3c9e316" "0b5c" "4db8" "817df92df00215ae" },
-	{ "Windows Basic data",           "ebd0a0a2" "b9e5" "4433" "87c068b6b72699c7" },
-	{ "Windows LDM metadata",         "5808c8aa" "7e8f" "42e0" "85d2e1e90434cfb3" },
-	{ "Windows LDM data",             "af9b60a0" "1431" "4f62" "bc683311714a69ad" },
-	{ "Windows Recovery Environment", "de94bba4" "06d1" "4d40" "a16abfd50179d6ac" },
-	{ "Windows IBM GPFS",             "37affc90" "ef7d" "4e96" "91c32d7ae055b174" }, /* 10 */
-	{ "Windows Cluster metadata",     "db97dba9" "0840" "4bae" "97f0ffb9a327c7e1" },
-	{ "HP-UX Data",                   "75894c1e" "3aeb" "11d3" "b7c17b03a0000000" },
-	{ "HP-UX Service",                "e2a1e728" "32e3" "11d6" "a6827b03a0000000" },
-	{ "Linux filesystem data",        "0fc63daf" "8483" "4772" "8e793d69d8477de4" },
-	{ "Linux RAID",                   "a19d880f" "05fc" "4d3b" "a006743f0f84911e" },
-	{ "Linux Swap",                   "0657fd6d" "a4ab" "43c4" "84e50933c84b4f4f" },
-	{ "Linux LVM",                    "e6d6d379" "f507" "44c2" "a23c238f2a3df928" },
-	{ "Linux filesystem data",        "933ac7e1" "2eb4" "4f13" "b8440e14e2aef915" },
-	{ "Linux Reserved",               "8da63339" "0007" "60c0" "c436083ac8230908" },
-	{ "FreeBSD Boot",                 "83bd6b9d" "7f41" "11dc" "be0b001560b84f0f" }, /* 20 */
-	{ "FreeBSD Data",                 "516e7cb4" "6ecf" "11d6" "8ff800022d09712b" },
-	{ "FreeBSD Swap",                 "516e7cb5" "6ecf" "11d6" "8ff800022d09712b" },
-	{ "FreeBSD UFS",                  "516e7cb6" "6ecf" "11d6" "8ff800022d09712b" },
-	{ "FreeBSD Vinum VM",             "516e7cb8" "6ecf" "11d6" "8ff800022d09712b" },
-	{ "FreeBSD ZFS",                  "516e7cba" "6ecf" "11d6" "8ff800022d09712b" },
-	{ "Mac OS X HFS+",                "48465300" "0000" "11aa" "aa1100306543ecac" },
-	{ "Mac OS X UFS",                 "55465300" "0000" "11aa" "aa1100306543ecac" },
-	{ "Mac OS X ZFS",                 "6a898cc3" "1dd2" "11b2" "99a6080020736631" },
-	{ "Mac OS X RAID",                "52414944" "0000" "11aa" "aa1100306543ecac" },
-	{ "Mac OS X RAID, offline",       "52414944" "5f4f" "11aa" "aa1100306543ecac" }, /* 30 */
-	{ "Mac OS X Boot",                "426f6f74" "0000" "11aa" "aa1100306543ecac" },
-	{ "Mac OS X Label",               "4c616265" "6c00" "11aa" "aa1100306543ecac" },
-	{ "Mac OS X TV Recovery",         "5265636f" "7665" "11aa" "aa1100306543ecac" },
-	{ "Mac OS X Core Storage",        "53746f72" "6167" "11aa" "aa1100306543ecac" },
-	{ "Solaris Boot",                 "6a82cb45" "1dd2" "11b2" "99a6080020736631" },
-	{ "Solaris Root",                 "6a85cf4d" "1dd2" "11b2" "99a6080020736631" },
-	{ "Solaris Swap",                 "6a87c46f" "1dd2" "11b2" "99a6080020736631" },
-	{ "Solaris Backup",               "6a8b642b" "1dd2" "11b2" "99a6080020736631" },
-	{ "Solaris /usr",                 "6a898cc3" "1dd2" "11b2" "99a6080020736631" },
-	{ "Solaris /var",                 "6a8ef2e9" "1dd2" "11b2" "99a6080020736631" }, /* 40 */
-	{ "Solaris /home",                "6a90ba39" "1dd2" "11b2" "99a6080020736631" },
-	{ "Solaris Alternate sector",     "6a9283a5" "1dd2" "11b2" "99a6080020736631" },
-	{ "Solaris Reserved",             "6a945a3b" "1dd2" "11b2" "99a6080020736631" },
-	{ "Solaris Reserved",             "6a9630d1" "1dd2" "11b2" "99a6080020736631" },
-	{ "Solaris Reserved",             "6a980767" "1dd2" "11b2" "99a6080020736631" },
-	{ "Solaris Reserved",             "6a96237f" "1dd2" "11b2" "99a6080020736631" },
-	{ "Solaris Reserved",             "6a8d2ac7" "1dd2" "11b2" "99a6080020736631" },
-	{ "NetBSD Swap",                  "49f48d32" "b10e" "11dc" "b99b0019d1879648" },
-	{ "NetBSD FFS",                   "49f48d5a" "b10e" "11dc" "b99b0019d1879648" },
-	{ "NetBSD LFS",                   "49f48d82" "b10e" "11dc" "b99b0019d1879648" }, /* 50 */
-	{ "NetBSD RAID",                  "49f48daa" "b10e" "11dc" "b99b0019d1879648" },
-	{ "NetBSD Concatenated",          "2db519c4" "b10f" "11dc" "b99b0019d1879648" },
-	{ "NetBSD Encrypted",             "2db519ec" "b10f" "11dc" "b99b0019d1879648" },
-	{ "ChromeOS ChromeOS kernel",     "fe3a2a5d" "4f32" "41a7" "b725accc3285a309" },
-	{ "ChromeOS rootfs",              "3cb8e202" "3b7e" "47dd" "8a3c7ff2a13cfcec" },
-	{ "ChromeOS future use",          "2e0a753d" "9e48" "43b0" "8337b15192cb1b5e" },
-	{ "MidnightBSD Boot",             "85d5e45e" "237c" "11e1" "b4b3e89a8f7fc3a7" },
-	{ "MidnightBSD Data",             "85d5e45a" "237c" "11e1" "b4b3e89a8f7fc3a7" },
-	{ "MidnightBSD Swap",             "85d5e45b" "237c" "11e1" "b4b3e89a8f7fc3a7" },
-	{ "MidnightBSD UFS",              "0394ef8b" "237e" "11e1" "b4b3e89a8f7fc3a7" }, /* 60 */
-	{ "MidnightBSD Vinum VM",         "85d5e45c" "237c" "11e1" "b4b3e89a8f7fc3a7" },
-	{ "MidnightBSD ZFS",              "85d5e45d" "237c" "11e1" "b4b3e89a8f7fc3a7" },
-	{ "unknown entry",                NULL } /* Keep this as the last entry */
-};
Index: pace/lib/gpt/gpt.h
===================================================================
--- uspace/lib/gpt/gpt.h	(revision cffa82aac31c77f5d26f954922753c58edfef5f7)
+++ 	(revision )
@@ -1,75 +1,0 @@
-/*
- * Copyright (c) 2009 Jiri Svoboda
- * Copyright (c) 2011-2013 Dominik Taborsky
- * 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 libgpt
- * @{
- */
-/** @file
- */
-
-#ifndef LIBGPT_GPT_H_
-#define LIBGPT_GPT_H_
-
-typedef enum {
-	AT_REQ_PART = 0,
-	AT_NO_BLOCK_IO,
-	AT_LEGACY_BOOT,
-	AT_UNDEFINED,
-	AT_SPECIFIC = 48
-} gpt_attr_t;
-
-/** GPT header */
-typedef struct {
-	uint8_t efi_signature[8];
-	uint8_t revision[4];
-	uint32_t header_size;
-	uint32_t header_crc32;
-	uint32_t reserved;
-	uint64_t current_lba;
-	uint64_t alternate_lba;
-	uint64_t first_usable_lba;
-	uint64_t last_usable_lba;
-	uint8_t disk_guid[16];
-	uint64_t entry_lba;
-	uint32_t fillries;
-	uint32_t entry_size;
-	uint32_t pe_array_crc32;
-} __attribute__((packed)) gpt_header_t;
-
-/** GPT partition entry */
-typedef struct {
-	uint8_t part_type[16];
-	uint8_t part_id[16];
-	uint64_t start_lba;
-	uint64_t end_lba;
-	uint64_t attributes;
-	uint8_t part_name[72];
-} __attribute__((packed)) gpt_entry_t;
-
-#endif
Index: pace/lib/gpt/libgpt.c
===================================================================
--- uspace/lib/gpt/libgpt.c	(revision cffa82aac31c77f5d26f954922753c58edfef5f7)
+++ 	(revision )
@@ -1,858 +1,0 @@
-/*
- * Copyright (c) 2011-2013 Dominik Taborsky
- * 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 libgpt
- * @{
- */
-/** @file
- */
-
-/* TODO:
- * The implementation currently supports fixed size partition entries only.
- * The specification requires otherwise, though.
- */
-
-#include <ipc/bd.h>
-#include <async.h>
-#include <stdio.h>
-#include <block.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <byteorder.h>
-#include <adt/checksum.h>
-#include <mem.h>
-#include <sys/typefmt.h>
-#include <mbr.h>
-#include <align.h>
-#include "libgpt.h"
-
-static int load_and_check_header(service_id_t, aoff64_t, size_t, gpt_header_t *);
-static gpt_partitions_t *alloc_part_array(uint32_t);
-static int extend_part_array(gpt_partitions_t *);
-static int reduce_part_array(gpt_partitions_t *);
-static uint8_t get_byte(const char *);
-static bool check_overlap(gpt_part_t *, gpt_part_t *);
-static bool check_encaps(gpt_part_t *, uint64_t, uint64_t);
-
-/** Allocate a GPT label */
-gpt_label_t *gpt_alloc_label(void)
-{
-	gpt_label_t *label = malloc(sizeof(gpt_label_t));
-	if (label == NULL)
-		return NULL;
-	
-	label->parts = gpt_alloc_partitions();
-	if (label->parts == NULL) {
-		free(label);
-		return NULL;
-	}
-	
-	label->gpt = NULL;
-	label->device = 0;
-	
-	return label;
-}
-
-/** Free a GPT label */
-void gpt_free_label(gpt_label_t *label)
-{
-	if (label->gpt != NULL)
-		gpt_free_gpt(label->gpt);
-	
-	if (label->parts != NULL)
-		gpt_free_partitions(label->parts);
-	
-	free(label);
-}
-
-/** Allocate a GPT header */
-gpt_t *gpt_alloc_header(size_t size)
-{
-	gpt_t *gpt = malloc(sizeof(gpt_t));
-	if (gpt == NULL)
-		return NULL;
-	
-	/*
-	 * We might need only sizeof(gpt_header_t), but we should follow
-	 * specs and have zeroes through all the rest of the block
-	 */
-	size_t final_size = max(size, sizeof(gpt_header_t));
-	gpt->header = malloc(final_size);
-	if (gpt->header == NULL) {
-		free(gpt);
-		return NULL;
-	}
-	
-	memset(gpt->header, 0, final_size);
-	memcpy(gpt->header->efi_signature, efi_signature, 8);
-	memcpy(gpt->header->revision, revision, 4);
-	gpt->header->header_size = host2uint32_t_le(final_size);
-	gpt->header->entry_lba = host2uint64_t_le((uint64_t) 2);
-	gpt->header->entry_size = host2uint32_t_le(sizeof(gpt_entry_t));
-	
-	return gpt;
-}
-
-/** Free a GPT header */
-void gpt_free_gpt(gpt_t *gpt)
-{
-	free(gpt->header);
-	free(gpt);
-}
-
-/** Read GPT from a device
- *
- * @param label      Label to read.
- * @param dev_handle Device to read GPT from.
- *
- * @return EOK on success, error code on error.
- *
- */
-int gpt_read_header(gpt_label_t *label, service_id_t dev_handle)
-{
-	int rc = block_init(dev_handle, 512);
-	if (rc != EOK)
-		return rc;
-	
-	size_t block_size;
-	rc = block_get_bsize(dev_handle, &block_size);
-	if (rc != EOK)
-		goto end;
-	
-	if (label->gpt == NULL) {
-		label->gpt = gpt_alloc_header(block_size);
-		if (label->gpt == NULL) {
-			rc = ENOMEM;
-			goto end;
-		}
-	}
-	
-	rc = load_and_check_header(dev_handle, GPT_HDR_BA, block_size,
-	    label->gpt->header);
-	if ((rc == EBADCHECKSUM) || (rc == EINVAL)) {
-		aoff64_t blocks;
-		rc = block_get_nblocks(dev_handle, &blocks);
-		if (rc != EOK) {
-			gpt_free_gpt(label->gpt);
-			goto end;
-		}
-		
-		rc = load_and_check_header(dev_handle, blocks - 1, block_size,
-		    label->gpt->header);
-		if ((rc == EBADCHECKSUM) || (rc == EINVAL)) {
-			gpt_free_gpt(label->gpt);
-			goto end;
-		}
-	}
-	
-	label->device = dev_handle;
-	rc = EOK;
-	
-end:
-	block_fini(dev_handle);
-	return rc;
-}
-
-/** Write GPT header to device
- *
- * @param label        Label to be written.
- * @param dev_handle   Device to write the GPT to.
- *
- * @return EOK on success, libblock error code otherwise.
- *
- */
-int gpt_write_header(gpt_label_t *label, service_id_t dev_handle)
-{
-	/* The comm_size argument (the last one) is ignored */
-	int rc = block_init(dev_handle, 4096);
-	if ((rc != EOK) && (rc != EEXIST))
-		return rc;
-	
-	size_t block_size;
-	rc = block_get_bsize(dev_handle, &block_size);
-	if (rc != EOK)
-		goto end;
-	
-	aoff64_t blocks;
-	rc = block_get_nblocks(dev_handle, &blocks);
-	if (rc != EOK)
-		goto end;
-	
-	gpt_set_random_uuid(label->gpt->header->disk_guid);
-	
-	/* Prepare the backup header */
-	label->gpt->header->alternate_lba = label->gpt->header->current_lba;
-	label->gpt->header->current_lba = host2uint64_t_le(blocks - 1);
-	
-	uint64_t lba = label->gpt->header->entry_lba;
-	label->gpt->header->entry_lba = host2uint64_t_le(blocks -
-	    (uint32_t_le2host(label->gpt->header->fillries) *
-	    sizeof(gpt_entry_t)) / block_size - 1);
-	
-	label->gpt->header->header_crc32 = 0;
-	label->gpt->header->header_crc32 =
-	    host2uint32_t_le(compute_crc32((uint8_t *) label->gpt->header,
-	    uint32_t_le2host(label->gpt->header->header_size)));
-	
-	/* Write to backup GPT header location */
-	rc = block_write_direct(dev_handle, blocks - 1, GPT_HDR_BS,
-	    label->gpt->header);
-	if (rc != EOK)
-		goto end;
-	
-	/* Prepare the main header */
-	label->gpt->header->entry_lba = lba;
-	
-	lba = label->gpt->header->alternate_lba;
-	label->gpt->header->alternate_lba = label->gpt->header->current_lba;
-	label->gpt->header->current_lba = lba;
-	
-	label->gpt->header->header_crc32 = 0;
-	label->gpt->header->header_crc32 =
-	    host2uint32_t_le(compute_crc32((uint8_t *) label->gpt->header,
-	    uint32_t_le2host(label->gpt->header->header_size)));
-	
-	/* Write to main GPT header location */
-	rc = block_write_direct(dev_handle, GPT_HDR_BA, GPT_HDR_BS,
-	    label->gpt->header);
-	if (rc != EOK)
-		goto end;
-	
-	/* Write Protective MBR */
-	br_block_t mbr;
-	memset(&mbr, 0, 512);
-	
-	memset(mbr.pte[0].first_chs, 1, 3);
-	mbr.pte[0].ptype = 0xEE;
-	memset(mbr.pte[0].last_chs, 0xff, 3);
-	mbr.pte[0].first_lba = host2uint32_t_le(1);
-	mbr.pte[0].length = 0xffffffff;
-	mbr.signature = host2uint16_t_le(BR_SIGNATURE);
-	
-	rc = block_write_direct(dev_handle, 0, 1, &mbr);
-	
-end:
-	block_fini(dev_handle);
-	return rc;
-}
-
-/** Alloc partition array */
-gpt_partitions_t *gpt_alloc_partitions(void)
-{
-	return alloc_part_array(GPT_MIN_PART_NUM);
-}
-
-/** Parse partitions from GPT
- *
- * @param label GPT label to be parsed.
- *
- * @return EOK on success, error code otherwise.
- *
- */
-int gpt_read_partitions(gpt_label_t *label)
-{
-	uint32_t fillries = uint32_t_le2host(label->gpt->header->fillries);
-	uint32_t ent_size = uint32_t_le2host(label->gpt->header->entry_size);
-	uint64_t ent_lba = uint64_t_le2host(label->gpt->header->entry_lba);
-	
-	if (label->parts == NULL) {
-		label->parts = alloc_part_array(fillries);
-		if (label->parts == NULL)
-			return ENOMEM;
-	}
-	
-	int rc = block_init(label->device, sizeof(gpt_entry_t));
-	if (rc != EOK) {
-		gpt_free_partitions(label->parts);
-		label->parts = NULL;
-		goto end;
-	}
-	
-	size_t block_size;
-	rc = block_get_bsize(label->device, &block_size);
-	if (rc != EOK) {
-		gpt_free_partitions(label->parts);
-		label->parts = NULL;
-		goto end;
-	}
-	
-	aoff64_t pos = ent_lba * block_size;
-	
-	for (uint32_t i = 0; i < fillries; i++) {
-		rc = block_read_bytes_direct(label->device, pos, sizeof(gpt_entry_t),
-		    label->parts->part_array + i);
-		pos += ent_size;
-		
-		if (rc != EOK) {
-			gpt_free_partitions(label->parts);
-			label->parts = NULL;
-			goto end;
-		}
-	}
-	
-	uint32_t crc = compute_crc32((uint8_t *) label->parts->part_array,
-	    fillries * ent_size);
-	
-	if (uint32_t_le2host(label->gpt->header->pe_array_crc32) != crc) {
-		rc = EBADCHECKSUM;
-		gpt_free_partitions(label->parts);
-		label->parts = NULL;
-		goto end;
-	}
-	
-	rc = EOK;
-	
-end:
-	block_fini(label->device);
-	return rc;
-}
-
-/** Write GPT and partitions to device
- *
- * Note: Also writes the header.
- *
- * @param label      Label to write.
- * @param dev_handle Device to write the data to.
- *
- * @return EOK on succes, error code otherwise
- *
- */
-int gpt_write_partitions(gpt_label_t *label, service_id_t dev_handle)
-{
-	/* comm_size of 4096 is ignored */
-	int rc = block_init(dev_handle, 4096);
-	if ((rc != EOK) && (rc != EEXIST))
-		return rc;
-	
-	size_t block_size;
-	rc = block_get_bsize(dev_handle, &block_size);
-	if (rc != EOK)
-		goto fail;
-	
-	aoff64_t blocks;
-	rc = block_get_nblocks(dev_handle, &blocks);
-	if (rc != EOK)
-		goto fail;
-	
-	if (label->gpt == NULL)
-		label->gpt = gpt_alloc_header(block_size);
-	
-	uint32_t entry_size =
-	    uint32_t_le2host(label->gpt->header->entry_size);
-	size_t fillries = (label->parts->fill > GPT_MIN_PART_NUM) ?
-	    label->parts->fill : GPT_MIN_PART_NUM;
-	
-	if (entry_size != sizeof(gpt_entry_t))
-		return ENOTSUP;
-	
-	label->gpt->header->fillries = host2uint32_t_le(fillries);
-	
-	uint64_t arr_blocks = (fillries * sizeof(gpt_entry_t)) / block_size;
-	
-	/* Include Protective MBR */
-	uint64_t gpt_space = arr_blocks + GPT_HDR_BS + 1;
-	
-	label->gpt->header->first_usable_lba = host2uint64_t_le(gpt_space);
-	label->gpt->header->last_usable_lba =
-	    host2uint64_t_le(blocks - gpt_space - 1);
-	
-	/* Perform checks */
-	gpt_part_foreach (label, p) {
-		if (gpt_get_part_type(p) == GPT_PTE_UNUSED)
-			continue;
-		
-		if (!check_encaps(p, blocks, gpt_space)) {
-			rc = ERANGE;
-			goto fail;
-		}
-		
-		gpt_part_foreach (label, q) {
-			if (p == q)
-				continue;
-			
-			if (gpt_get_part_type(p) != GPT_PTE_UNUSED) {
-				if (check_overlap(p, q)) {
-					rc = ERANGE;
-					goto fail;
-				}
-			}
-		}
-	}
-	
-	label->gpt->header->pe_array_crc32 =
-	    host2uint32_t_le(compute_crc32((uint8_t *) label->parts->part_array,
-	    fillries * entry_size));
-	
-	/* Write to backup GPT partition array location */
-	rc = block_write_direct(dev_handle, blocks - arr_blocks - 1,
-	    arr_blocks, label->parts->part_array);
-	if (rc != EOK)
-		goto fail;
-	
-	/* Write to main GPT partition array location */
-	rc = block_write_direct(dev_handle,
-	    uint64_t_le2host(label->gpt->header->entry_lba),
-	    arr_blocks, label->parts->part_array);
-	if (rc != EOK)
-		goto fail;
-	
-	return gpt_write_header(label, dev_handle);
-	
-fail:
-	block_fini(dev_handle);
-	return rc;
-}
-
-/** Allocate a new partition
- *
- * Note: Use either gpt_alloc_partition() or gpt_get_partition().
- * This returns a memory block (zero-filled) and needs gpt_add_partition()
- * to be called to insert it into a partition array.
- * Requires you to call gpt_free_partition afterwards.
- *
- * @return Pointer to the new partition or NULL.
- *
- */
-gpt_part_t *gpt_alloc_partition(void)
-{
-	gpt_part_t *partition = malloc(sizeof(gpt_part_t));
-	if (partition == NULL)
-		return NULL;
-	
-	memset(partition, 0, sizeof(gpt_part_t));
-	
-	return partition;
-}
-
-/** Allocate a new partition already inside the label
- *
- * Note: Use either gpt_alloc_partition() or gpt_get_partition().
- * This one returns a pointer to the first empty structure already
- * inside the array, so don't call gpt_add_partition() afterwards.
- * This is the one you will usually want.
- *
- * @param label Label to carry new partition.
- *
- * @return Pointer to the new partition or NULL.
- *
- */
-gpt_part_t *gpt_get_partition(gpt_label_t *label)
-{
-	gpt_part_t *partition;
-	
-	/* Find the first empty entry */
-	do {
-		if (label->parts->fill == label->parts->arr_size) {
-			if (extend_part_array(label->parts) == -1)
-				return NULL;
-		}
-		
-		partition = label->parts->part_array + label->parts->fill++;
-	} while (gpt_get_part_type(partition) != GPT_PTE_UNUSED);
-	
-	return partition;
-}
-
-/** Get partition already inside the label
- *
- * Note: For new partitions use either gpt_alloc_partition() or
- * gpt_get_partition() unless you want a partition at a specific place.
- * This returns a pointer to a structure already inside the array,
- * so don't call gpt_add_partition() afterwards.
- * This function is handy when you want to change already existing
- * partition or to simply write somewhere in the middle. This works only
- * for indexes smaller than either 128 or the actual number of filled
- * entries.
- *
- * @param label Label to carrying the partition.
- * @param idx   Index of the partition.
- *
- * @return Pointer to the partition or NULL when out of range.
- *
- */
-gpt_part_t *gpt_get_partition_at(gpt_label_t *label, size_t idx)
-{
-	if ((idx >= GPT_MIN_PART_NUM) && (idx >= label->parts->fill))
-		return NULL;
-	
-	return label->parts->part_array + idx;
-}
-
-/** Copy partition into partition array
- *
- * Note: For use with gpt_alloc_partition() only. You will get
- * duplicates with gpt_get_partition().
- * Note: Does not call gpt_free_partition()!
- *
- * @param parts     Target label
- * @param partition Source partition to copy
- *
- * @return EOK on succes, error code otherwise
- *
- */
-int gpt_add_partition(gpt_label_t *label, gpt_part_t *partition)
-{
-	/* Find the first empty entry */
-	
-	gpt_part_t *part;
-	
-	do {
-		if (label->parts->fill == label->parts->arr_size) {
-			if (extend_part_array(label->parts) == -1)
-				return ENOMEM;
-		}
-		
-		part = label->parts->part_array + label->parts->fill++;
-	} while (gpt_get_part_type(part) != GPT_PTE_UNUSED);
-	
-	memcpy(part, partition, sizeof(gpt_entry_t));
-	return EOK;
-}
-
-/** Remove partition from array
- *
- * Note: Even if it fails, the partition still gets removed. Only
- * reducing the array failed.
- *
- * @param label Label to remove from
- * @param idx   Index of the partition to remove
- *
- * @return EOK on success, ENOMEM on array reduction failure
- *
- */
-int gpt_remove_partition(gpt_label_t *label, size_t idx)
-{
-	if (idx >= label->parts->arr_size)
-		return EINVAL;
-	
-	/*
-	 * FIXME:
-	 * If we allow blank spots, we break the array. If we have more than
-	 * 128 partitions in the array and then remove something from
-	 * the first 128 partitions, we would forget to write the last one.
-	 */
-	
-	memset(label->parts->part_array + idx, 0, sizeof(gpt_entry_t));
-	
-	if (label->parts->fill > idx)
-		label->parts->fill = idx;
-	
-	gpt_part_t *partition;
-	
-	if ((label->parts->fill > GPT_MIN_PART_NUM) &&
-	    (label->parts->fill < (label->parts->arr_size / 2) -
-	    GPT_IGNORE_FILL_NUM)) {
-		for (partition = gpt_get_partition_at(label, label->parts->arr_size / 2);
-		     partition < label->parts->part_array + label->parts->arr_size;
-		     partition++) {
-			if (gpt_get_part_type(partition) != GPT_PTE_UNUSED)
-				return EOK;
-		}
-		
-		if (reduce_part_array(label->parts) == ENOMEM)
-			return ENOMEM;
-	}
-	
-	return EOK;
-}
-
-/** Free partition list
- *
- * @param parts Partition list to be freed
- *
- */
-void gpt_free_partitions(gpt_partitions_t *parts)
-{
-	free(parts->part_array);
-	free(parts);
-}
-
-/** Get partition type */
-size_t gpt_get_part_type(gpt_part_t *partition)
-{
-	size_t i;
-	
-	for (i = 0; gpt_ptypes[i].guid != NULL; i++) {
-		if ((partition->part_type[3] == get_byte(gpt_ptypes[i].guid + 0)) &&
-		    (partition->part_type[2] == get_byte(gpt_ptypes[i].guid + 2)) &&
-		    (partition->part_type[1] == get_byte(gpt_ptypes[i].guid + 4)) &&
-		    (partition->part_type[0] == get_byte(gpt_ptypes[i].guid + 6)) &&
-		    (partition->part_type[5] == get_byte(gpt_ptypes[i].guid + 8)) &&
-		    (partition->part_type[4] == get_byte(gpt_ptypes[i].guid + 10)) &&
-		    (partition->part_type[7] == get_byte(gpt_ptypes[i].guid + 12)) &&
-		    (partition->part_type[6] == get_byte(gpt_ptypes[i].guid + 14)) &&
-		    (partition->part_type[8] == get_byte(gpt_ptypes[i].guid + 16)) &&
-		    (partition->part_type[9] == get_byte(gpt_ptypes[i].guid + 18)) &&
-		    (partition->part_type[10] == get_byte(gpt_ptypes[i].guid + 20)) &&
-		    (partition->part_type[11] == get_byte(gpt_ptypes[i].guid + 22)) &&
-		    (partition->part_type[12] == get_byte(gpt_ptypes[i].guid + 24)) &&
-		    (partition->part_type[13] == get_byte(gpt_ptypes[i].guid + 26)) &&
-		    (partition->part_type[14] == get_byte(gpt_ptypes[i].guid + 28)) &&
-		    (partition->part_type[15] == get_byte(gpt_ptypes[i].guid + 30)))
-			return i;
-	}
-	
-	return i;
-}
-
-/** Set partition type */
-void gpt_set_part_type(gpt_part_t *partition, size_t type)
-{
-	/* Beware: first 3 blocks are byteswapped! */
-	partition->part_type[3] = get_byte(gpt_ptypes[type].guid + 0);
-	partition->part_type[2] = get_byte(gpt_ptypes[type].guid + 2);
-	partition->part_type[1] = get_byte(gpt_ptypes[type].guid + 4);
-	partition->part_type[0] = get_byte(gpt_ptypes[type].guid + 6);
-	
-	partition->part_type[5] = get_byte(gpt_ptypes[type].guid + 8);
-	partition->part_type[4] = get_byte(gpt_ptypes[type].guid + 10);
-	
-	partition->part_type[7] = get_byte(gpt_ptypes[type].guid + 12);
-	partition->part_type[6] = get_byte(gpt_ptypes[type].guid + 14);
-	
-	partition->part_type[8] = get_byte(gpt_ptypes[type].guid + 16);
-	partition->part_type[9] = get_byte(gpt_ptypes[type].guid + 18);
-	partition->part_type[10] = get_byte(gpt_ptypes[type].guid + 20);
-	partition->part_type[11] = get_byte(gpt_ptypes[type].guid + 22);
-	partition->part_type[12] = get_byte(gpt_ptypes[type].guid + 24);
-	partition->part_type[13] = get_byte(gpt_ptypes[type].guid + 26);
-	partition->part_type[14] = get_byte(gpt_ptypes[type].guid + 28);
-	partition->part_type[15] = get_byte(gpt_ptypes[type].guid + 30);
-}
-
-/** Get partition starting LBA */
-uint64_t gpt_get_start_lba(gpt_part_t *partition)
-{
-	return uint64_t_le2host(partition->start_lba);
-}
-
-/** Set partition starting LBA */
-void gpt_set_start_lba(gpt_part_t *partition, uint64_t start)
-{
-	partition->start_lba = host2uint64_t_le(start);
-}
-
-/** Get partition ending LBA */
-uint64_t gpt_get_end_lba(gpt_part_t *partition)
-{
-	return uint64_t_le2host(partition->end_lba);
-}
-
-/** Set partition ending LBA */
-void gpt_set_end_lba(gpt_part_t *partition, uint64_t end)
-{
-	partition->end_lba = host2uint64_t_le(end);
-}
-
-/** Get partition name */
-unsigned char * gpt_get_part_name(gpt_part_t *partition)
-{
-	return partition->part_name;
-}
-
-/** Copy partition name */
-void gpt_set_part_name(gpt_part_t *partition, char *name, size_t length)
-{
-	if (length >= 72)
-		length = 71;
-	
-	memcpy(partition->part_name, name, length);
-	partition->part_name[length] = '\0';
-}
-
-/** Get partition attribute */
-bool gpt_get_flag(gpt_part_t *partition, gpt_attr_t flag)
-{
-	return (partition->attributes & (((uint64_t) 1) << flag)) ? 1 : 0;
-}
-
-/** Set partition attribute */
-void gpt_set_flag(gpt_part_t *partition, gpt_attr_t flag, bool value)
-{
-	uint64_t attr = partition->attributes;
-	
-	if (value)
-		attr = attr | (((uint64_t) 1) << flag);
-	else
-		attr = attr ^ (attr & (((uint64_t) 1) << flag));
-	
-	partition->attributes = attr;
-}
-
-/** Generate a new pseudo-random UUID compliant with RFC 4122 */
-void gpt_set_random_uuid(uint8_t *uuid)
-{
-	srandom((unsigned int) (size_t) uuid);
-	
-	for (size_t i = 0; i < 16; i++)
-		uuid[i] = random();
-
-	/* 
-	 * Set version (stored in bits 4-7 of seventh byte) to 4 (random
-	 * UUID) and bits 6 and 7 of ninth byte to 0 and 1 respectively -
-	 * according to RFC 4122, section 4.4.
-	 */
-	uuid[6] &= 0x0f;
-	uuid[6] |= (0x4 << 4);
-	uuid[8] &= 0x3f;
-	uuid[8] |= (1 << 7);
-}
-
-/** Get next aligned address */
-uint64_t gpt_get_next_aligned(uint64_t addr, unsigned int alignment)
-{
-	return ALIGN_UP(addr + 1, alignment);
-}
-
-static int load_and_check_header(service_id_t dev_handle, aoff64_t addr,
-    size_t block_size, gpt_header_t *header)
-{
-	int rc = block_read_direct(dev_handle, addr, GPT_HDR_BS, header);
-	if (rc != EOK)
-		return rc;
-	
-	/* Check the EFI signature */
-	for (unsigned int i = 0; i < 8; i++) {
-		if (header->efi_signature[i] != efi_signature[i])
-			return EINVAL;
-	}
-	
-	/* Check the CRC32 of the header */
-	uint32_t crc = header->header_crc32;
-	header->header_crc32 = 0;
-	
-	if (crc != compute_crc32((uint8_t *) header, header->header_size))
-		return EBADCHECKSUM;
-	else
-		header->header_crc32 = crc;
-	
-	/* Check for zeroes in the rest of the block */
-	for (size_t i = sizeof(gpt_header_t); i < block_size; i++) {
-		if (((uint8_t *) header)[i] != 0)
-			return EINVAL;
-	}
-	
-	return EOK;
-}
-
-static gpt_partitions_t *alloc_part_array(uint32_t num)
-{
-	gpt_partitions_t *res = malloc(sizeof(gpt_partitions_t));
-	if (res == NULL)
-		return NULL;
-	
-	uint32_t size = num > GPT_BASE_PART_NUM ? num : GPT_BASE_PART_NUM;
-	res->part_array = malloc(size * sizeof(gpt_entry_t));
-	if (res->part_array == NULL) {
-		free(res);
-		return NULL;
-	}
-	
-	memset(res->part_array, 0, size * sizeof(gpt_entry_t));
-	
-	res->fill = 0;
-	res->arr_size = num;
-	
-	return res;
-}
-
-static int extend_part_array(gpt_partitions_t *partition)
-{
-	size_t nsize = partition->arr_size * 2;
-	gpt_entry_t *entry = malloc(nsize * sizeof(gpt_entry_t));
-	if (entry == NULL)
-		return ENOMEM;
-	
-	memcpy(entry, partition->part_array, partition->fill *
-	    sizeof(gpt_entry_t));
-	free(partition->part_array);
-	
-	partition->part_array = entry;
-	partition->arr_size = nsize;
-	
-	return EOK;
-}
-
-static int reduce_part_array(gpt_partitions_t *partition)
-{
-	if (partition->arr_size > GPT_MIN_PART_NUM) {
-		unsigned int nsize = partition->arr_size / 2;
-		nsize = nsize > GPT_MIN_PART_NUM ? nsize : GPT_MIN_PART_NUM;
-		
-		gpt_entry_t *entry = malloc(nsize * sizeof(gpt_entry_t));
-		if (entry == NULL)
-			return ENOMEM;
-		
-		memcpy(entry, partition->part_array,
-		    partition->fill < nsize ? partition->fill : nsize);
-		free(partition->part_array);
-		
-		partition->part_array = entry;
-		partition->arr_size = nsize;
-	}
-	
-	return EOK;
-}
-
-/* Parse a byte from a string in hexadecimal */
-static uint8_t get_byte(const char *c)
-{
-	uint8_t val = 0;
-	char hex[3] = {*c, *(c + 1), 0};
-	
-	str_uint8_t(hex, NULL, 16, false, &val);
-	return val;
-}
-
-static bool check_overlap(gpt_part_t *part1, gpt_part_t *part2)
-{
-	if ((gpt_get_start_lba(part1) < gpt_get_start_lba(part2)) &&
-	    (gpt_get_end_lba(part1) < gpt_get_start_lba(part2)))
-		return false;
-	
-	if ((gpt_get_start_lba(part1) > gpt_get_start_lba(part2)) &&
-	    (gpt_get_end_lba(part2) < gpt_get_start_lba(part1)))
-		return false;
-	
-	return true;
-}
-
-static bool check_encaps(gpt_part_t *part, uint64_t blocks,
-    uint64_t first_lba)
-{
-	/*
-	 * We allow "<=" in the second expression because it lacks
-	 * MBR so it is smaller by 1 block.
-	 */
-	if ((gpt_get_start_lba(part) >= first_lba) &&
-	    (gpt_get_end_lba(part) <= blocks - first_lba))
-		return true;
-	
-	return false;
-}
Index: pace/lib/gpt/libgpt.h
===================================================================
--- uspace/lib/gpt/libgpt.h	(revision cffa82aac31c77f5d26f954922753c58edfef5f7)
+++ 	(revision )
@@ -1,138 +1,0 @@
-/*
- * Copyright (c) 2009 Jiri Svoboda
- * Copyright (c) 2011-2013 Dominik Taborsky
- * 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 libgpt
- * @{
- */
-/** @file
- */
-
-#ifndef LIBGPT_LIBGPT_H_
-#define LIBGPT_LIBGPT_H_
-
-#include <loc.h>
-#include <sys/types.h>
-#include "gpt.h"
-
-/** Block address of GPT header. */
-#define GPT_HDR_BA  1
-
-/** Block size of GPT header. */
-#define GPT_HDR_BS  1
-
-/** Minimum number of GPT partition entries */
-#define GPT_MIN_PART_NUM  128
-
-/** Basic number of GPT partition entries */
-#define GPT_BASE_PART_NUM  (GPT_MIN_PART_NUM)
-
-/** How much fill we ignore before resizing partition array */
-#define GPT_IGNORE_FILL_NUM  10
-
-/** Unused partition entry */
-#define GPT_PTE_UNUSED  0
-
-/** Raw GPT header.
- *
- * Uses more bytes than sizeof(gpt_header_t).
- */
-typedef struct {
-	gpt_header_t *header;
-} gpt_t;
-
-typedef gpt_entry_t gpt_part_t;
-
-typedef struct {
-	/** Number of entries */
-	size_t fill;
-	
-	/** Size of the array */
-	size_t arr_size;
-	
-	/** Resizable partition array */
-	gpt_part_t *part_array;
-} gpt_partitions_t;
-
-typedef struct {
-	gpt_t *gpt;
-	gpt_partitions_t *parts;
-	service_id_t device;
-} gpt_label_t;
-
-typedef struct {
-	const char *desc;
-	const char *guid;
-} partition_type_t;
-
-/** GPT header signature ("EFI PART" in ASCII) */
-extern const uint8_t efi_signature[8];
-extern const uint8_t revision[4];
-
-extern const partition_type_t gpt_ptypes[];
-
-extern gpt_label_t *gpt_alloc_label(void);
-extern void gpt_free_label(gpt_label_t *);
-
-extern gpt_t *gpt_alloc_header(size_t);
-extern int gpt_read_header(gpt_label_t *, service_id_t);
-extern int gpt_write_header(gpt_label_t *, service_id_t);
-
-extern gpt_partitions_t *gpt_alloc_partitions(void);
-extern int gpt_read_partitions(gpt_label_t *);
-extern int gpt_write_partitions(gpt_label_t *, service_id_t);
-extern gpt_part_t *gpt_alloc_partition(void);
-extern gpt_part_t *gpt_get_partition(gpt_label_t *);
-extern gpt_part_t *gpt_get_partition_at(gpt_label_t *, size_t);
-extern int gpt_add_partition(gpt_label_t *, gpt_part_t *);
-extern int gpt_remove_partition(gpt_label_t *, size_t);
-
-extern size_t gpt_get_part_type(gpt_part_t *);
-extern void gpt_set_part_type(gpt_part_t *, size_t);
-extern void gpt_set_start_lba(gpt_part_t *, uint64_t);
-extern uint64_t gpt_get_start_lba(gpt_part_t *);
-extern void gpt_set_end_lba(gpt_part_t *, uint64_t);
-extern uint64_t gpt_get_end_lba(gpt_part_t *);
-extern unsigned char *gpt_get_part_name(gpt_part_t *);
-extern void gpt_set_part_name(gpt_part_t *, char *, size_t);
-extern bool gpt_get_flag(gpt_part_t *, gpt_attr_t);
-extern void gpt_set_flag(gpt_part_t *, gpt_attr_t, bool);
-
-extern void gpt_set_random_uuid(uint8_t *);
-extern uint64_t gpt_get_next_aligned(uint64_t, unsigned int);
-
-
-#define gpt_part_foreach(label, iterator) \
-	for (gpt_part_t *iterator = (label)->parts->part_array; \
-	    iterator < (label)->parts->part_array + (label)->parts->arr_size; \
-	    iterator++)
-
-extern void gpt_free_gpt(gpt_t *);
-extern void gpt_free_partitions(gpt_partitions_t *);
-
-#endif
Index: pace/lib/mbr/Makefile
===================================================================
--- uspace/lib/mbr/Makefile	(revision cffa82aac31c77f5d26f954922753c58edfef5f7)
+++ 	(revision )
@@ -1,36 +1,0 @@
-#
-# Copyright (c) 2011 Dominik Taborsky
-# 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 = ../..
-EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX)
-LIBRARY = libmbr
-
-SOURCES = \
-	libmbr.c
-
-include $(USPACE_PREFIX)/Makefile.common
Index: pace/lib/mbr/libmbr.c
===================================================================
--- uspace/lib/mbr/libmbr.c	(revision cffa82aac31c77f5d26f954922753c58edfef5f7)
+++ 	(revision )
@@ -1,852 +1,0 @@
-/*
- * Copyright (c) 2011-2013 Dominik Taborsky
- * 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 LIBMBR_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 libmbr
- * @{
- */
-/** @file MBR extraxtion library
- */
-
-#include <async.h>
-#include <assert.h>
-#include <block.h>
-#include <byteorder.h>
-#include <errno.h>
-#include <ipc/bd.h>
-#include <mem.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <str_error.h>
-#include <align.h>
-#include "libmbr.h"
-
-static br_block_t *alloc_br(void);
-static int decode_part(pt_entry_t *, mbr_part_t *, uint32_t);
-static int decode_logical(mbr_label_t *, mbr_part_t *);
-static void encode_part(mbr_part_t *, pt_entry_t *, uint32_t, bool);
-static bool check_overlap(mbr_part_t *, mbr_part_t *);
-static bool check_encaps(mbr_part_t *, mbr_part_t *);
-static bool check_preceeds(mbr_part_t *, mbr_part_t *);
-static mbr_err_val mbr_add_primary(mbr_label_t *, mbr_part_t *);
-static mbr_err_val mbr_add_logical(mbr_label_t *, mbr_part_t *);
-
-/** Allocate and initialize mbr_label_t structure */
-mbr_label_t *mbr_alloc_label(void)
-{
-	mbr_label_t *label = malloc(sizeof(mbr_label_t));
-	if (label == NULL)
-		return NULL;
-	
-	label->mbr = NULL;
-	label->parts = NULL;
-	label->device = 0;
-	
-	return label;
-}
-
-void mbr_set_device(mbr_label_t *label, service_id_t dev_handle)
-{
-	label->device = dev_handle;
-}
-
-/** Free mbr_label_t structure */
-void mbr_free_label(mbr_label_t *label)
-{
-	if (label->mbr != NULL)
-		mbr_free_mbr(label->mbr);
-	
-	if (label->parts != NULL)
-		mbr_free_partitions(label->parts);
-	
-	free(label);
-}
-
-/** Allocate memory for mbr_t */
-mbr_t *mbr_alloc_mbr(void)
-{
-	return (mbr_t *)alloc_br();
-}
-
-/** Read MBR from specific device
- *
- * @param label      Label to be read.
- * @param dev_handle Device to read MBR from.
- *
- * @return EOK on success, error code on error.
- *
- */
-int mbr_read_mbr(mbr_label_t *label, service_id_t dev_handle)
-{	
-	if (label->mbr == NULL) {
-		label->mbr = mbr_alloc_mbr();
-		if (label->mbr == NULL)
-			return ENOMEM;
-	}
-	
-	int rc = block_init(dev_handle, 512);
-	if (rc != EOK)
-		return rc;
-	
-	rc = block_read_direct(dev_handle, 0, 1, &label->mbr->raw_data);
-	block_fini(dev_handle);
-	if (rc != EOK)
-		return rc;
-	
-	label->device = dev_handle;
-	
-	return EOK;
-}
-
-/** Write MBR to specific device
- *
- * @param label      Label to be written.
- * @param dev_handle Device to write MBR to.
- *
- * @return EOK on success, error code on error.
- *
- */
-int mbr_write_mbr(mbr_label_t *label, service_id_t dev_handle)
-{
-	int rc = block_init(dev_handle, 512);
-	if (rc != EOK)
-		return rc;
-	
-	rc = block_write_direct(dev_handle, 0, 1, &label->mbr->raw_data);
-	block_fini(dev_handle);
-	
-	return rc;
-}
-
-/** Decide whether this is an actual MBR or a Protective MBR for GPT
- *
- * @param label Label to decide upon.
- *
- * @return True if MBR.
- * @return False if Protective MBR for GPT.
- *
- */
-int mbr_is_mbr(mbr_label_t *label)
-{
-	return (label->mbr->raw_data.pte[0].ptype != PT_GPT);
-}
-
-/** Parse partitions from MBR (freeing previous partitions if any)
- *
- * It is assumed that mbr_read_mbr() was called before.
- *
- * @param label Label to be parsed.
- *
- * @return EOK on success, error code on error.
- *
- */
-int mbr_read_partitions(mbr_label_t *label)
-{
-	if ((label == NULL) || (label->mbr == NULL))
-		return EINVAL;
-	
-	if (label->parts != NULL)
-		mbr_free_partitions(label->parts);
-	
-	label->parts = mbr_alloc_partitions();
-	if (label->parts == NULL)
-		return ENOMEM;
-	
-	mbr_part_t *extended = NULL;
-	
-	/* Generate the primary partitions */
-	for (unsigned int i = 0; i < N_PRIMARY; i++) {
-		if (label->mbr->raw_data.pte[i].ptype == PT_UNUSED)
-			continue;
-		
-		mbr_part_t *partition = mbr_alloc_partition();
-		if (partition == NULL) {
-			mbr_free_partitions(label->parts);
-			return ENOMEM;
-		}
-		
-		int is_extended =
-		    decode_part(&label->mbr->raw_data.pte[i], partition, 0);
-		
-		mbr_set_flag(partition, ST_LOGIC, false);
-		
-		int rc = mbr_add_partition(label, partition);
-		if (rc != ERR_OK) {
-			mbr_free_partitions(label->parts);
-			return EINVAL;
-		}
-		
-		if (is_extended) {
-			extended = partition;
-			label->parts->l_extended = &partition->link;
-		}
-	}
-	
-	/* Fill in the primary partitions and generate logical ones (if any) */
-	return decode_logical(label, extended);
-}
-
-/** Write MBR and partitions to device
- *
- * @param label      Label to write.
- * @param dev_handle Device to write the data to.
- *
- * @return EOK on success, specific error code otherwise.
- *
- */
-int mbr_write_partitions(mbr_label_t *label, service_id_t dev_handle)
-{
-	if (label->parts == NULL)
-		return EOK;
-	
-	if (label->mbr == NULL)
-		label->mbr = mbr_alloc_mbr();
-	
-	int rc = block_init(dev_handle, 512);
-	if (rc != EOK)
-		return rc;
-	
-	mbr_part_t *partition = NULL;
-	mbr_part_t *extended = NULL;
-	
-	if (label->parts->l_extended != NULL)
-		extended = list_get_instance(label->parts->l_extended,
-		    mbr_part_t, link);
-	
-	link_t *link = label->parts->list.head.next;
-	
-	/* Encode primary partitions */
-	for (unsigned int i = 0; i < N_PRIMARY; i++) {
-		partition = list_get_instance(link, mbr_part_t, link);
-		
-		encode_part(partition, &label->mbr->raw_data.pte[i], 0, false);
-		link = link->next;
-	}
-	
-	/* Write MBR */
-	rc = block_write_direct(dev_handle, 0, 1, &label->mbr->raw_data);
-	if ((rc != EOK) || (extended == NULL))
-		goto end;
-	
-	uint32_t base = extended->start_addr;
-	mbr_part_t *prev_partition;
-	
-	/* Encode and write first logical partition */
-	if (link != &label->parts->list.head) {
-		partition = list_get_instance(link, mbr_part_t, link);
-		
-		partition->ebr_addr = base;
-		encode_part(partition, &partition->ebr->pte[0], base, false);
-		link = link->next;
-	} else {
-		/*
-		 * If there was an extended partition but no logical partitions,
-		 * we should overwrite the space where the first logical
-		 * partitions's EBR would have been. There might be some
-		 * garbage from the past.
-		 */
-		
-		br_block_t *br = alloc_br();
-		rc = block_write_direct(dev_handle, base, 1, br);
-		if (rc != EOK)
-			goto end;
-		
-		free(br);
-		goto end;
-	}
-	
-	prev_partition = partition;
-	
-	/*
-	 * Check EBR addresses: The code saves previous EBR
-	 * placements from other software. But if our user
-	 * modifies the logical partition chain, we have to
-	 * fix those placements if needed.
-	 */
-	
-	link_t *link_ebr = link;
-	link_t *link_iter;
-	
-	mbr_part_t tmp_partition;
-	tmp_partition.length = 1;
-	
-	while (link_ebr != &label->parts->list.head) {
-		partition = list_get_instance(link_ebr, mbr_part_t, link);
-		
-		tmp_partition.start_addr = partition->ebr_addr;
-		
-		link_iter = link;
-		while (link_iter != &label->parts->list.head) {
-			/*
-			 * Check whether EBR address makes sense. If not, we take
-			 * a guess.  So far this is simple, we just take the first
-			 * preceeding sector. FDisk always reserves at least 2048
-			 * sectors (1 MiB), so it can have the EBR aligned as well
-			 * as the partition itself. Parted reserves minimum one
-			 * sector, like we do.
-			 *
-			 * Note that we know there is at least one sector free from
-			 * previous checks. Also note that the user can set ebr_addr
-			 * to their liking (if it is valid).
-			 */
-			
-			if ((partition->ebr_addr < base) ||
-			    (partition->ebr_addr >= base + extended->length) ||
-			    (check_overlap(&tmp_partition,
-			    list_get_instance(link_iter, mbr_part_t, link)))) {
-				partition->ebr_addr = partition->start_addr - 1;
-				break;
-			}
-			
-			link_iter = link_iter->next;
-		}
-		
-		link_ebr = link_ebr->next;
-	}
-	
-	/* Encode and write logical partitions */
-	while (link != &label->parts->list.head) {
-		partition = list_get_instance(link, mbr_part_t, link);
-		
-		encode_part(partition, &partition->ebr->pte[0],
-		    partition->ebr_addr, false);
-		encode_part(partition, &prev_partition->ebr->pte[1],
-		    base, true);
-		
-		rc = block_write_direct(dev_handle, prev_partition->ebr_addr, 1,
-		    prev_partition->ebr);
-		if (rc != EOK)
-			goto end;
-		
-		prev_partition = partition;
-		link = link->next;
-	}
-	
-	/* Write the last EBR */
-	encode_part(NULL, &prev_partition->ebr->pte[1], 0, false);
-	rc = block_write_direct(dev_handle, prev_partition->ebr_addr,
-	    1, prev_partition->ebr);
-	
-end:
-	block_fini(dev_handle);
-	return rc;
-}
-
-/** Partition constructor */
-mbr_part_t *mbr_alloc_partition(void)
-{
-	mbr_part_t *partition = malloc(sizeof(mbr_part_t));
-	if (partition == NULL)
-		return NULL;
-	
-	link_initialize(&partition->link);
-	partition->ebr = NULL;
-	partition->type = PT_UNUSED;
-	partition->status = 0;
-	partition->start_addr = 0;
-	partition->length = 0;
-	partition->ebr_addr = 0;
-	
-	return partition;
-}
-
-/** Partitions constructor */
-mbr_partitions_t *mbr_alloc_partitions(void)
-{
-	mbr_partitions_t *parts = malloc(sizeof(mbr_partitions_t));
-	if (parts == NULL)
-		return NULL;
-	
-	list_initialize(&parts->list);
-	parts->n_primary = 0;
-	parts->n_logical = 0;
-	parts->l_extended = NULL;
-	
-	/* Add blank primary partitions */
-	for (unsigned int i = 0; i < N_PRIMARY; ++i) {
-		mbr_part_t *part = mbr_alloc_partition();
-		if (part == NULL) {
-			mbr_free_partitions(parts);
-			return NULL;
-		}
-		
-		list_append(&part->link, &parts->list);
-	}
-	
-	return parts;
-}
-
-/** Add partition
- *
- * Perform checks, sort the list.
- *
- * @param label Label to add to.
- * @param part  Partition to add.
- *
- * @return ERR_OK on success, other MBR_ERR_VAL otherwise
- *
- */
-mbr_err_val mbr_add_partition(mbr_label_t *label, mbr_part_t *part)
-{
-	int rc = block_init(label->device, 512);
-	if ((rc != EOK) && (rc != EEXIST))
-		return ERR_LIBBLOCK;
-	
-	aoff64_t nblocks;
-	int ret = block_get_nblocks(label->device, &nblocks);
-	
-	if (rc != EEXIST)
-		block_fini(label->device);
-	
-	if (ret != EOK)
-		return ERR_LIBBLOCK;
-	
-	if ((aoff64_t) part->start_addr + part->length > nblocks)
-		return ERR_OUT_BOUNDS;
-	
-	if (label->parts == NULL) {
-		label->parts = mbr_alloc_partitions();
-		if (label->parts == NULL)
-			// FIXME! merge mbr_err_val into errno.h
-			return ENOMEM;
-	}
-	
-	if (mbr_get_flag(part, ST_LOGIC))
-		return mbr_add_logical(label, part);
-	else
-		return mbr_add_primary(label, part);
-}
-
-/** Remove partition
- *
- * Remove partition (indexed from zero). When removing the extended
- * partition, all logical partitions get removed as well.
- *
- * @param label Label to remove from.
- * @param idx   Index of the partition to remove.
- *
- * @return EOK on success.
- * @return EINVAL if the index is invalid.
- *
- */
-int mbr_remove_partition(mbr_label_t *label, size_t idx)
-{
-	link_t *link = list_nth(&label->parts->list, idx);
-	if (link == NULL)
-		return EINVAL;
-	
-	/*
-	 * If removing the extended partition, remove all
-	 * logical partitions as well.
-	 */
-	if (link == label->parts->l_extended) {
-		label->parts->l_extended = NULL;
-		
-		link_t *iterator = link->next;
-		link_t *next;
-		
-		while (iterator != &label->parts->list.head) {
-			next = iterator->next;
-			mbr_part_t *partition =
-			    list_get_instance(iterator, mbr_part_t, link);
-			
-			if (mbr_get_flag(partition, ST_LOGIC)) {
-				list_remove(iterator);
-				label->parts->n_logical--;
-				mbr_free_partition(partition);
-			}
-			
-			iterator = next;
-		}
-	}
-	
-	/* Remove the partition itself */
-	mbr_part_t *partition =
-	    list_get_instance(link, mbr_part_t, link);
-	
-	if (mbr_get_flag(partition, ST_LOGIC)) {
-		label->parts->n_logical--;
-		list_remove(link);
-		mbr_free_partition(partition);
-	} else {
-		/*
-		 * Cannot remove a primary partition without
-		 * breaking the ordering. Just zero it.
-		 */
-		label->parts->n_primary--;
-		partition->type = 0;
-		partition->status = 0;
-		partition->start_addr = 0;
-		partition->length = 0;
-		partition->ebr_addr = 0;
-	}
-	
-	return EOK;
-}
-
-/** Partition destructor */
-void mbr_free_partition(mbr_part_t *partition)
-{
-	if (partition->ebr != NULL)
-		free(partition->ebr);
-	
-	free(partition);
-}
-
-/** Check for flag */
-int mbr_get_flag(mbr_part_t *partition, mbr_flags_t flag)
-{
-	return (partition->status & (1 << flag));
-}
-
-/** Set a specific status flag */
-void mbr_set_flag(mbr_part_t *partition, mbr_flags_t flag, bool set)
-{
-	if (set)
-		partition->status |= 1 << flag;
-	else
-		partition->status &= ~((uint16_t) (1 << flag));
-}
-
-/** Get next aligned address */
-uint32_t mbr_get_next_aligned(uint32_t addr, unsigned int alignment)
-{
-	return ALIGN_UP(addr + 1, alignment);
-}
-
-list_t *mbr_get_list(mbr_label_t *label)
-{
-	if (label->parts != NULL)
-		return &label->parts->list;
-	else
-		return NULL;
-}
-
-mbr_part_t *mbr_get_first_partition(mbr_label_t *label)
-{
-	list_t *list = mbr_get_list(label);
-	if ((list != NULL) && (!list_empty(list)))
-		return list_get_instance(list->head.next, mbr_part_t, link);
-	else
-		return NULL;
-}
-
-mbr_part_t *mbr_get_next_partition(mbr_label_t *label, mbr_part_t *partition)
-{
-	list_t *list = mbr_get_list(label);
-	if ((list != NULL) && (&partition->link != list_last(list)))
-		return list_get_instance(partition->link.next, mbr_part_t, link);
-	else
-		return NULL;
-}
-
-void mbr_free_mbr(mbr_t *mbr)
-{
-	free(mbr);
-}
-
-/** Free partition list
- *
- * @param parts Partition list to be freed
- *
- */
-void mbr_free_partitions(mbr_partitions_t *parts)
-{
-	list_foreach_safe(parts->list, cur_link, next) {
-		mbr_part_t *partition = list_get_instance(cur_link, mbr_part_t, link);
-		list_remove(cur_link);
-		mbr_free_partition(partition);
-	}
-	
-	free(parts);
-}
-
-static br_block_t *alloc_br(void)
-{
-	br_block_t *br = malloc(sizeof(br_block_t));
-	if (br == NULL)
-		return NULL;
-	
-	memset(br, 0, 512);
-	br->signature = host2uint16_t_le(BR_SIGNATURE);
-	
-	return br;
-}
-
-/** Decode partition entry */
-static int decode_part(pt_entry_t *src, mbr_part_t *partition, uint32_t base)
-{
-	partition->type = src->ptype;
-	partition->status = (partition->status & 0xff00) | (uint16_t) src->status;
-	partition->start_addr = uint32_t_le2host(src->first_lba) + base;
-	partition->length = uint32_t_le2host(src->length);
-	
-	return (src->ptype == PT_EXTENDED);
-}
-
-/** Parse logical partitions */
-static int decode_logical(mbr_label_t *label, mbr_part_t *extended)
-{
-	if (extended == NULL)
-		return EOK;
-	
-	br_block_t *ebr = alloc_br();
-	if (ebr == NULL)
-		return ENOMEM;
-	
-	uint32_t base = extended->start_addr;
-	uint32_t addr = base;
-	
-	int rc = block_init(label->device, 512);
-	if (rc != EOK)
-		goto end;
-	
-	rc = block_read_direct(label->device, addr, 1, ebr);
-	if (rc != EOK)
-		goto end;
-	
-	if (uint16_t_le2host(ebr->signature) != BR_SIGNATURE) {
-		rc = EINVAL;
-		goto end;
-	}
-	
-	if (ebr->pte[0].ptype == PT_UNUSED) {
-		rc = EOK;
-		goto end;
-	}
-	
-	mbr_part_t *partition = mbr_alloc_partition();
-	if (partition == NULL) {
-		rc = ENOMEM;
-		goto end;
-	}
-	
-	decode_part(&ebr->pte[0], partition, base);
-	mbr_set_flag(partition, ST_LOGIC, true);
-	partition->ebr = ebr;
-	partition->ebr_addr = addr;
-	
-	rc = mbr_add_partition(label, partition);
-	if (rc != ERR_OK)
-		goto end;
-	
-	addr = uint32_t_le2host(ebr->pte[1].first_lba) + base;
-	
-	while (ebr->pte[1].ptype != PT_UNUSED) {
-		rc = block_read_direct(label->device, addr, 1, ebr);
-		if (rc != EOK)
-			goto end;
-		
-		if (uint16_t_le2host(ebr->signature) != BR_SIGNATURE) {
-			rc = EINVAL;
-			goto end;
-		}
-		
-		mbr_part_t *partition = mbr_alloc_partition();
-		if (partition == NULL) {
-			rc = ENOMEM;
-			goto end;
-		}
-		
-		decode_part(&ebr->pte[0], partition, addr);
-		mbr_set_flag(partition, ST_LOGIC, true);
-		partition->ebr = ebr;
-		partition->ebr_addr = addr;
-		
-		rc = mbr_add_partition(label, partition);
-		if (rc != ERR_OK)
-			goto end;
-		
-		addr = uint32_t_le2host(ebr->pte[1].first_lba) + base;
-	}
-	
-	rc = EOK;
-	
-end:
-	// FIXME possible memory leaks
-	block_fini(label->device);
-	
-	return rc;
-}
-
-/** Encode partition entry */
-static void encode_part(mbr_part_t *src, pt_entry_t *entry, uint32_t base,
-    bool ebr)
-{
-	if (src != NULL) {
-		entry->status = (uint8_t) src->status & 0xff;
-		
-		/* Ignore CHS */
-		entry->first_chs[0] = 0xfe;
-		entry->first_chs[1] = 0xff;
-		entry->first_chs[2] = 0xff;
-		entry->last_chs[0] = 0xfe;
-		entry->last_chs[1] = 0xff;
-		entry->last_chs[2] = 0xff;
-		
-		if (ebr) {
-			/* Encode reference to EBR */
-			entry->ptype = PT_EXTENDED_LBA;
-			entry->first_lba = host2uint32_t_le(src->ebr_addr - base);
-			entry->length = host2uint32_t_le(src->length + src->start_addr -
-			    src->ebr_addr);
-		} else {
-			/* Encode reference to partition */
-			entry->ptype = src->type;
-			entry->first_lba = host2uint32_t_le(src->start_addr - base);
-			entry->length = host2uint32_t_le(src->length);
-		}
-		
-		if (entry->ptype == PT_UNUSED)
-			memset(entry, 0, sizeof(pt_entry_t));
-	} else
-		memset(entry, 0, sizeof(pt_entry_t));
-}
-
-/** Check whether two partitions overlap */
-static bool check_overlap(mbr_part_t *part1, mbr_part_t *part2)
-{
-	if ((part1->start_addr < part2->start_addr) &&
-	    (part1->start_addr + part1->length <= part2->start_addr))
-		return false;
-	
-	if ((part1->start_addr > part2->start_addr) &&
-	    (part2->start_addr + part2->length <= part1->start_addr))
-		return false;
-	
-	return true;
-}
-
-/** Check whether one partition encapsulates the other */
-static bool check_encaps(mbr_part_t *inner, mbr_part_t *outer)
-{
-	if ((inner->start_addr <= outer->start_addr) ||
-	    (outer->start_addr + outer->length <= inner->start_addr))
-		return false;
-	
-	if (outer->start_addr + outer->length < inner->start_addr + inner->length)
-		return false;
-	
-	return true;
-}
-
-/** Check whether one partition preceeds the other */
-static bool check_preceeds(mbr_part_t *preceeder, mbr_part_t *precedee)
-{
-	return preceeder->start_addr < precedee->start_addr;
-}
-
-mbr_err_val mbr_add_primary(mbr_label_t *label, mbr_part_t *part)
-{
-	if (label->parts->n_primary == 4)
-		return ERR_PRIMARY_FULL;
-	
-	/* Check if partition makes space for MBR itself */
-	if (part->start_addr == 0)
-		return ERR_OUT_BOUNDS;
-	
-	/* If it is an extended partition, is there any other one? */
-	if (((part->type == PT_EXTENDED) || (part->type == PT_EXTENDED_LBA)) &&
-	    (label->parts->l_extended != NULL))
-		return ERR_EXTENDED_PRESENT;
-	
-	/* Find a place and add it */
-	mbr_part_t *iter;
-	mbr_part_t *empty = NULL;
-	mbr_part_foreach(label, iter) {
-		if (iter->type == PT_UNUSED) {
-			if (empty == NULL)
-				empty = iter;
-		} else if (check_overlap(part, iter))
-			return ERR_OVERLAP;
-	}
-	
-	list_insert_after(&part->link, &empty->link);
-	list_remove(&empty->link);
-	free(empty);
-	
-	label->parts->n_primary++;
-	
-	if ((part->type == PT_EXTENDED) || (part->type == PT_EXTENDED_LBA))
-		label->parts->l_extended = &part->link;
-	
-	return EOK;
-}
-
-mbr_err_val mbr_add_logical(mbr_label_t *label, mbr_part_t *part)
-{
-	/* Is there any extended partition? */
-	if (label->parts->l_extended == NULL)
-		return ERR_NO_EXTENDED;
-	
-	/* Is the logical partition inside the extended partition? */
-	mbr_part_t *extended = list_get_instance(label->parts->l_extended, mbr_part_t, link);
-	if (!check_encaps(part, extended))
-		return ERR_OUT_BOUNDS;
-	
-	/* Find a place for the new partition in a sorted linked list */
-	bool first_logical = true;
-	mbr_part_t *iter;
-	mbr_part_foreach (label, iter) {
-		if (mbr_get_flag(iter, ST_LOGIC)) {
-			if (check_overlap(part, iter))
-				return ERR_OVERLAP;
-			
-			if (check_preceeds(iter, part)) {
-				/* Check if there is at least one sector of space preceeding */
-				if ((iter->start_addr + iter->length) >= part->start_addr - 1)
-					return ERR_NO_EBR;
-			} else if (first_logical) {
-				/*
-				 * First logical partition's EBR is before every other
-				 * logical partition. Thus we do not check if this partition
-				 * leaves enough space for it.
-				 */
-				first_logical = false;
-			} else {
-				/*
-				 * Check if there is at least one sector of space following
-				 * (for following partitions's EBR).
-				 */
-				if ((part->start_addr + part->length) >= iter->start_addr - 1)
-					return ERR_NO_EBR;
-			}
-		}
-	}
-	
-	/* Allocate EBR if it is not already there */
-	if (part->ebr == NULL) {
-		part->ebr = alloc_br();
-		if (part->ebr == NULL)
-			return ERR_NOMEM;
-	}
-	
-	list_append(&part->link, &label->parts->list);
-	label->parts->n_logical++;
-	
-	return EOK;
-}
Index: pace/lib/mbr/libmbr.h
===================================================================
--- uspace/lib/mbr/libmbr.h	(revision cffa82aac31c77f5d26f954922753c58edfef5f7)
+++ 	(revision )
@@ -1,158 +1,0 @@
-/*
- * Copyright (c) 2009 Jiri Svoboda
- * Copyright (c) 2011-2013 Dominik Taborsky
- * 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 libmbr
- * @{
- */
-/** @file
- */
-
-#ifndef LIBMBR_LIBMBR_H_
-#define LIBMBR_LIBMBR_H_
-
-#include <adt/list.h>
-#include <loc.h>
-#include <sys/types.h>
-#include "mbr.h"
-
-/*
- * WARNING: When changing both header and partitions, write first header,
- * then partitions. The MBR headers' raw_data is not updated to follow
- * partition changes.
- *
- * NOTE: Writing partitions writes the complete header as well.
- */
-
-typedef enum {
-	/** Other flags unknown - saving previous state */
-	/** Bootability */
-	ST_BOOT = 7,
-	/** Logical partition, 0 = primary, 1 = logical*/
-	ST_LOGIC = 8
-} mbr_flags_t;
-
-typedef enum {
-	/** No error */
-	ERR_OK = 0,
-	/** All primary partitions already present */
-	ERR_PRIMARY_FULL,
-	/** Extended partition already present */
-	ERR_EXTENDED_PRESENT,
-	/** No extended partition present */
-	ERR_NO_EXTENDED,
-	/** Partition overlapping */
-	ERR_OVERLAP,
-	/** Partition out of bounds */
-	ERR_OUT_BOUNDS,
-	/** No space left for EBR */
-	ERR_NO_EBR,
-	/** Out of memory */
-	ERR_NOMEM,
-	/** Libblock error */
-	ERR_LIBBLOCK,
-} mbr_err_val;
-
-/** MBR header */
-typedef struct {
-	/** Raw access to data */
-	br_block_t raw_data;
-} mbr_t;
-
-/** Partition */
-typedef struct mbr_part {
-	/** The link in the doubly-linked list */
-	link_t link;
-	/** Partition type */
-	uint8_t type;
-	/** Flags */
-	uint16_t status;
-	/** Address of first block */
-	uint32_t start_addr;
-	/** Number of blocks */
-	uint32_t length;
-	/** Points to Extended Boot Record of logical partition */
-	br_block_t *ebr;
-	/** EBR address */
-	uint32_t ebr_addr;
-} mbr_part_t;
-
-/** Partition list structure */
-typedef struct mbr_parts {
-	/** Number of primary partitions */
-	unsigned char n_primary;
-	/** Index to the extended partition in the array */
-	link_t *l_extended;
-	/** Number of logical partitions */
-	unsigned int n_logical;
-	/** Logical partition linked list */
-	list_t list;
-} mbr_partitions_t;
-
-/** Both header and partition list */
-typedef struct mbr_label {
-	/** MBR header */
-	mbr_t *mbr;
-	/** Partition list */
-	mbr_partitions_t * parts;
-	/** Device where the data are from (or for) */
-	service_id_t device;
-} mbr_label_t;
-
-#define mbr_part_foreach(label, iterator) \
-	for (iterator = list_get_instance((label)->parts->list.head.next, mbr_part_t, link); \
-	    iterator != list_get_instance(&((label)->parts->list.head), mbr_part_t, link); \
-	    iterator = list_get_instance(iterator->link.next, mbr_part_t, link))
-
-extern mbr_label_t *mbr_alloc_label(void);
-
-extern void mbr_set_device(mbr_label_t *, service_id_t);
-extern mbr_t *mbr_alloc_mbr(void);
-extern int mbr_read_mbr(mbr_label_t *, service_id_t);
-extern int mbr_write_mbr(mbr_label_t *, service_id_t);
-extern int mbr_is_mbr(mbr_label_t *);
-
-extern int mbr_read_partitions(mbr_label_t *);
-extern int mbr_write_partitions(mbr_label_t *, service_id_t);
-extern mbr_part_t *mbr_alloc_partition(void);
-extern mbr_partitions_t *mbr_alloc_partitions(void);
-extern mbr_err_val mbr_add_partition(mbr_label_t *, mbr_part_t *);
-extern int mbr_remove_partition(mbr_label_t *, size_t);
-extern int mbr_get_flag(mbr_part_t *, mbr_flags_t);
-extern void mbr_set_flag(mbr_part_t *, mbr_flags_t, bool);
-extern uint32_t mbr_get_next_aligned(uint32_t, unsigned int);
-extern list_t *mbr_get_list(mbr_label_t *);
-extern mbr_part_t *mbr_get_first_partition(mbr_label_t *);
-extern mbr_part_t *mbr_get_next_partition(mbr_label_t *, mbr_part_t *);
-
-extern void mbr_free_label(mbr_label_t *);
-extern void mbr_free_mbr(mbr_t *);
-extern void mbr_free_partition(mbr_part_t *);
-extern void mbr_free_partitions(mbr_partitions_t *);
-
-#endif
Index: pace/lib/mbr/mbr.h
===================================================================
--- uspace/lib/mbr/mbr.h	(revision cffa82aac31c77f5d26f954922753c58edfef5f7)
+++ 	(revision )
@@ -1,98 +1,0 @@
-/*
- * Copyright (c) 2009 Jiri Svoboda
- * Copyright (c) 2011-2013 Dominik Taborsky
- * 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 libmbr
- * @{
- */
-/** @file
- */
-
-#ifndef LIBMBR_MBR_H_
-#define LIBMBR_MBR_H_
-
-#include <sys/types.h>
-
-enum {
-	/** Number of primary partition records */
-	N_PRIMARY = 4,
-	
-	/** Boot record signature */
-	BR_SIGNATURE = 0xAA55
-};
-
-enum {
-	/** Non-bootable */
-	B_INACTIVE = 0x00,
-	/** Bootable */
-	B_ACTIVE = 0x80,
-	/** Anything else means invalid */
-};
-
-enum {
-	/** Unused partition entry */
-	PT_UNUSED = 0x00,
-	/** Extended partition */
-	PT_EXTENDED = 0x05,
-	/** Extended partition with LBA */
-	PT_EXTENDED_LBA = 0x0F,
-	/** GPT Protective partition */
-	PT_GPT = 0xEE,
-};
-
-/** Structure of a partition table entry */
-typedef struct {
-	uint8_t status;
-	/** CHS of fist block in partition */
-	uint8_t first_chs[3];
-	/** Partition type */
-	uint8_t ptype;
-	/** CHS of last block in partition */
-	uint8_t last_chs[3];
-	/** LBA of first block in partition */
-	uint32_t first_lba;
-	/** Number of blocks in partition */
-	uint32_t length;
-} __attribute__((packed)) pt_entry_t;
-
-/** Structure of a boot-record block */
-typedef struct {
-	/** Area for boot code */
-	uint8_t code_area[440];
-	/** Optional media ID */
-	uint32_t media_id;
-	/** Padding */
-	uint16_t pad0;
-	/** Partition table entries */
-	pt_entry_t pte[N_PRIMARY];
-	/** Boot record block signature (@c BR_SIGNATURE) */
-	uint16_t signature;
-} __attribute__((packed)) br_block_t;
-
-#endif
-
Index: pace/srv/bd/part/guid_part/Makefile
===================================================================
--- uspace/srv/bd/part/guid_part/Makefile	(revision cffa82aac31c77f5d26f954922753c58edfef5f7)
+++ 	(revision )
@@ -1,39 +1,0 @@
-#
-# Copyright (c) 2010 Jiri Svoboda
-# 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
-EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX) -I$(LIBLABEL_PREFIX)/include
-
-# Correct name is 'guid_part' but must use this because of FAT 8.3 names.
-BINARY = g_part
-
-SOURCES = \
-	guid_part.c
-
-include $(USPACE_PREFIX)/Makefile.common
Index: pace/srv/bd/part/guid_part/guid_part.c
===================================================================
--- uspace/srv/bd/part/guid_part/guid_part.c	(revision cffa82aac31c77f5d26f954922753c58edfef5f7)
+++ 	(revision )
@@ -1,435 +1,0 @@
-/*
- * Copyright (c) 2010 Jiri Svoboda
- * 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 bd
- * @{
- */
-
-/**
- * @file
- * @brief GUID partition table driver
- *
- * Handles the GUID partitioning scheme. Uses a block device
- * and provides one for each partition.
- *
- * References:
- *	UEFI Specification Version 2.3, Chapter 5 GUID Partition Table (GPT)
- *	Format, http://www.uefi.org/specs/
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <async.h>
-#include <as.h>
-#include <bd_srv.h>
-#include <fibril_synch.h>
-#include <loc.h>
-#include <sys/types.h>
-#include <sys/typefmt.h>
-#include <inttypes.h>
-#include <block.h>
-#include <loc.h>
-#include <errno.h>
-#include <stdbool.h>
-#include <byteorder.h>
-#include <assert.h>
-#include <macros.h>
-#include <task.h>
-
-#include <std/gpt.h>
-
-#define NAME "guid_part"
-
-const uint8_t efi_signature[8] = {
-	/* "EFI PART" in ASCII */
-	0x45, 0x46, 0x49, 0x20, 0x50, 0x41, 0x52, 0x54
-};
-
-/** Partition */
-typedef struct part {
-	/** Partition entry is in use */
-	bool present;
-	/** Address of first block */
-	aoff64_t start_addr;
-	/** Number of blocks */
-	aoff64_t length;
-	/** Service representing the partition (outbound device) */
-	service_id_t dsid;
-	/** Block device service structure */
-	bd_srvs_t bds;
-	/** Points to next partition structure. */
-	struct part *next;
-} part_t;
-
-static size_t block_size;
-
-/** Partitioned device (inbound device) */
-static service_id_t indev_sid;
-
-/** List of partitions. This structure is an empty head. */
-static part_t plist_head;
-
-static int gpt_init(const char *dev_name);
-static int gpt_read(void);
-static part_t *gpt_part_new(void);
-static void gpt_pte_to_part(const gpt_entry_t *pte, part_t *part);
-static void gpt_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg);
-static int gpt_bsa_translate(part_t *p, aoff64_t ba, size_t cnt, aoff64_t *gba);
-
-static int gpt_bd_open(bd_srvs_t *, bd_srv_t *);
-static int gpt_bd_close(bd_srv_t *);
-static int gpt_bd_read_blocks(bd_srv_t *, aoff64_t, size_t, void *, size_t);
-static int gpt_bd_write_blocks(bd_srv_t *, aoff64_t, size_t, const void *, size_t);
-static int gpt_bd_get_block_size(bd_srv_t *, size_t *);
-static int gpt_bd_get_num_blocks(bd_srv_t *, aoff64_t *);
-
-static bd_ops_t gpt_bd_ops = {
-	.open = gpt_bd_open,
-	.close = gpt_bd_close,
-	.read_blocks = gpt_bd_read_blocks,
-	.write_blocks = gpt_bd_write_blocks,
-	.get_block_size = gpt_bd_get_block_size,
-	.get_num_blocks = gpt_bd_get_num_blocks
-};
-
-static part_t *bd_srv_part(bd_srv_t *bd)
-{
-	return (part_t *)bd->srvs->sarg;
-}
-
-int main(int argc, char **argv)
-{
-	printf(NAME ": GUID partition table driver\n");
-
-	if (argc != 2) {
-		printf("Expected one argument (device name).\n");
-		return -1;
-	}
-
-	if (gpt_init(argv[1]) != EOK)
-		return -1;
-
-	printf(NAME ": Accepting connections\n");
-	task_retval(0);
-	async_manager();
-
-	/* Not reached */
-	return 0;
-}
-
-static int gpt_init(const char *dev_name)
-{
-	int rc;
-	int i;
-	char *name;
-	service_id_t dsid;
-	uint64_t size_mb;
-	part_t *part;
-
-	rc = loc_service_get_id(dev_name, &indev_sid, 0);
-	if (rc != EOK) {
-		printf(NAME ": could not resolve device `%s'.\n", dev_name);
-		return rc;
-	}
-
-	rc = block_init(indev_sid, 2048);
-	if (rc != EOK)  {
-		printf(NAME ": could not init libblock.\n");
-		return rc;
-	}
-
-	/* Determine and verify block size. */
-
-	rc = block_get_bsize(indev_sid, &block_size);
-	if (rc != EOK) {
-		printf(NAME ": error getting block size.\n");
-		return rc;
-	}
-
-	if (block_size < 512 || (block_size % 512) != 0) {
-		printf(NAME ": invalid block size %zu.\n", block_size);
-		return ENOTSUP;
-	}
-
-	/* Read in partition records. */
-	rc = gpt_read();
-	if (rc != EOK)
-		return rc;
-
-	/* Register server with location service. */
-	async_set_fallback_port_handler(gpt_connection, NULL);
-	rc = loc_server_register(NAME);
-	if (rc != EOK) {
-		printf(NAME ": Unable to register server.\n");
-		return rc;
-	}
-	
-	/*
-	 * Create partition devices.
-	 */
-	i = 0;
-	part = plist_head.next;
-
-	while (part != NULL) {
-		/* Skip absent partitions. */
-		if (!part->present) {
-			part = part->next;
-			++i;
-			continue;
-		}
-
-		asprintf(&name, "%sp%d", dev_name, i);
-		if (name == NULL)
-			return ENOMEM;
-
-		rc = loc_service_register(name, &dsid);
-		if (rc != EOK) {
-			printf(NAME ": Unable to register service %s.\n", name);
-			return rc;
-		}
-
-		size_mb = (part->length * block_size + 1024 * 1024 - 1)
-		    / (1024 * 1024);
-		printf(NAME ": Registered device %s: %" PRIu64 " blocks "
-		    "%" PRIuOFF64 " MB.\n", name, part->length, size_mb);
-
-		part->dsid = dsid;
-		free(name);
-
-		part = part->next;
-		++i;
-	}
-
-	return EOK;
-}
-
-/** Read in partition records. */
-static int gpt_read(void)
-{
-	int i, rc;
-	gpt_header_t *gpt_hdr;
-	gpt_entry_t *etable;
-	uint64_t ba;
-	uint32_t bcnt;
-	uint32_t esize;
-	uint32_t num_entries;
-	uint32_t entry;
-	part_t *prev, *p;
-
-	gpt_hdr = malloc(block_size);
-	if (gpt_hdr == NULL) {
-		printf(NAME ": Failed allocating memory.\n");
-		return ENOMEM;
-	}
-
-	rc = block_read_direct(indev_sid, gpt_hdr_ba, 1, gpt_hdr);
-	if (rc != EOK) {
-		printf(NAME ": Failed reading GPT header block.\n");
-		return rc;
-	}
-
-	for (i = 0; i < 8; ++i) {
-		if (gpt_hdr->efi_signature[i] != efi_signature[i]) {
-			printf(NAME ": Invalid GPT signature.\n");
-			return EINVAL;
-		}
-	}
-
-	plist_head.next = NULL;
-	prev = &plist_head;
-
-	num_entries = uint32_t_le2host(gpt_hdr->num_entries);
-	ba = uint64_t_le2host(gpt_hdr->entry_lba);
-	esize = uint32_t_le2host(gpt_hdr->entry_size);
-	bcnt = (num_entries / esize) + ((num_entries % esize != 0) ? 1 : 0);
-
-	etable = malloc(num_entries * esize);
-	if (etable == NULL) {
-		free(gpt_hdr);
-		printf(NAME ": Failed allocating memory.\n");
-		return ENOMEM;
-	}
-
-	rc = block_read_direct(indev_sid, ba, bcnt, etable);
-	if (rc != EOK) {
-		printf(NAME ": Failed reading GPT entries.\n");
-		return rc;
-	}
-
-	for (entry = 0; entry < num_entries; ++entry) {
-		p = gpt_part_new();
-		if (p == NULL)
-			return ENOMEM;
-
-		gpt_pte_to_part(&etable[entry], p);
-		prev->next = p;
-		prev = p;
-	}
-
-	free(etable);
-
-	return EOK;
-}
-
-/** Allocate a new @c part_t structure. */
-static part_t *gpt_part_new(void)
-{
-	return malloc(sizeof(part_t));
-}
-
-/** Parse partition table entry. */
-static void gpt_pte_to_part(const gpt_entry_t *pte, part_t *part)
-{
-	uint64_t sa, len;
-	int i;
-
-	/* Partition spans addresses [start_lba, end_lba] (inclusive). */
-	sa = uint64_t_le2host(pte->start_lba);
-	len = uint64_t_le2host(pte->end_lba) + 1 - sa;
-
-	part->start_addr = sa;
-	part->length     = len;
-
-	part->present = false;
-
-	for (i = 0; i < 8; ++i) {
-		if (pte->part_type[i] != 0x00)
-			part->present = true;
-	}
-
-	bd_srvs_init(&part->bds);
-	part->bds.ops = &gpt_bd_ops;
-	part->bds.sarg = part;
-
-	part->dsid = 0;
-	part->next = NULL;
-}
-
-static void gpt_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
-{
-	service_id_t dh;
-	part_t *part;
-
-	/* Get the device handle. */
-	dh = IPC_GET_ARG2(*icall);
-
-	/*
-	 * Determine which partition device is the client connecting to.
-	 * A linear search is not terribly fast, but we only do this
-	 * once for each connection.
-	 */
-	part = plist_head.next;
-	while (part != NULL && part->dsid != dh)
-		part = part->next;
-
-	if (part == NULL) {
-		async_answer_0(iid, EINVAL);
-		return;
-	}
-
-	assert(part->present == true);
-
-	bd_conn(iid, icall, &part->bds);
-}
-
-/** Open device. */
-static int gpt_bd_open(bd_srvs_t *bds, bd_srv_t *bd)
-{
-	return EOK;
-}
-
-/** Close device. */
-static int gpt_bd_close(bd_srv_t *bd)
-{
-	return EOK;
-}
-
-/** Read blocks from partition. */
-static int gpt_bd_read_blocks(bd_srv_t *bd, aoff64_t ba, size_t cnt, void *buf,
-    size_t size)
-{
-	part_t *p = bd_srv_part(bd);
-	aoff64_t gba;
-
-	if (cnt * block_size < size)
-		return EINVAL;
-
-	if (gpt_bsa_translate(p, ba, cnt, &gba) != EOK)
-		return ELIMIT;
-
-	return block_read_direct(indev_sid, gba, cnt, buf);
-}
-
-/** Write blocks to partition. */
-static int gpt_bd_write_blocks(bd_srv_t *bd, aoff64_t ba, size_t cnt,
-    const void *buf, size_t size)
-{
-	part_t *p = bd_srv_part(bd);
-	aoff64_t gba;
-
-	if (cnt * block_size < size)
-		return EINVAL;
-
-	if (gpt_bsa_translate(p, ba, cnt, &gba) != EOK)
-		return ELIMIT;
-
-	return block_write_direct(indev_sid, gba, cnt, buf);
-}
-
-/** Get device block size. */
-static int gpt_bd_get_block_size(bd_srv_t *bd, size_t *rsize)
-{
-	*rsize = block_size;
-	return EOK;
-}
-
-/** Get number of blocks on device. */
-static int gpt_bd_get_num_blocks(bd_srv_t *bd, aoff64_t *rnb)
-{
-	part_t *part = bd_srv_part(bd);
-
-	*rnb = part->length;
-	return EOK;
-}
-
-
-/** Translate block segment address with range checking. */
-static int gpt_bsa_translate(part_t *p, aoff64_t ba, size_t cnt, aoff64_t *gba)
-{
-	if (ba + cnt > p->length)
-		return ELIMIT;
-
-	*gba = p->start_addr + ba;
-	return EOK;
-}
-
-/**
- * @}
- */
Index: pace/srv/bd/part/mbr_part/Makefile
===================================================================
--- uspace/srv/bd/part/mbr_part/Makefile	(revision cffa82aac31c77f5d26f954922753c58edfef5f7)
+++ 	(revision )
@@ -1,38 +1,0 @@
-#
-# Copyright (c) 2005 Martin Decky
-# Copyright (c) 2007 Jakub Jermar
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-USPACE_PREFIX = ../../../..
-LIBS = $(LIBBLOCK_PREFIX)/libblock.a
-EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX)
-BINARY = mbr_part
-
-SOURCES = \
-	mbr_part.c
-
-include $(USPACE_PREFIX)/Makefile.common
Index: pace/srv/bd/part/mbr_part/mbr_part.c
===================================================================
--- uspace/srv/bd/part/mbr_part/mbr_part.c	(revision cffa82aac31c77f5d26f954922753c58edfef5f7)
+++ 	(revision )
@@ -1,510 +1,0 @@
-/*
- * Copyright (c) 2009 Jiri Svoboda
- * 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 bd
- * @{
- */
-
-/**
- * @file
- * @brief PC MBR partition driver
- *
- * Handles the PC MBR partitioning scheme. Uses a block device
- * and provides one for each partition.
- *
- * Limitations:
- * 
- * Only works with boot records using LBA. CHS-only records are not
- * supported.
- *
- * Referemces:
- *
- * The source of MBR structures for this driver have been the following
- * Wikipedia articles:
- *	- http://en.wikipedia.org/wiki/Master_Boot_Record
- *	- http://en.wikipedia.org/wiki/Extended_boot_record
- *
- * The fact that the extended partition has type 0x05 is pure observation.
- * (TODO: can it have any other type number?)
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <async.h>
-#include <as.h>
-#include <bd_srv.h>
-#include <fibril_synch.h>
-#include <loc.h>
-#include <sys/types.h>
-#include <sys/typefmt.h>
-#include <inttypes.h>
-#include <block.h>
-#include <errno.h>
-#include <stdbool.h>
-#include <byteorder.h>
-#include <assert.h>
-#include <macros.h>
-#include <task.h>
-
-#define NAME "mbr_part"
-
-enum {
-	/** Number of primary partition records */
-	N_PRIMARY	= 4,
-
-	/** Boot record signature */
-	BR_SIGNATURE	= 0xAA55
-};
-
-enum ptype {
-	/** Unused partition entry */
-	PT_UNUSED	= 0x00,
-	/** Extended partition */
-	PT_EXTENDED	= 0x05,
-};
-
-/** Partition */
-typedef struct part {
-	/** Primary partition entry is in use */
-	bool present;
-	/** Address of first block */
-	aoff64_t start_addr;
-	/** Number of blocks */
-	aoff64_t length;
-	/** Device representing the partition (outbound device) */
-	service_id_t dsid;
-	/** Block device service sturcture */
-	bd_srvs_t bds;
-	/** Points to next partition structure. */
-	struct part *next;
-} part_t;
-
-/** Structure of a partition table entry */
-typedef struct {
-	uint8_t status;
-	/** CHS of fist block in partition */
-	uint8_t first_chs[3];
-	/** Partition type */
-	uint8_t ptype;
-	/** CHS of last block in partition */
-	uint8_t last_chs[3];
-	/** LBA of first block in partition */
-	uint32_t first_lba;
-	/** Number of blocks in partition */
-	uint32_t length;
-} __attribute__((packed)) pt_entry_t;
-
-/** Structure of a boot-record block */
-typedef struct {
-	/* Area for boot code */
-	uint8_t code_area[440];
-
-	/* Optional media ID */
-	uint32_t media_id;
-
-	uint16_t pad0;
-
-	/** Partition table entries */
-	pt_entry_t pte[N_PRIMARY];
-
-	/** Boot record block signature (@c BR_SIGNATURE) */
-	uint16_t signature;
-} __attribute__((packed)) br_block_t;
-
-
-static size_t block_size;
-
-/** Partitioned device (inbound device) */
-static service_id_t indev_sid;
-
-/** List of partitions. This structure is an empty head. */
-static part_t plist_head;
-
-static int mbr_init(const char *dev_name);
-static int mbr_part_read(void);
-static part_t *mbr_part_new(void);
-static void mbr_pte_to_part(uint32_t base, const pt_entry_t *pte, part_t *part);
-static void mbr_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg);
-static int mbr_bsa_translate(part_t *p, uint64_t ba, size_t cnt, uint64_t *gba);
-
-static int mbr_bd_open(bd_srvs_t *, bd_srv_t *);
-static int mbr_bd_close(bd_srv_t *);
-static int mbr_bd_read_blocks(bd_srv_t *, aoff64_t, size_t, void *, size_t);
-static int mbr_bd_write_blocks(bd_srv_t *, aoff64_t, size_t, const void *, size_t);
-static int mbr_bd_get_block_size(bd_srv_t *, size_t *);
-static int mbr_bd_get_num_blocks(bd_srv_t *, aoff64_t *);
-
-static bd_ops_t mbr_bd_ops = {
-	.open = mbr_bd_open,
-	.close = mbr_bd_close,
-	.read_blocks = mbr_bd_read_blocks,
-	.write_blocks = mbr_bd_write_blocks,
-	.get_block_size = mbr_bd_get_block_size,
-	.get_num_blocks = mbr_bd_get_num_blocks
-};
-
-static part_t *bd_srv_part(bd_srv_t *bd)
-{
-	return (part_t *)bd->srvs->sarg;
-}
-
-int main(int argc, char **argv)
-{
-	printf(NAME ": PC MBR partition driver\n");
-
-	if (argc != 2) {
-		printf("Expected one argument (device name).\n");
-		return -1;
-	}
-
-	if (mbr_init(argv[1]) != EOK)
-		return -1;
-
-	printf(NAME ": Accepting connections\n");
-	task_retval(0);
-	async_manager();
-
-	/* Not reached */
-	return 0;
-}
-
-static int mbr_init(const char *dev_name)
-{
-	int rc;
-	int i;
-	char *name;
-	service_id_t dsid;
-	uint64_t size_mb;
-	part_t *part;
-
-	rc = loc_service_get_id(dev_name, &indev_sid, 0);
-	if (rc != EOK) {
-		printf(NAME ": could not resolve device `%s'.\n", dev_name);
-		return rc;
-	}
-
-	rc = block_init(indev_sid, 2048);
-	if (rc != EOK)  {
-		printf(NAME ": could not init libblock.\n");
-		return rc;
-	}
-
-	/* Determine and verify block size. */
-
-	rc = block_get_bsize(indev_sid, &block_size);
-	if (rc != EOK) {
-		printf(NAME ": error getting block size.\n");
-		return rc;
-	}
-
-	if (block_size < 512 || (block_size % 512) != 0) {
-		printf(NAME ": invalid block size %zu.\n", block_size);
-		return ENOTSUP;
-	}
-
-	/* Read in partition records. */
-	rc = mbr_part_read();
-	if (rc != EOK)
-		return rc;
-
-	/* Register server with location service. */
-	async_set_fallback_port_handler(mbr_connection, NULL);
-	rc = loc_server_register(NAME);
-	if (rc != EOK) {
-		printf(NAME ": Unable to register server.\n");
-		return rc;
-	}
-
-	/*
-	 * Create partition devices.
-	 */
-	i = 0;
-	part = plist_head.next;
-
-	while (part != NULL) {
-		/* Skip absent partitions. */
-		if (!part->present) {
-			part = part->next;
-			++i;
-			continue;
-		}
-
-		asprintf(&name, "%sp%d", dev_name, i);
-		if (name == NULL)
-			return ENOMEM;
-
-		rc = loc_service_register(name, &dsid);
-		if (rc != EOK) {
-			printf(NAME ": Unable to register service %s.\n", name);
-			return rc;
-		}
-
-		size_mb = (part->length * block_size + 1024 * 1024 - 1)
-		    / (1024 * 1024);
-		printf(NAME ": Registered device %s: %" PRIuOFF64 " blocks "
-		    "%" PRIu64 " MB.\n", name, part->length, size_mb);
-
-		part->dsid = dsid;
-		free(name);
-
-		part = part->next;
-		++i;
-	}
-
-	return EOK;
-}
-
-/** Read in partition records. */
-static int mbr_part_read(void)
-{
-	int i, rc;
-	br_block_t *brb;
-	uint16_t sgn;
-	uint32_t ba;
-	part_t *ext_part, cp;
-	uint32_t base;
-	part_t *prev, *p;
-
-	brb = malloc(sizeof(br_block_t));
-	if (brb == NULL) {
-		printf(NAME ": Failed allocating memory.\n");
-		return ENOMEM;
-	}
-
-	/*
-	 * Read primary partition entries.
-	 */
-
-	rc = block_read_direct(indev_sid, 0, 1, brb);
-	if (rc != EOK) {
-		printf(NAME ": Failed reading MBR block.\n");
-		return rc;
-	}
-
-	sgn = uint16_t_le2host(brb->signature);
-	if (sgn != BR_SIGNATURE) {
-		printf(NAME ": Invalid boot record signature 0x%04" PRIX16
-		    ".\n", sgn);
-		return EINVAL;
-	}
-
-	ext_part = NULL;
-	plist_head.next = NULL;
-	prev = &plist_head;
-
-	for (i = 0; i < N_PRIMARY; ++i) {
-		p = mbr_part_new();
-		if (p == NULL)
-			return ENOMEM;
-
-		mbr_pte_to_part(0, &brb->pte[i], p);
-		prev->next = p;
-		prev = p;
-
-		if (brb->pte[i].ptype == PT_EXTENDED) {
-			p->present = false;
-			ext_part = p;
-		}
-	}
-
-	if (ext_part == NULL)
-		return EOK;
-
-	printf("Extended partition found.\n");
-
-	/*
-	 * Read extended partition entries.
-	 */
-
-	cp.start_addr = ext_part->start_addr;
-	cp.length = ext_part->length;
-	base = ext_part->start_addr;
-
-	do {
-		/*
-		 * Addressing in the EBR chain is relative to the beginning
-		 * of the extended partition.
-		 */
-		ba = cp.start_addr;
-		rc = block_read_direct(indev_sid, ba, 1, brb);
-		if (rc != EOK) {
-			printf(NAME ": Failed reading EBR block at %"
-			    PRIu32 ".\n", ba);
-			return rc;
-		}
-
-		sgn = uint16_t_le2host(brb->signature);
-		if (sgn != BR_SIGNATURE) {
-			printf(NAME ": Invalid boot record signature 0x%04"
-			    PRIX16 " in EBR at %" PRIu32 ".\n", sgn, ba);
-			return EINVAL;
-		}
-
-		p = mbr_part_new();
-		if (p == NULL)
-			return ENOMEM;
-
-		/* First PTE is the logical partition itself. */
-		mbr_pte_to_part(base, &brb->pte[0], p);
-		prev->next = p;
-		prev = p;
-
-		/* Second PTE describes next chain element. */
-		mbr_pte_to_part(base, &brb->pte[1], &cp);
-	} while (cp.present);
-
-	return EOK;
-}
-
-/** Allocate a new @c part_t structure. */
-static part_t *mbr_part_new(void)
-{
-	return malloc(sizeof(part_t));
-}
-
-/** Parse partition table entry. */
-static void mbr_pte_to_part(uint32_t base, const pt_entry_t *pte, part_t *part)
-{
-	uint32_t sa, len;
-
-	sa = uint32_t_le2host(pte->first_lba);
-	len = uint32_t_le2host(pte->length);
-
-	part->start_addr = base + sa;
-	part->length     = len;
-
-	part->present = (pte->ptype != PT_UNUSED) ? true : false;
-
-	bd_srvs_init(&part->bds);
-	part->bds.ops = &mbr_bd_ops;
-	part->bds.sarg = part;
-
-	part->dsid = 0;
-	part->next = NULL;
-}
-
-static void mbr_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
-{
-	service_id_t dh;
-	part_t *part;
-
-	/* Get the device handle. */
-	dh = IPC_GET_ARG2(*icall);
-
-	/*
-	 * Determine which partition device is the client connecting to.
-	 * A linear search is not terribly fast, but we only do this
-	 * once for each connection.
-	 */
-	part = plist_head.next;
-	while (part != NULL && part->dsid != dh)
-		part = part->next;
-
-	if (part == NULL) {
-		async_answer_0(iid, EINVAL);
-		return;
-	}
-
-	assert(part->present == true);
-	bd_conn(iid, icall, &part->bds);
-}
-
-/** Open device. */
-static int mbr_bd_open(bd_srvs_t *bds, bd_srv_t *bd)
-{
-	return EOK;
-}
-
-/** Close device. */
-static int mbr_bd_close(bd_srv_t *bd)
-{
-	return EOK;
-}
-
-/** Read blocks from partition. */
-static int mbr_bd_read_blocks(bd_srv_t *bd, aoff64_t ba, size_t cnt, void *buf,
-    size_t size)
-{
-	part_t *p = bd_srv_part(bd);
-	aoff64_t gba;
-
-	if (cnt * block_size < size)
-		return EINVAL;
-
-	if (mbr_bsa_translate(p, ba, cnt, &gba) != EOK)
-		return ELIMIT;
-
-	return block_read_direct(indev_sid, gba, cnt, buf);
-}
-
-/** Write blocks to partition. */
-static int mbr_bd_write_blocks(bd_srv_t *bd, aoff64_t ba, size_t cnt,
-    const void *buf, size_t size)
-{
-	part_t *p = bd_srv_part(bd);
-	aoff64_t gba;
-
-	if (cnt * block_size < size)
-		return EINVAL;
-
-	if (mbr_bsa_translate(p, ba, cnt, &gba) != EOK)
-		return ELIMIT;
-
-	return block_write_direct(indev_sid, gba, cnt, buf);
-}
-
-/** Get device block size. */
-static int mbr_bd_get_block_size(bd_srv_t *bd, size_t *rsize)
-{
-	*rsize = block_size;
-	return EOK;
-}
-
-/** Get number of blocks on device. */
-static int mbr_bd_get_num_blocks(bd_srv_t *bd, aoff64_t *rnb)
-{
-	part_t *part = bd_srv_part(bd);
-
-	*rnb = part->length;
-	return EOK;
-}
-
-/** Translate block segment address with range checking. */
-static int mbr_bsa_translate(part_t *p, uint64_t ba, size_t cnt, uint64_t *gba)
-{
-	if (ba + cnt > p->length)
-		return ELIMIT;
-
-	*gba = p->start_addr + ba;
-	return EOK;
-}
-
-/**
- * @}
- */
