Index: uspace/app/bdsh/cmds/modules/cat/cat.c
===================================================================
--- uspace/app/bdsh/cmds/modules/cat/cat.c	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/app/bdsh/cmds/modules/cat/cat.c	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -164,5 +164,4 @@
 {
 	int fd, bytes = 0, count = 0, reads = 0;
-	off64_t total = 0;
 	char *buff = NULL;
 	int i;
@@ -174,7 +173,4 @@
 		return 1;
 	}
-
-	total = lseek(fd, 0, SEEK_END);
-	lseek(fd, 0, SEEK_SET);
 
 	if (NULL == (buff = (char *) malloc(blen + 1))) {
Index: uspace/app/bdsh/cmds/modules/ls/ls.c
===================================================================
--- uspace/app/bdsh/cmds/modules/ls/ls.c	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/app/bdsh/cmds/modules/ls/ls.c	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -38,7 +38,9 @@
 #include <dirent.h>
 #include <fcntl.h>
+#include <getopt.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <str.h>
+#include <sort.h>
 
 #include "errors.h"
@@ -46,64 +48,160 @@
 #include "util.h"
 #include "entry.h"
-#include "ls.h"
 #include "cmds.h"
 
+/* Various values that can be returned by ls_scope() */
+#define LS_BOGUS 0
+#define LS_FILE  1
+#define LS_DIR   2
+
+/** Structure to represent a directory entry.
+ *
+ * Useful to keep together important information
+ * for sorting directory entries.
+ */
+struct dir_elem_t {
+	char *name;
+	struct stat s;
+};
+
 static const char *cmdname = "ls";
 
-static void ls_scan_dir(const char *d, DIR *dirp)
-{
+static struct option const long_options[] = {
+	{ "help", no_argument, 0, 'h' },
+	{ "unsort", no_argument, 0, 'u' },
+	{ 0, 0, 0, 0 }
+};
+
+/** Print an entry.
+ *
+ * ls_print currently does nothing more than print the entry.
+ * In the future, we will likely pass the absolute path, and
+ * some sort of ls_options structure that controls how each
+ * entry is printed and what is printed about it.
+ *
+ * Now we just print basic DOS style lists.
+ *
+ * @param de		Directory element.
+ */
+static void ls_print(struct dir_elem_t *de)
+{
+	if (de->s.is_file)
+		printf("%-40s\t%llu\n", de->name, (long long) de->s.size);
+	else if (de->s.is_directory)
+		printf("%-40s\t<dir>\n", de->name);
+	else
+		printf("%-40s\n", de->name);
+}
+
+
+/** Compare 2 directory elements.
+ *
+ * It compares 2 elements of a directory : a file is considered
+ * as bigger than a directory, and if they have the same type,
+ * they are compared alphabetically.
+ *
+ * @param a		Pointer to the structure of the first element.
+ * @param b		Pointer to the structure of the second element.
+ * @param arg		Pointer for an other and optionnal argument.
+ *
+ * @return		-1 if a < b, 1 otherwise.
+ */
+static int ls_cmp(void *a, void *b, void *arg)
+{
+	struct dir_elem_t *da = a;
+	struct dir_elem_t *db = b;
+	
+	if ((da->s.is_directory && db->s.is_file) ||
+	    ((da->s.is_directory == db->s.is_directory) &&
+	    str_cmp(da->name, db->name) < 0))
+		return -1;
+	else
+		return 1;
+}
+
+/** Scan a directory.
+ *
+ * Scan the content of a directory and print it.
+ *
+ * @param d		Name of the directory.
+ * @param dirp	Directory stream.
+ * @param sort	1 if the output must be sorted,
+ *				0 otherwise.
+ */
+static void ls_scan_dir(const char *d, DIR *dirp, int sort)
+{
+	int alloc_blocks = 20;
+	int i;
+	int nbdirs = 0;
+	int rc;
+	int len;
+	char *buff;
+	struct dir_elem_t *tmp;
+	struct dir_elem_t *tosort;
 	struct dirent *dp;
-	char *buff;
-
-	if (! dirp)
+	
+	if (!dirp)
 		return;
 
-	buff = (char *)malloc(PATH_MAX);
-	if (NULL == buff) {
+	buff = (char *) malloc(PATH_MAX);
+	if (!buff) {
 		cli_error(CL_ENOMEM, "ls: failed to scan %s", d);
 		return;
 	}
-
+	
+	tosort = (struct dir_elem_t *) malloc(alloc_blocks * sizeof(*tosort));
+	if (!tosort) {
+		cli_error(CL_ENOMEM, "ls: failed to scan %s", d);
+		free(buff);
+		return;
+	}
+	
 	while ((dp = readdir(dirp))) {
-		memset(buff, 0, sizeof(buff));
-		/* Don't worry if inserting a double slash, this will be fixed by
-		 * absolutize() later with subsequent calls to open() or readdir() */
-		snprintf(buff, PATH_MAX - 1, "%s/%s", d, dp->d_name);
-		ls_print(dp->d_name, buff);
-	}
-
+		if (nbdirs + 1 > alloc_blocks) {
+			alloc_blocks += alloc_blocks;
+			
+			tmp = (struct dir_elem_t *) realloc(tosort,
+			    alloc_blocks * sizeof(struct dir_elem_t));
+			if (!tmp) {
+				cli_error(CL_ENOMEM, "ls: failed to scan %s", d);
+				goto out;
+			}
+			tosort = tmp;
+		}
+		
+		/* fill the name field */
+		tosort[nbdirs].name = (char *) malloc(str_length(dp->d_name) + 1);
+		if (!tosort[nbdirs].name) {
+			cli_error(CL_ENOMEM, "ls: failed to scan %s", d);
+			goto out;
+		}
+		
+		str_cpy(tosort[nbdirs].name, str_length(dp->d_name) + 1, dp->d_name);
+		len = snprintf(buff, PATH_MAX - 1, "%s/%s", d, tosort[nbdirs].name);
+		buff[len] = '\0';
+
+		rc = stat(buff, &tosort[nbdirs++].s);
+		if (rc != 0) {
+			printf("ls: skipping bogus node %s\n", buff);
+			printf("rc=%d\n", rc);
+			goto out;
+		}
+	}
+	
+	if (sort) {
+		if (!qsort(&tosort[0], nbdirs, sizeof(struct dir_elem_t),
+		    ls_cmp, NULL)) {
+			printf("Sorting error.\n");
+		}
+	}
+	
+	for (i = 0; i < nbdirs; i++)
+		ls_print(&tosort[i]);
+	
+out:
+	for(i = 0; i < nbdirs; i++)
+		free(tosort[i].name);
+	free(tosort);
 	free(buff);
-
-	return;
-}
-
-/* ls_print currently does nothing more than print the entry.
- * in the future, we will likely pass the absolute path, and
- * some sort of ls_options structure that controls how each
- * entry is printed and what is printed about it.
- *
- * Now we just print basic DOS style lists */
-
-static void ls_print(const char *name, const char *pathname)
-{
-	struct stat s;
-	int rc;
-
-	rc = stat(pathname, &s);
-	if (rc != 0) {
-		/* Odd chance it was deleted from the time readdir() found it */
-		printf("ls: skipping bogus node %s\n", pathname);
-		printf("rc=%d\n", rc);
-		return;
-	}
-	
-	if (s.is_file)
-		printf("%-40s\t%llu\n", name, (long long) s.size);
-	else if (s.is_directory)
-		printf("%-40s\t<dir>\n", name);
-	else
-		printf("%-40s\n", name);
-
-	return;
 }
 
@@ -114,6 +212,11 @@
 	} else {
 		help_cmd_ls(HELP_SHORT);
-		printf("  `%s' [path], if no path is given the current "
-				"working directory is used.\n", cmdname);
+		printf(
+		"Usage:  %s [options] [path]\n"
+		"If not path is given, the current working directory is used.\n"
+		"Options:\n"
+		"  -h, --help       A short option summary\n"
+		"  -u, --unsort     Do not sort directory entries\n",
+		cmdname);
 	}
 
@@ -124,43 +227,58 @@
 {
 	unsigned int argc;
-	struct stat s;
-	char *buff;
+	struct dir_elem_t de;
 	DIR *dirp;
+	int c, opt_ind;
+	int sort = 1;
 
 	argc = cli_count_args(argv);
-
-	buff = (char *) malloc(PATH_MAX);
-	if (NULL == buff) {
+	
+	for (c = 0, optind = 0, opt_ind = 0; c != -1;) {
+		c = getopt_long(argc, argv, "hu", long_options, &opt_ind);
+		switch (c) {
+		case 'h':
+			help_cmd_ls(HELP_LONG);
+			return CMD_SUCCESS;
+		case 'u':
+			sort = 0;
+			break;
+		}
+	}
+	
+	argc -= optind;
+	
+	de.name = (char *) malloc(PATH_MAX);
+	if (!de.name) {
 		cli_error(CL_ENOMEM, "%s: ", cmdname);
 		return CMD_FAILURE;
 	}
-	memset(buff, 0, sizeof(buff));
-
-	if (argc == 1)
-		getcwd(buff, PATH_MAX);
+	memset(de.name, 0, sizeof(PATH_MAX));
+	
+	if (argc == 0)
+		getcwd(de.name, PATH_MAX);
 	else
-		str_cpy(buff, PATH_MAX, argv[1]);
-
-	if (stat(buff, &s)) {
-		cli_error(CL_ENOENT, buff);
-		free(buff);
+		str_cpy(de.name, PATH_MAX, argv[optind]);
+	
+	if (stat(de.name, &de.s)) {
+		cli_error(CL_ENOENT, de.name);
+		free(de.name);
 		return CMD_FAILURE;
 	}
 
-	if (s.is_file) {
-		ls_print(buff, buff);
+	if (de.s.is_file) {
+		ls_print(&de);
 	} else {
-		dirp = opendir(buff);
+		dirp = opendir(de.name);
 		if (!dirp) {
 			/* May have been deleted between scoping it and opening it */
-			cli_error(CL_EFAIL, "Could not stat %s", buff);
-			free(buff);
+			cli_error(CL_EFAIL, "Could not stat %s", de.name);
+			free(de.name);
 			return CMD_FAILURE;
 		}
-		ls_scan_dir(buff, dirp);
+		ls_scan_dir(de.name, dirp, sort);
 		closedir(dirp);
 	}
 
-	free(buff);
+	free(de.name);
 
 	return CMD_SUCCESS;
Index: uspace/app/bdsh/cmds/modules/ls/ls.h
===================================================================
--- uspace/app/bdsh/cmds/modules/ls/ls.h	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ 	(revision )
@@ -1,13 +1,0 @@
-#ifndef LS_H
-#define LS_H
-
-/* Various values that can be returned by ls_scope() */
-#define LS_BOGUS 0
-#define LS_FILE  1
-#define LS_DIR   2
-
-static void ls_scan_dir(const char *, DIR *);
-static void ls_print(const char *, const char *);
-
-#endif /* LS_H */
-
Index: uspace/app/init/init.c
===================================================================
--- uspace/app/init/init.c	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/app/init/init.c	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -272,4 +272,7 @@
 	mount_tmpfs();
 	
+#ifdef CONFIG_START_DEVMAN
+	spawn("/srv/devman");
+#endif
 	spawn("/srv/apic");
 	spawn("/srv/i8259");
Index: uspace/app/netstart/self_test.c
===================================================================
--- uspace/app/netstart/self_test.c	(revision ea5352913e3f4737d9d751831020498633794587)
+++ uspace/app/netstart/self_test.c	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -0,0 +1,334 @@
+/*
+ * Copyright (c) 2009 Lukas Mejdrech
+ * 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 net
+ * @{
+ */
+
+/** @file
+ * Networking self-tests implementation.
+ *
+ */
+
+#include <errno.h>
+#include <malloc.h>
+#include <stdio.h>
+
+#include <net_checksum.h>
+#include <adt/int_map.h>
+#include <adt/char_map.h>
+#include <adt/generic_char_map.h>
+#include <adt/measured_strings.h>
+#include <adt/dynamic_fifo.h>
+
+#include "self_test.h"
+
+/** Test the statement, compare the result and evaluate.
+ *
+ * @param[in] statement The statement to test.
+ * @param[in] result    The expected result.
+ *
+ */
+#define TEST(statement, result) \
+	do { \
+		printf("\n\t%s == %s", #statement, #result); \
+		if ((statement) != (result)) { \
+			printf("\tfailed\n"); \
+			fprintf(stderr, "\nNetwork self-test failed\n"); \
+			return EINVAL; \
+		} else \
+			printf("\tOK"); \
+	} while (0)
+
+#define XMALLOC(var, type) \
+	do { \
+		(var) = (type *) malloc(sizeof(type)); \
+		if ((var) == NULL) { \
+			fprintf(stderr, "\nMemory allocation error\n"); \
+			return ENOMEM; \
+		} \
+	} while (0)
+
+GENERIC_CHAR_MAP_DECLARE(int_char_map, int);
+GENERIC_CHAR_MAP_IMPLEMENT(int_char_map, int);
+
+GENERIC_FIELD_DECLARE(int_field, int);
+GENERIC_FIELD_IMPLEMENT(int_field, int);
+
+INT_MAP_DECLARE(int_map, int);
+INT_MAP_IMPLEMENT(int_map, int);
+
+/** Self-test start function.
+ *
+ * Run all self-tests.
+ *
+ * @returns EOK on success.
+ * @returns The first error occurred.
+ *
+ */
+int self_test(void)
+{
+	printf("Running networking self-tests\n");
+	
+	printf("\nChar map test");
+	char_map_t cm;
+	
+	TEST(char_map_update(&cm, "ucho", 0, 3), EINVAL);
+	TEST(char_map_initialize(&cm), EOK);
+	TEST(char_map_exclude(&cm, "bla", 0), CHAR_MAP_NULL);
+	TEST(char_map_find(&cm, "bla", 0), CHAR_MAP_NULL);
+	TEST(char_map_add(&cm, "bla", 0, 1), EOK);
+	TEST(char_map_find(&cm, "bla", 0), 1);
+	TEST(char_map_add(&cm, "bla", 0, 10), EEXISTS);
+	TEST(char_map_update(&cm, "bla", 0, 2), EOK);
+	TEST(char_map_find(&cm, "bla", 0), 2);
+	TEST(char_map_update(&cm, "ucho", 0, 2), EOK);
+	TEST(char_map_exclude(&cm, "bla", 0), 2);
+	TEST(char_map_exclude(&cm, "bla", 0), CHAR_MAP_NULL);
+	TEST(char_map_find(&cm, "ucho", 0), 2);
+	TEST(char_map_update(&cm, "ucho", 0, 3), EOK);
+	TEST(char_map_find(&cm, "ucho", 0), 3);
+	TEST(char_map_add(&cm, "blabla", 0, 5), EOK);
+	TEST(char_map_find(&cm, "blabla", 0), 5);
+	TEST(char_map_add(&cm, "bla", 0, 6), EOK);
+	TEST(char_map_find(&cm, "bla", 0), 6);
+	TEST(char_map_exclude(&cm, "bla", 0), 6);
+	TEST(char_map_find(&cm, "bla", 0), CHAR_MAP_NULL);
+	TEST(char_map_find(&cm, "blabla", 0), 5);
+	TEST(char_map_add(&cm, "auto", 0, 7), EOK);
+	TEST(char_map_find(&cm, "auto", 0), 7);
+	TEST(char_map_add(&cm, "kara", 0, 8), EOK);
+	TEST(char_map_find(&cm, "kara", 0), 8);
+	TEST(char_map_add(&cm, "nic", 0, 9), EOK);
+	TEST(char_map_find(&cm, "nic", 0), 9);
+	TEST(char_map_find(&cm, "blabla", 0), 5);
+	TEST(char_map_add(&cm, "micnicnic", 5, 9), EOK);
+	TEST(char_map_find(&cm, "micni", 0), 9);
+	TEST(char_map_find(&cm, "micnicn", 5), 9);
+	TEST(char_map_add(&cm, "\x10\x0\x2\x2", 4, 15), EOK);
+	TEST(char_map_find(&cm, "\x10\x0\x2\x2", 4), 15);
+	
+	TEST((char_map_destroy(&cm), EOK), EOK);
+	TEST(char_map_update(&cm, "ucho", 0, 3), EINVAL);
+	
+	printf("\nCRC computation test");
+	uint32_t value;
+	
+	TEST(value = ~compute_crc32(~0, "123456789", 8 * 9), 0xcbf43926);
+	TEST(value = ~compute_crc32(~0, "1", 8), 0x83dcefb7);
+	TEST(value = ~compute_crc32(~0, "12", 8 * 2), 0x4f5344cd);
+	TEST(value = ~compute_crc32(~0, "123", 8 * 3), 0x884863d2);
+	TEST(value = ~compute_crc32(~0, "1234", 8 * 4), 0x9be3e0a3);
+	TEST(value = ~compute_crc32(~0, "12345678", 8 * 8), 0x9ae0daaf);
+	TEST(value = ~compute_crc32(~0, "ahoj pane", 8 * 9), 0x5fc3d706);
+	
+	printf("\nDynamic fifo test");
+	dyn_fifo_t fifo;
+	
+	TEST(dyn_fifo_push(&fifo, 1, 0), EINVAL);
+	TEST(dyn_fifo_initialize(&fifo, 1), EOK);
+	TEST(dyn_fifo_push(&fifo, 1, 0), EOK);
+	TEST(dyn_fifo_pop(&fifo), 1);
+	TEST(dyn_fifo_pop(&fifo), ENOENT);
+	TEST(dyn_fifo_push(&fifo, 2, 1), EOK);
+	TEST(dyn_fifo_push(&fifo, 3, 1), ENOMEM);
+	TEST(dyn_fifo_push(&fifo, 3, 0), EOK);
+	TEST(dyn_fifo_pop(&fifo), 2);
+	TEST(dyn_fifo_pop(&fifo), 3);
+	TEST(dyn_fifo_push(&fifo, 4, 2), EOK);
+	TEST(dyn_fifo_push(&fifo, 5, 2), EOK);
+	TEST(dyn_fifo_push(&fifo, 6, 2), ENOMEM);
+	TEST(dyn_fifo_push(&fifo, 6, 5), EOK);
+	TEST(dyn_fifo_push(&fifo, 7, 5), EOK);
+	TEST(dyn_fifo_pop(&fifo), 4);
+	TEST(dyn_fifo_pop(&fifo), 5);
+	TEST(dyn_fifo_push(&fifo, 8, 5), EOK);
+	TEST(dyn_fifo_push(&fifo, 9, 5), EOK);
+	TEST(dyn_fifo_push(&fifo, 10, 6), EOK);
+	TEST(dyn_fifo_push(&fifo, 11, 6), EOK);
+	TEST(dyn_fifo_pop(&fifo), 6);
+	TEST(dyn_fifo_pop(&fifo), 7);
+	TEST(dyn_fifo_push(&fifo, 12, 6), EOK);
+	TEST(dyn_fifo_push(&fifo, 13, 6), EOK);
+	TEST(dyn_fifo_push(&fifo, 14, 6), ENOMEM);
+	TEST(dyn_fifo_push(&fifo, 14, 8), EOK);
+	TEST(dyn_fifo_pop(&fifo), 8);
+	TEST(dyn_fifo_pop(&fifo), 9);
+	TEST(dyn_fifo_pop(&fifo), 10);
+	TEST(dyn_fifo_pop(&fifo), 11);
+	TEST(dyn_fifo_pop(&fifo), 12);
+	TEST(dyn_fifo_pop(&fifo), 13);
+	TEST(dyn_fifo_pop(&fifo), 14);
+	TEST(dyn_fifo_destroy(&fifo), EOK);
+	TEST(dyn_fifo_push(&fifo, 1, 0), EINVAL);
+	
+	printf("\nGeneric char map test");
+	
+	int *x;
+	int *y;
+	int *z;
+	int *u;
+	int *v;
+	int *w;
+	
+	XMALLOC(x, int);
+	XMALLOC(y, int);
+	XMALLOC(z, int);
+	XMALLOC(u, int);
+	XMALLOC(v, int);
+	XMALLOC(w, int);
+	
+	int_char_map_t icm;
+	icm.magic = 0;
+	
+	TEST(int_char_map_add(&icm, "ucho", 0, z), EINVAL);
+	TEST(int_char_map_initialize(&icm), EOK);
+	TEST((int_char_map_exclude(&icm, "bla", 0), EOK), EOK);
+	TEST(int_char_map_find(&icm, "bla", 0), NULL);
+	TEST(int_char_map_add(&icm, "bla", 0, x), EOK);
+	TEST(int_char_map_find(&icm, "bla", 0), x);
+	TEST(int_char_map_add(&icm, "bla", 0, y), EEXISTS);
+	TEST((int_char_map_exclude(&icm, "bla", 0), EOK), EOK);
+	TEST((int_char_map_exclude(&icm, "bla", 0), EOK), EOK);
+	TEST(int_char_map_add(&icm, "blabla", 0, v), EOK);
+	TEST(int_char_map_find(&icm, "blabla", 0), v);
+	TEST(int_char_map_add(&icm, "bla", 0, w), EOK);
+	TEST(int_char_map_find(&icm, "bla", 0), w);
+	TEST((int_char_map_exclude(&icm, "bla", 0), EOK), EOK);
+	TEST(int_char_map_find(&icm, "bla", 0), NULL);
+	TEST(int_char_map_find(&icm, "blabla", 0), v);
+	TEST(int_char_map_add(&icm, "auto", 0, u), EOK);
+	TEST(int_char_map_find(&icm, "auto", 0), u);
+	TEST((int_char_map_destroy(&icm), EOK), EOK);
+	TEST(int_char_map_add(&icm, "ucho", 0, z), EINVAL);
+	
+	printf("\nGeneric field test");
+	
+	XMALLOC(x, int);
+	XMALLOC(y, int);
+	XMALLOC(z, int);
+	XMALLOC(u, int);
+	XMALLOC(v, int);
+	XMALLOC(w, int);
+	
+	int_field_t gf;
+	gf.magic = 0;
+	
+	TEST(int_field_add(&gf, x), EINVAL);
+	TEST(int_field_count(&gf), -1);
+	TEST(int_field_initialize(&gf), EOK);
+	TEST(int_field_count(&gf), 0);
+	TEST(int_field_get_index(&gf, 1), NULL);
+	TEST(int_field_add(&gf, x), 0);
+	TEST(int_field_get_index(&gf, 0), x);
+	TEST((int_field_exclude_index(&gf, 0), EOK), EOK);
+	TEST(int_field_get_index(&gf, 0), NULL);
+	TEST(int_field_add(&gf, y), 1);
+	TEST(int_field_get_index(&gf, 1), y);
+	TEST(int_field_add(&gf, z), 2);
+	TEST(int_field_get_index(&gf, 2), z);
+	TEST(int_field_get_index(&gf, 1), y);
+	TEST(int_field_count(&gf), 3);
+	TEST(int_field_add(&gf, u), 3);
+	TEST(int_field_get_index(&gf, 3), u);
+	TEST(int_field_add(&gf, v), 4);
+	TEST(int_field_get_index(&gf, 4), v);
+	TEST(int_field_add(&gf, w), 5);
+	TEST(int_field_get_index(&gf, 5), w);
+	TEST(int_field_count(&gf), 6);
+	TEST((int_field_exclude_index(&gf, 1), EOK), EOK);
+	TEST(int_field_get_index(&gf, 1), NULL);
+	TEST(int_field_get_index(&gf, 3), u);
+	TEST((int_field_exclude_index(&gf, 7), EOK), EOK);
+	TEST(int_field_get_index(&gf, 3), u);
+	TEST(int_field_get_index(&gf, 5), w);
+	TEST((int_field_exclude_index(&gf, 4), EOK), EOK);
+	TEST(int_field_get_index(&gf, 4), NULL);
+	TEST((int_field_destroy(&gf), EOK), EOK);
+	TEST(int_field_count(&gf), -1);
+	
+	printf("\nInt map test");
+	
+	XMALLOC(x, int);
+	XMALLOC(y, int);
+	XMALLOC(z, int);
+	XMALLOC(u, int);
+	XMALLOC(v, int);
+	XMALLOC(w, int);
+	
+	int_map_t im;
+	im.magic = 0;
+	
+	TEST(int_map_add(&im, 1, x), EINVAL);
+	TEST(int_map_count(&im), -1);
+	TEST(int_map_initialize(&im), EOK);
+	TEST(int_map_count(&im), 0);
+	TEST(int_map_find(&im, 1), NULL);
+	TEST(int_map_add(&im, 1, x), 0);
+	TEST(int_map_find(&im, 1), x);
+	TEST((int_map_exclude(&im, 1), EOK), EOK);
+	TEST(int_map_find(&im, 1), NULL);
+	TEST(int_map_add(&im, 1, y), 1);
+	TEST(int_map_find(&im, 1), y);
+	TEST(int_map_add(&im, 4, z), 2);
+	TEST(int_map_get_index(&im, 2), z);
+	TEST(int_map_find(&im, 4), z);
+	TEST(int_map_find(&im, 1), y);
+	TEST(int_map_count(&im), 3);
+	TEST(int_map_add(&im, 2, u), 3);
+	TEST(int_map_find(&im, 2), u);
+	TEST(int_map_add(&im, 3, v), 4);
+	TEST(int_map_find(&im, 3), v);
+	TEST(int_map_get_index(&im, 4), v);
+	TEST(int_map_add(&im, 6, w), 5);
+	TEST(int_map_find(&im, 6), w);
+	TEST(int_map_count(&im), 6);
+	TEST((int_map_exclude(&im, 1), EOK), EOK);
+	TEST(int_map_find(&im, 1), NULL);
+	TEST(int_map_find(&im, 2), u);
+	TEST((int_map_exclude(&im, 7), EOK), EOK);
+	TEST(int_map_find(&im, 2), u);
+	TEST(int_map_find(&im, 6), w);
+	TEST((int_map_exclude_index(&im, 4), EOK), EOK);
+	TEST(int_map_get_index(&im, 4), NULL);
+	TEST(int_map_find(&im, 3), NULL);
+	TEST((int_map_destroy(&im), EOK), EOK);
+	TEST(int_map_count(&im), -1);
+	
+	printf("\nMeasured strings test");
+	
+	measured_string_ref string =
+	    measured_string_create_bulk("I am a measured string!", 0);
+	printf("\n%x, %s at %x of %d\n", string, string->value, string->value,
+	    string->length);
+	
+	return EOK;
+}
+
+/** @}
+ */
Index: uspace/app/netstart/self_test.h
===================================================================
--- uspace/app/netstart/self_test.h	(revision ea5352913e3f4737d9d751831020498633794587)
+++ uspace/app/netstart/self_test.h	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2009 Lukas Mejdrech
+ * 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 net
+ * @{
+ */
+
+#ifndef __SELF_TEST_H__
+#define __SELF_TEST_H__
+
+extern int self_test(void);
+
+#endif
+
+/** @}
+ */
Index: uspace/app/sbi/src/run_expr.c
===================================================================
--- uspace/app/sbi/src/run_expr.c	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/app/sbi/src/run_expr.c	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -2529,4 +2529,6 @@
 	if (rc1 == EOK)
 		rc2 = os_str_get_char(string->value, elem_index, &cval);
+	else
+		rc2 = EOK;
 
 	if (rc1 != EOK || rc2 != EOK) {
Index: uspace/app/tester/Makefile
===================================================================
--- uspace/app/tester/Makefile	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/app/tester/Makefile	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -49,4 +49,5 @@
 	loop/loop1.c \
 	mm/malloc1.c \
+	devs/devman1.c \
 	hw/misc/virtchar1.c \
 	hw/serial/serial1.c
Index: uspace/app/tester/devs/devman1.c
===================================================================
--- uspace/app/tester/devs/devman1.c	(revision ea5352913e3f4737d9d751831020498633794587)
+++ uspace/app/tester/devs/devman1.c	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2011 Vojtech Horky
+ * 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 tester
+ * @brief Test devman service.
+ * @{
+ */
+/**
+ * @file
+ */
+
+#include <inttypes.h>
+#include <errno.h>
+#include <str_error.h>
+#include <sys/types.h>
+#include <async.h>
+#include <devman.h>
+#include <str.h>
+#include <vfs/vfs.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include "../tester.h"
+
+#define DEVICE_PATH_NORMAL "/virt/null/a"
+#define DEVICE_CLASS "virt-null"
+#define DEVICE_CLASS_NAME "1"
+#define DEVICE_PATH_CLASSES DEVICE_CLASS "/" DEVICE_CLASS_NAME
+
+const char *test_devman1(void)
+{
+	devman_handle_t handle_primary;
+	devman_handle_t handle_class;
+	
+	int rc;
+	
+	TPRINTF("Asking for handle of `%s'...\n", DEVICE_PATH_NORMAL);
+	rc = devman_device_get_handle(DEVICE_PATH_NORMAL, &handle_primary, 0);
+	if (rc != EOK) {
+		TPRINTF(" ...failed: %s.\n", str_error(rc));
+		if (rc == ENOENT) {
+			TPRINTF("Have you compiled the test drivers?\n");
+		}
+		return "Failed getting device handle";
+	}
+
+	TPRINTF("Asking for handle of `%s' by class..\n", DEVICE_PATH_CLASSES);
+	rc = devman_device_get_handle_by_class(DEVICE_CLASS, DEVICE_CLASS_NAME,
+	    &handle_class, 0);
+	if (rc != EOK) {
+		TPRINTF(" ...failed: %s.\n", str_error(rc));
+		return "Failed getting device class handle";
+	}
+
+	TPRINTF("Received handles %" PRIun " and %" PRIun ".\n",
+	    handle_primary, handle_class);
+	if (handle_primary != handle_class) {
+		return "Retrieved different handles for the same device";
+	}
+
+	return NULL;
+}
+
+/** @}
+ */
Index: uspace/app/tester/devs/devman1.def
===================================================================
--- uspace/app/tester/devs/devman1.def	(revision ea5352913e3f4737d9d751831020498633794587)
+++ uspace/app/tester/devs/devman1.def	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -0,0 +1,6 @@
+{
+	"devman1",
+	"devman test",
+	&test_devman1,
+	false
+},
Index: uspace/app/tester/fault/fault2.c
===================================================================
--- uspace/app/tester/fault/fault2.c	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/app/tester/fault/fault2.c	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -29,4 +29,5 @@
 
 #include "../tester.h"
+#include <stdio.h>
 
 typedef int __attribute__((may_alias)) aliasing_int;
@@ -38,4 +39,5 @@
 	
 	var1 = *((aliasing_int *) (((char *) (&var)) + 1));
+	printf("Read %d\n", var1);
 	
 	return "Survived unaligned read";
Index: uspace/app/tester/tester.c
===================================================================
--- uspace/app/tester/tester.c	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/app/tester/tester.c	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -64,4 +64,5 @@
 #include "hw/serial/serial1.def"
 #include "hw/misc/virtchar1.def"
+#include "devs/devman1.def"
 	{NULL, NULL, NULL, false}
 };
Index: uspace/app/tester/tester.h
===================================================================
--- uspace/app/tester/tester.h	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/app/tester/tester.h	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -80,4 +80,5 @@
 extern const char *test_serial1(void);
 extern const char *test_virtchar1(void);
+extern const char *test_devman1(void);
 
 extern test_t tests[];
Index: uspace/app/trace/trace.c
===================================================================
--- uspace/app/trace/trace.c	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/app/trace/trace.c	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -872,5 +872,5 @@
 static display_mask_t parse_display_mask(const char *text)
 {
-	display_mask_t dm;
+	display_mask_t dm = 0;
 	const char *c = text;
 	
Index: uspace/drv/isa/isa.c
===================================================================
--- uspace/drv/isa/isa.c	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/drv/isa/isa.c	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -53,4 +53,5 @@
 
 #include <ddf/driver.h>
+#include <ddf/log.h>
 #include <ops/hw_res.h>
 
@@ -134,5 +135,5 @@
 	fd = open(conf_path, O_RDONLY);
 	if (fd < 0) {
-		printf(NAME ": unable to open %s\n", conf_path);
+		ddf_msg(LVL_ERROR, "Unable to open %s", conf_path);
 		goto cleanup;
 	}
@@ -141,8 +142,8 @@
 
 	len = lseek(fd, 0, SEEK_END);
-	lseek(fd, 0, SEEK_SET);	
+	lseek(fd, 0, SEEK_SET);
 	if (len == 0) {
-		printf(NAME ": fun_conf_read error: configuration file '%s' "
-		    "is empty.\n", conf_path);
+		ddf_msg(LVL_ERROR, "Configuration file '%s' is empty.",
+		    conf_path);
 		goto cleanup;
 	}
@@ -150,11 +151,10 @@
 	buf = malloc(len + 1);
 	if (buf == NULL) {
-		printf(NAME ": fun_conf_read error: memory allocation failed.\n");
+		ddf_msg(LVL_ERROR, "Memory allocation failed.");
 		goto cleanup;
 	}
 
 	if (0 >= read(fd, buf, len)) {
-		printf(NAME ": fun_conf_read error: unable to read file '%s'.\n",
-		    conf_path);
+		ddf_msg(LVL_ERROR, "Unable to read file '%s'.", conf_path);
 		goto cleanup;
 	}
@@ -252,5 +252,5 @@
 		fun->hw_resources.count++;
 
-		printf(NAME ": added irq 0x%x to function %s\n", irq,
+		ddf_msg(LVL_NOTE, "Added irq 0x%x to function %s", irq,
 		    fun->fnode->name);
 	}
@@ -270,6 +270,6 @@
 		fun->hw_resources.count++;
 
-		printf(NAME ": added io range (addr=0x%x, size=0x%x) to "
-		    "function %s\n", (unsigned int) addr, (unsigned int) len,
+		ddf_msg(LVL_NOTE, "Added io range (addr=0x%x, size=0x%x) to "
+		    "function %s", (unsigned int) addr, (unsigned int) len,
 		    fun->fnode->name);
 	}
@@ -331,6 +331,6 @@
 	score = (int)strtol(val, &end, 10);
 	if (val == end) {
-		printf(NAME " : error - could not read match score for "
-		    "function %s.\n", fun->fnode->name);
+		ddf_msg(LVL_ERROR, "Cannot read match score for function "
+		    "%s.", fun->fnode->name);
 		return;
 	}
@@ -339,15 +339,17 @@
 	get_match_id(&id, val);
 	if (id == NULL) {
-		printf(NAME " : error - could not read match id for "
-		    "function %s.\n", fun->fnode->name);
+		ddf_msg(LVL_ERROR, "Cannot read match ID for function %s.",
+		    fun->fnode->name);
 		return;
 	}
 
-	printf(NAME ": adding match id '%s' with score %d to function %s\n", id,
-	    score, fun->fnode->name);
+	ddf_msg(LVL_DEBUG, "Adding match id '%s' with score %d to "
+	    "function %s", id, score, fun->fnode->name);
 
 	rc = ddf_fun_add_match_id(fun->fnode, id, score);
-	if (rc != EOK)
-		printf(NAME ": error adding match ID: %s\n", str_error(rc));
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Failed adding match ID: %s",
+		    str_error(rc));
+	}
 }
 
@@ -375,8 +377,8 @@
 	if (!prop_parse(fun, line, "io_range", &fun_parse_io_range) &&
 	    !prop_parse(fun, line, "irq", &fun_parse_irq) &&
-	    !prop_parse(fun, line, "match", &fun_parse_match_id))
-	{
-	    printf(NAME " error undefined device property at line '%s'\n",
-		line);
+	    !prop_parse(fun, line, "match", &fun_parse_match_id)) {
+
+		ddf_msg(LVL_ERROR, "Undefined device property at line '%s'",
+		    line);
 	}
 }
@@ -439,5 +441,5 @@
 	fun->fnode->ops = &isa_fun_ops;
 
-	printf(NAME ": Binding function %s.\n", fun->fnode->name);
+	ddf_msg(LVL_DEBUG, "Binding function %s.", fun->fnode->name);
 
 	/* XXX Handle error */
@@ -467,18 +469,18 @@
 static int isa_add_device(ddf_dev_t *dev)
 {
-	printf(NAME ": isa_add_device, device handle = %d\n",
+	ddf_msg(LVL_DEBUG, "isa_add_device, device handle = %d",
 	    (int) dev->handle);
 
 	/* Make the bus device more visible. Does not do anything. */
-	printf(NAME ": adding a 'ctl' function\n");
+	ddf_msg(LVL_DEBUG, "Adding a 'ctl' function");
 
 	ddf_fun_t *ctl = ddf_fun_create(dev, fun_exposed, "ctl");
 	if (ctl == NULL) {
-		printf(NAME ": Error creating control function.\n");
+		ddf_msg(LVL_ERROR, "Failed creating control function.");
 		return EXDEV;
 	}
 
 	if (ddf_fun_bind(ctl) != EOK) {
-		printf(NAME ": Error binding control function.\n");
+		ddf_msg(LVL_ERROR, "Failed binding control function.");
 		return EXDEV;
 	}
@@ -486,5 +488,5 @@
 	/* Add functions as specified in the configuration file. */
 	isa_functions_add(dev);
-	printf(NAME ": finished the enumeration of legacy functions\n");
+	ddf_msg(LVL_NOTE, "Finished enumerating legacy functions");
 
 	return EOK;
@@ -493,4 +495,5 @@
 static void isa_init() 
 {
+	ddf_log_init(NAME, LVL_ERROR);
 	isa_fun_ops.interfaces[HW_RES_DEV_IFACE] = &isa_fun_hw_res_ops;
 }
Index: uspace/drv/ns8250/ns8250.c
===================================================================
--- uspace/drv/ns8250/ns8250.c	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/drv/ns8250/ns8250.c	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -55,4 +55,5 @@
 #include <ddf/driver.h>
 #include <ddf/interrupt.h>
+#include <ddf/log.h>
 #include <ops/char_dev.h>
 
@@ -275,11 +276,11 @@
 static bool ns8250_pio_enable(ns8250_t *ns)
 {
-	printf(NAME ": ns8250_pio_enable %s\n", ns->dev->name);
+	ddf_msg(LVL_DEBUG, "ns8250_pio_enable %s", ns->dev->name);
 	
 	/* Gain control over port's registers. */
 	if (pio_enable((void *)(uintptr_t) ns->io_addr, REG_COUNT,
 	    (void **) &ns->port)) {
-		printf(NAME ": error - cannot gain the port %#" PRIx32 " for device "
-		    "%s.\n", ns->io_addr, ns->dev->name);
+		ddf_msg(LVL_ERROR, "Cannot map the port %#" PRIx32
+		    " for device %s.", ns->io_addr, ns->dev->name);
 		return false;
 	}
@@ -295,5 +296,5 @@
 static bool ns8250_dev_probe(ns8250_t *ns)
 {
-	printf(NAME ": ns8250_dev_probe %s\n", ns->dev->name);
+	ddf_msg(LVL_DEBUG, "ns8250_dev_probe %s", ns->dev->name);
 	
 	ioport8_t *port_addr = ns->port;
@@ -313,6 +314,8 @@
 	pio_write_8(port_addr + 4, olddata);
 	
-	if (!res)
-		printf(NAME ": device %s is not present.\n", ns->dev->name);
+	if (!res) {
+		ddf_msg(LVL_DEBUG, "Device %s is not present.",
+		    ns->dev->name);
+	}
 	
 	return res;
@@ -326,5 +329,5 @@
 static int ns8250_dev_initialize(ns8250_t *ns)
 {
-	printf(NAME ": ns8250_dev_initialize %s\n", ns->dev->name);
+	ddf_msg(LVL_DEBUG, "ns8250_dev_initialize %s", ns->dev->name);
 	
 	int ret = EOK;
@@ -337,6 +340,6 @@
 	    IPC_FLAG_BLOCKING);
 	if (ns->dev->parent_phone < 0) {
-		printf(NAME ": failed to connect to the parent driver of the "
-		    "device %s.\n", ns->dev->name);
+		ddf_msg(LVL_ERROR, "Failed to connect to parent driver of "
+		    "device %s.", ns->dev->name);
 		ret = ns->dev->parent_phone;
 		goto failed;
@@ -346,6 +349,6 @@
 	ret = hw_res_get_resource_list(ns->dev->parent_phone, &hw_resources);
 	if (ret != EOK) {
-		printf(NAME ": failed to get hw resources for the device "
-		    "%s.\n", ns->dev->name);
+		ddf_msg(LVL_ERROR, "Failed to get HW resources for device "
+		    "%s.", ns->dev->name);
 		goto failed;
 	}
@@ -362,5 +365,5 @@
 			ns->irq = res->res.interrupt.irq;
 			irq = true;
-			printf(NAME ": the %s device was asigned irq = 0x%x.\n",
+			ddf_msg(LVL_NOTE, "Device %s was asigned irq = 0x%x.",
 			    ns->dev->name, ns->irq);
 			break;
@@ -369,13 +372,13 @@
 			ns->io_addr = res->res.io_range.address;
 			if (res->res.io_range.size < REG_COUNT) {
-				printf(NAME ": i/o range assigned to the device "
-				    "%s is too small.\n", ns->dev->name);
+				ddf_msg(LVL_ERROR, "I/O range assigned to "
+				    "device %s is too small.", ns->dev->name);
 				ret = ELIMIT;
 				goto failed;
 			}
 			ioport = true;
-			printf(NAME ": the %s device was asigned i/o address = "
-			    "0x%x.\n", ns->dev->name, ns->io_addr);
-			break;
+			ddf_msg(LVL_NOTE, "Device %s was asigned I/O address = "
+			    "0x%x.", ns->dev->name, ns->io_addr);
+    			break;
 			
 		default:
@@ -385,5 +388,5 @@
 	
 	if (!irq || !ioport) {
-		printf(NAME ": missing hw resource(s) for the device %s.\n",
+		ddf_msg(LVL_ERROR, "Missing HW resource(s) for device %s.",
 		    ns->dev->name);
 		ret = ENOENT;
@@ -470,6 +473,6 @@
 	
 	if (baud_rate < 50 || MAX_BAUD_RATE % baud_rate != 0) {
-		printf(NAME ": error - somebody tried to set invalid baud rate "
-		    "%d\n", baud_rate);
+		ddf_msg(LVL_ERROR, "Invalid baud rate %d requested.",
+		    baud_rate);
 		return EINVAL;
 	}
@@ -654,9 +657,9 @@
 			if (ns->client_connected) {
 				if (!buf_push_back(&ns->input_buffer, val)) {
-					printf(NAME ": buffer overflow on "
-					    "%s.\n", ns->dev->name);
+					ddf_msg(LVL_WARN, "Buffer overflow on "
+					    "%s.", ns->dev->name);
 				} else {
-					printf(NAME ": the character %c saved "
-					    "to the buffer of %s.\n",
+					ddf_msg(LVL_DEBUG2, "Character %c saved "
+					    "to the buffer of %s.",
 					    val, ns->dev->name);
 				}
@@ -714,5 +717,5 @@
 	int rc;
 	
-	printf(NAME ": ns8250_add_device %s (handle = %d)\n",
+	ddf_msg(LVL_DEBUG, "ns8250_add_device %s (handle = %d)",
 	    dev->name, (int) dev->handle);
 	
@@ -749,5 +752,5 @@
 	/* Register interrupt handler. */
 	if (ns8250_register_interrupt_handler(ns) != EOK) {
-		printf(NAME ": failed to register interrupt handler.\n");
+		ddf_msg(LVL_ERROR, "Failed to register interrupt handler.");
 		rc = EADDRNOTAVAIL;
 		goto fail;
@@ -757,6 +760,6 @@
 	rc = ns8250_interrupt_enable(ns);
 	if (rc != EOK) {
-		printf(NAME ": failed to enable the interrupt. Error code = "
-		    "%d.\n", rc);
+		ddf_msg(LVL_ERROR, "Failed to enable the interrupt. Error code = "
+		    "%d.", rc);
 		goto fail;
 	}
@@ -764,5 +767,5 @@
 	fun = ddf_fun_create(dev, fun_exposed, "a");
 	if (fun == NULL) {
-		printf(NAME ": error creating function.\n");
+		ddf_msg(LVL_ERROR, "Failed creating function.");
 		goto fail;
 	}
@@ -772,5 +775,5 @@
 	rc = ddf_fun_bind(fun);
 	if (rc != EOK) {
-		printf(NAME ": error binding function.\n");
+		ddf_msg(LVL_ERROR, "Failed binding function.");
 		goto fail;
 	}
@@ -780,5 +783,5 @@
 	ddf_fun_add_to_class(fun, "serial");
 	
-	printf(NAME ": the %s device has been successfully initialized.\n",
+	ddf_msg(LVL_NOTE, "Device %s successfully initialized.",
 	    dev->name);
 	
@@ -862,6 +865,6 @@
 	fibril_mutex_unlock(&data->mutex);
 	
-	printf(NAME ": ns8250_get_props: baud rate %d, parity 0x%x, word "
-	    "length %d, stop bits %d\n", *baud_rate, *parity, *word_length,
+	ddf_msg(LVL_DEBUG, "ns8250_get_props: baud rate %d, parity 0x%x, word "
+	    "length %d, stop bits %d", *baud_rate, *parity, *word_length,
 	    *stop_bits);
 }
@@ -879,6 +882,6 @@
     unsigned int parity, unsigned int word_length, unsigned int stop_bits)
 {
-	printf(NAME ": ns8250_set_props: baud rate %d, parity 0x%x, word "
-	    "length %d, stop bits %d\n", baud_rate, parity, word_length,
+	ddf_msg(LVL_DEBUG, "ns8250_set_props: baud rate %d, parity 0x%x, word "
+	    "length %d, stop bits %d", baud_rate, parity, word_length,
 	    stop_bits);
 	
@@ -940,4 +943,6 @@
 static void ns8250_init(void)
 {
+	ddf_log_init(NAME, LVL_ERROR);
+	
 	ns8250_dev_ops.open = &ns8250_open;
 	ns8250_dev_ops.close = &ns8250_close;
Index: uspace/drv/pciintel/pci.c
===================================================================
--- uspace/drv/pciintel/pci.c	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/drv/pciintel/pci.c	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -48,4 +48,5 @@
 
 #include <ddf/driver.h>
+#include <ddf/log.h>
 #include <devman.h>
 #include <ipc/devman.h>
@@ -225,5 +226,5 @@
 
 	if (match_id_str == NULL) {
-		printf(NAME ": out of memory creating match ID.\n");
+		ddf_msg(LVL_ERROR, "Out of memory creating match ID.");
 		return;
 	}
@@ -231,5 +232,5 @@
 	rc = ddf_fun_add_match_id(fun->fnode, match_id_str, 90);
 	if (rc != EOK) {
-		printf(NAME ": error adding match ID: %s\n",
+		ddf_msg(LVL_ERROR, "Failed adding match ID: %s",
 		    str_error(rc));
 	}
@@ -323,7 +324,7 @@
 	
 	if (range_addr != 0) {
-		printf(NAME ": function %s : ", fun->fnode->name);
-		printf("address = %" PRIx64, range_addr);
-		printf(", size = %x\n", (unsigned int) range_size);
+		ddf_msg(LVL_DEBUG, "Function %s : address = %" PRIx64
+		    ", size = %x", fun->fnode->name, range_addr,
+		    (unsigned int) range_size);
 	}
 	
@@ -350,5 +351,5 @@
 	hw_res_list->count++;
 	
-	printf(NAME ": function %s uses irq %x.\n", fun->fnode->name, irq);
+	ddf_msg(LVL_NOTE, "Function %s uses irq %x.", fun->fnode->name, irq);
 }
 
@@ -406,5 +407,5 @@
 			char *fun_name = pci_fun_create_name(fun);
 			if (fun_name == NULL) {
-				printf(NAME ": out of memory.\n");
+				ddf_msg(LVL_ERROR, "Out of memory.");
 				return;
 			}
@@ -412,5 +413,5 @@
 			fnode = ddf_fun_create(bus->dnode, fun_inner, fun_name);
 			if (fnode == NULL) {
-				printf(NAME ": error creating function.\n");
+				ddf_msg(LVL_ERROR, "Failed creating function.");
 				return;
 			}
@@ -426,5 +427,5 @@
 			fnode->driver_data = fun;
 			
-			printf(NAME ": adding new function %s.\n",
+			ddf_msg(LVL_DEBUG, "Adding new function %s.",
 			    fnode->name);
 			
@@ -443,6 +444,7 @@
 				child_bus = pci_conf_read_8(fun,
 				    PCI_BRIDGE_SEC_BUS_NUM);
-				printf(NAME ": device is pci-to-pci bridge, "
-				    "secondary bus number = %d.\n", bus_num);
+				ddf_msg(LVL_DEBUG, "Device is pci-to-pci "
+				    "bridge, secondary bus number = %d.",
+				    bus_num);
 				if (child_bus > bus_num)
 					pci_bus_scan(bus, child_bus);
@@ -466,10 +468,10 @@
 	int rc;
 	
-	printf(NAME ": pci_add_device\n");
+	ddf_msg(LVL_DEBUG, "pci_add_device");
 	dnode->parent_phone = -1;
 	
 	bus = pci_bus_new();
 	if (bus == NULL) {
-		printf(NAME ": pci_add_device allocation failed.\n");
+		ddf_msg(LVL_ERROR, "pci_add_device allocation failed.");
 		rc = ENOMEM;
 		goto fail;
@@ -481,6 +483,6 @@
 	    IPC_FLAG_BLOCKING);
 	if (dnode->parent_phone < 0) {
-		printf(NAME ": pci_add_device failed to connect to the "
-		    "parent's driver.\n");
+		ddf_msg(LVL_ERROR, "pci_add_device failed to connect to the "
+		    "parent's driver.");
 		rc = dnode->parent_phone;
 		goto fail;
@@ -491,11 +493,11 @@
 	rc = hw_res_get_resource_list(dnode->parent_phone, &hw_resources);
 	if (rc != EOK) {
-		printf(NAME ": pci_add_device failed to get hw resources for "
-		    "the device.\n");
+		ddf_msg(LVL_ERROR, "pci_add_device failed to get hw resources "
+		    "for the device.");
 		goto fail;
 	}
 	got_res = true;
 	
-	printf(NAME ": conf_addr = %" PRIx64 ".\n",
+	ddf_msg(LVL_DEBUG, "conf_addr = %" PRIx64 ".",
 	    hw_resources.resources[0].res.io_range.address);
 	
@@ -509,5 +511,5 @@
 	if (pio_enable((void *)(uintptr_t)bus->conf_io_addr, 8,
 	    &bus->conf_addr_port)) {
-		printf(NAME ": failed to enable configuration ports.\n");
+		ddf_msg(LVL_ERROR, "Failed to enable configuration ports.");
 		rc = EADDRNOTAVAIL;
 		goto fail;
@@ -516,9 +518,9 @@
 	
 	/* Make the bus device more visible. It has no use yet. */
-	printf(NAME ": adding a 'ctl' function\n");
+	ddf_msg(LVL_DEBUG, "Adding a 'ctl' function");
 	
 	ctl = ddf_fun_create(bus->dnode, fun_exposed, "ctl");
 	if (ctl == NULL) {
-		printf(NAME ": error creating control function.\n");
+		ddf_msg(LVL_ERROR, "Failed creating control function.");
 		rc = ENOMEM;
 		goto fail;
@@ -527,10 +529,10 @@
 	rc = ddf_fun_bind(ctl);
 	if (rc != EOK) {
-		printf(NAME ": error binding control function.\n");
+		ddf_msg(LVL_ERROR, "Failed binding control function.");
 		goto fail;
 	}
 	
 	/* Enumerate functions. */
-	printf(NAME ": scanning the bus\n");
+	ddf_msg(LVL_DEBUG, "Scanning the bus");
 	pci_bus_scan(bus, 0);
 	
@@ -554,4 +556,5 @@
 static void pciintel_init(void)
 {
+	ddf_log_init(NAME, LVL_ERROR);
 	pci_fun_ops.interfaces[HW_RES_DEV_IFACE] = &pciintel_hw_res_ops;
 }
@@ -631,5 +634,5 @@
 int main(int argc, char *argv[])
 {
-	printf(NAME ": HelenOS pci bus driver (intel method 1).\n");
+	printf(NAME ": HelenOS PCI bus driver (Intel method 1).\n");
 	pciintel_init();
 	return ddf_driver_main(&pci_driver);
Index: uspace/drv/root/root.c
===================================================================
--- uspace/drv/root/root.c	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/drv/root/root.c	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -52,4 +52,5 @@
 
 #include <ddf/driver.h>
+#include <ddf/log.h>
 #include <devman.h>
 #include <ipc/devman.h>
@@ -89,11 +90,11 @@
 	int rc;
 
-	printf(NAME ": adding new function for virtual devices.\n");
-	printf(NAME ":   function node is `%s' (%d %s)\n", name,
+	ddf_msg(LVL_DEBUG, "Adding new function for virtual devices. "
+	    "Function node is `%s' (%d %s)", name,
 	    VIRTUAL_FUN_MATCH_SCORE, VIRTUAL_FUN_MATCH_ID);
 
 	fun = ddf_fun_create(dev, fun_inner, name);
 	if (fun == NULL) {
-		printf(NAME ": error creating function %s\n", name);
+		ddf_msg(LVL_ERROR, "Failed creating function %s", name);
 		return ENOMEM;
 	}
@@ -102,5 +103,6 @@
 	    VIRTUAL_FUN_MATCH_SCORE);
 	if (rc != EOK) {
-		printf(NAME ": error adding match IDs to function %s\n", name);
+		ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s",
+		    name);
 		ddf_fun_destroy(fun);
 		return rc;
@@ -109,5 +111,5 @@
 	rc = ddf_fun_bind(fun);
 	if (rc != EOK) {
-		printf(NAME ": error binding function %s: %s\n", name,
+		ddf_msg(LVL_ERROR, "Failed binding function %s: %s", name,
 		    str_error(rc));
 		ddf_fun_destroy(fun);
@@ -136,5 +138,5 @@
 	platform = sysinfo_get_data("platform", &platform_size);
 	if (platform == NULL) {
-		printf(NAME ": Failed to obtain platform name.\n");
+		ddf_msg(LVL_ERROR, "Failed to obtain platform name.");
 		return ENOENT;
 	}
@@ -143,5 +145,5 @@
 	platform = realloc(platform, platform_size + 1);
 	if (platform == NULL) {
-		printf(NAME ": Memory allocation failed.\n");
+		ddf_msg(LVL_ERROR, "Memory allocation failed.");
 		return ENOMEM;
 	}
@@ -151,16 +153,16 @@
 	/* Construct match ID. */
 	if (asprintf(&match_id, PLATFORM_FUN_MATCH_ID_FMT, platform) == -1) {
-		printf(NAME ": Memory allocation failed.\n");
+		ddf_msg(LVL_ERROR, "Memory allocation failed.");
 		return ENOMEM;
 	}
 
 	/* Add function. */
-	printf(NAME ": adding platform function\n");
-	printf(NAME ":   function node is `%s' (%d %s)\n", PLATFORM_FUN_NAME,
-	    PLATFORM_FUN_MATCH_SCORE, match_id);
+	ddf_msg(LVL_DEBUG, "Adding platform function. Function node is `%s' "
+	    " (%d %s)", PLATFORM_FUN_NAME, PLATFORM_FUN_MATCH_SCORE,
+	    match_id);
 
 	fun = ddf_fun_create(dev, fun_inner, name);
 	if (fun == NULL) {
-		printf(NAME ": error creating function %s\n", name);
+		ddf_msg(LVL_ERROR, "Error creating function %s", name);
 		return ENOMEM;
 	}
@@ -168,5 +170,6 @@
 	rc = ddf_fun_add_match_id(fun, match_id, PLATFORM_FUN_MATCH_SCORE);
 	if (rc != EOK) {
-		printf(NAME ": error adding match IDs to function %s\n", name);
+		ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s",
+		    name);
 		ddf_fun_destroy(fun);
 		return rc;
@@ -175,5 +178,5 @@
 	rc = ddf_fun_bind(fun);
 	if (rc != EOK) {
-		printf(NAME ": error binding function %s: %s\n", name,
+		ddf_msg(LVL_ERROR, "Failed binding function %s: %s", name,
 		    str_error(rc));
 		ddf_fun_destroy(fun);
@@ -191,5 +194,5 @@
 static int root_add_device(ddf_dev_t *dev)
 {
-	printf(NAME ": root_add_device, device handle=%" PRIun "\n",
+	ddf_msg(LVL_DEBUG, "root_add_device, device handle=%" PRIun,
 	    dev->handle);
 
@@ -204,5 +207,5 @@
 	int res = add_platform_fun(dev);
 	if (EOK != res)
-		printf(NAME ": failed to add child device for platform.\n");
+		ddf_msg(LVL_ERROR, "Failed adding child device for platform.");
 
 	return res;
@@ -212,4 +215,6 @@
 {
 	printf(NAME ": HelenOS root device driver\n");
+
+	ddf_log_init(NAME, LVL_ERROR);
 	return ddf_driver_main(&root_driver);
 }
Index: uspace/drv/rootpc/rootpc.c
===================================================================
--- uspace/drv/rootpc/rootpc.c	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/drv/rootpc/rootpc.c	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -47,4 +47,5 @@
 
 #include <ddf/driver.h>
+#include <ddf/log.h>
 #include <devman.h>
 #include <ipc/devman.h>
@@ -119,5 +120,5 @@
     rootpc_fun_t *fun)
 {
-	printf(NAME ": adding new function '%s'.\n", name);
+	ddf_msg(LVL_DEBUG, "Adding new function '%s'.", name);
 	
 	ddf_fun_t *fnode = NULL;
@@ -145,5 +146,5 @@
 	/* Register function. */
 	if (ddf_fun_bind(fnode) != EOK) {
-		printf(NAME ": error binding function %s.\n", name);
+		ddf_msg(LVL_ERROR, "Failed binding function %s.", name);
 		goto failure;
 	}
@@ -158,5 +159,5 @@
 		ddf_fun_destroy(fnode);
 	
-	printf(NAME ": failed to add function '%s'.\n", name);
+	ddf_msg(LVL_ERROR, "Failed adding function '%s'.", name);
 	
 	return false;
@@ -176,10 +177,10 @@
 static int rootpc_add_device(ddf_dev_t *dev)
 {
-	printf(NAME ": rootpc_add_device, device handle = %d\n",
+	ddf_msg(LVL_DEBUG, "rootpc_add_device, device handle = %d",
 	    (int)dev->handle);
 	
 	/* Register functions. */
 	if (!rootpc_add_functions(dev)) {
-		printf(NAME ": failed to add functions for PC platform.\n");
+		ddf_msg(LVL_ERROR, "Failed to add functions for PC platform.");
 	}
 	
@@ -189,4 +190,5 @@
 static void root_pc_init(void)
 {
+	ddf_log_init(NAME, LVL_ERROR);
 	rootpc_fun_ops.interfaces[HW_RES_DEV_IFACE] = &fun_hw_res_ops;
 }
Index: uspace/drv/rootvirt/rootvirt.c
===================================================================
--- uspace/drv/rootvirt/rootvirt.c	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/drv/rootvirt/rootvirt.c	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -40,4 +40,5 @@
 #include <str_error.h>
 #include <ddf/driver.h>
+#include <ddf/log.h>
 
 #define NAME "rootvirt"
@@ -83,10 +84,10 @@
 	int rc;
 
-	printf(NAME ": registering function `%s' (match \"%s\")\n",
+	ddf_msg(LVL_DEBUG, "Registering function `%s' (match \"%s\")",
 	    vfun->name, vfun->match_id);
 
 	fun = ddf_fun_create(vdev, fun_inner, vfun->name);
 	if (fun == NULL) {
-		printf(NAME ": error creating function %s\n", vfun->name);
+		ddf_msg(LVL_ERROR, "Failed creating function %s", vfun->name);
 		return ENOMEM;
 	}
@@ -94,5 +95,5 @@
 	rc = ddf_fun_add_match_id(fun, vfun->match_id, 10);
 	if (rc != EOK) {
-		printf(NAME ": error adding match IDs to function %s\n",
+		ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s",
 		    vfun->name);
 		ddf_fun_destroy(fun);
@@ -102,11 +103,11 @@
 	rc = ddf_fun_bind(fun);
 	if (rc != EOK) {
-		printf(NAME ": error binding function %s: %s\n", vfun->name,
-		    str_error(rc));
+		ddf_msg(LVL_ERROR, "Failed binding function %s: %s",
+		    vfun->name, str_error(rc));
 		ddf_fun_destroy(fun);
 		return rc;
 	}
 
-	printf(NAME ": registered child device `%s'\n", vfun->name);
+	ddf_msg(LVL_NOTE, "Registered child device `%s'", vfun->name);
 	return EOK;
 }
@@ -124,5 +125,5 @@
 	}
 
-	printf(NAME ": add_device(handle=%d)\n", (int)dev->handle);
+	ddf_msg(LVL_DEBUG, "add_device(handle=%d)", (int)dev->handle);
 
 	/*
@@ -142,4 +143,6 @@
 {
 	printf(NAME ": HelenOS virtual devices root driver\n");
+
+	ddf_log_init(NAME, LVL_ERROR);
 	return ddf_driver_main(&rootvirt_driver);
 }
Index: uspace/drv/test1/test1.c
===================================================================
--- uspace/drv/test1/test1.c	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/drv/test1/test1.c	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -35,4 +35,5 @@
 #include <str_error.h>
 #include <ddf/driver.h>
+#include <ddf/log.h>
 
 #include "test1.h"
@@ -58,34 +59,49 @@
  */
 static int register_fun_verbose(ddf_dev_t *parent, const char *message,
-    const char *name, const char *match_id, int match_score)
+    const char *name, const char *match_id, int match_score,
+    int expected_rc)
 {
-	ddf_fun_t *fun;
+	ddf_fun_t *fun = NULL;
 	int rc;
 
-	printf(NAME ": registering function `%s': %s.\n", name, message);
+	ddf_msg(LVL_DEBUG, "Registering function `%s': %s.", name, message);
 
 	fun = ddf_fun_create(parent, fun_inner, name);
 	if (fun == NULL) {
-		printf(NAME ": error creating function %s\n", name);
-		return ENOMEM;
+		ddf_msg(LVL_ERROR, "Failed creating function %s", name);
+		rc = ENOMEM;
+		goto leave;
 	}
 
-	rc = ddf_fun_add_match_id(fun, match_id, match_score);
+	rc = ddf_fun_add_match_id(fun, str_dup(match_id), match_score);
 	if (rc != EOK) {
-		printf(NAME ": error adding match IDs to function %s\n", name);
-		ddf_fun_destroy(fun);
-		return rc;
+		ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s",
+		    name);
+		goto leave;
 	}
 
 	rc = ddf_fun_bind(fun);
 	if (rc != EOK) {
-		printf(NAME ": error binding function %s: %s\n", name,
+		ddf_msg(LVL_ERROR, "Failed binding function %s: %s", name,
 		    str_error(rc));
-		ddf_fun_destroy(fun);
-		return rc;
+		goto leave;
 	}
 
-	printf(NAME ": registered child device `%s'\n", name);
-	return EOK;
+	ddf_msg(LVL_NOTE, "Registered child device `%s'", name);
+	rc = EOK;
+
+leave:
+	if (rc != expected_rc) {
+		fprintf(stderr,
+		    NAME ": Unexpected error registering function `%s'.\n" 
+		    NAME ":     Expected \"%s\" but got \"%s\".\n",
+		    name, str_error(expected_rc), str_error(rc));
+	}
+
+	if ((rc != EOK) && (fun != NULL)) {
+		ddf_fun_destroy(fun);
+	}
+
+	return rc;
 }
 
@@ -112,10 +128,10 @@
 	int rc;
 
-	printf(NAME ": add_device(name=\"%s\", handle=%d)\n",
+	ddf_msg(LVL_DEBUG, "add_device(name=\"%s\", handle=%d)",
 	    dev->name, (int) dev->handle);
 
 	fun_a = ddf_fun_create(dev, fun_exposed, "a");
 	if (fun_a == NULL) {
-		printf(NAME ": error creating function 'a'.\n");
+		ddf_msg(LVL_ERROR, "Failed creating function 'a'.");
 		return ENOMEM;
 	}
@@ -123,5 +139,5 @@
 	rc = ddf_fun_bind(fun_a);
 	if (rc != EOK) {
-		printf(NAME ": error binding function 'a'.\n");
+		ddf_msg(LVL_ERROR, "Failed binding function 'a'.");
 		return rc;
 	}
@@ -133,12 +149,17 @@
 		ddf_fun_add_to_class(fun_a, "virt-null");
 	} else if (str_cmp(dev->name, "test1") == 0) {
-		(void) register_fun_verbose(dev, "cloning myself ;-)", "clone",
-		    "virtual&test1", 10);
+		(void) register_fun_verbose(dev,
+		    "cloning myself ;-)", "clone",
+		    "virtual&test1", 10, EOK);
+		(void) register_fun_verbose(dev,
+		    "cloning myself twice ;-)", "clone",
+		    "virtual&test1", 10, EEXISTS);
 	} else if (str_cmp(dev->name, "clone") == 0) {
-		(void) register_fun_verbose(dev, "run by the same task", "child",
-		    "virtual&test1&child", 10);
+		(void) register_fun_verbose(dev,
+		    "run by the same task", "child",
+		    "virtual&test1&child", 10, EOK);
 	}
 
-	printf(NAME ": device `%s' accepted.\n", dev->name);
+	ddf_msg(LVL_DEBUG, "Device `%s' accepted.", dev->name);
 
 	return EOK;
@@ -148,4 +169,5 @@
 {
 	printf(NAME ": HelenOS test1 virtual device driver\n");
+	ddf_log_init(NAME, LVL_ERROR);
 	return ddf_driver_main(&test1_driver);
 }
Index: uspace/drv/test2/test2.c
===================================================================
--- uspace/drv/test2/test2.c	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/drv/test2/test2.c	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -36,4 +36,5 @@
 #include <str_error.h>
 #include <ddf/driver.h>
+#include <ddf/log.h>
 
 #define NAME "test2"
@@ -64,9 +65,9 @@
 	int rc;
 
-	printf(NAME ": registering function `%s': %s.\n", name, message);
+	ddf_msg(LVL_DEBUG, "Registering function `%s': %s.", name, message);
 
 	fun = ddf_fun_create(parent, fun_inner, name);
 	if (fun == NULL) {
-		printf(NAME ": error creating function %s\n", name);
+		ddf_msg(LVL_ERROR, "Failed creating function %s", name);
 		return ENOMEM;
 	}
@@ -74,5 +75,6 @@
 	rc = ddf_fun_add_match_id(fun, match_id, match_score);
 	if (rc != EOK) {
-		printf(NAME ": error adding match IDs to function %s\n", name);
+		ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s",
+		    name);
 		ddf_fun_destroy(fun);
 		return rc;
@@ -81,5 +83,5 @@
 	rc = ddf_fun_bind(fun);
 	if (rc != EOK) {
-		printf(NAME ": error binding function %s: %s\n", name,
+		ddf_msg(LVL_ERROR, "Failed binding function %s: %s", name,
 		    str_error(rc));
 		ddf_fun_destroy(fun);
@@ -87,5 +89,5 @@
 	}
 
-	printf(NAME ": registered child device `%s'\n", name);
+	ddf_msg(LVL_NOTE, "Registered child device `%s'", name);
 	return EOK;
 }
@@ -111,5 +113,5 @@
 	fun_a = ddf_fun_create(dev, fun_exposed, "a");
 	if (fun_a == NULL) {
-		printf(NAME ": error creating function 'a'.\n");
+		ddf_msg(LVL_ERROR, "Failed creating function 'a'.");
 		return ENOMEM;
 	}
@@ -117,5 +119,5 @@
 	rc = ddf_fun_bind(fun_a);
 	if (rc != EOK) {
-		printf(NAME ": error binding function 'a'.\n");
+		ddf_msg(LVL_ERROR, "Failed binding function 'a'.");
 		return rc;
 	}
@@ -128,5 +130,5 @@
 static int test2_add_device(ddf_dev_t *dev)
 {
-	printf(NAME ": test2_add_device(name=\"%s\", handle=%d)\n",
+	ddf_msg(LVL_DEBUG, "test2_add_device(name=\"%s\", handle=%d)",
 	    dev->name, (int) dev->handle);
 
@@ -134,5 +136,5 @@
 		fid_t postpone = fibril_create(postponed_birth, dev);
 		if (postpone == 0) {
-			printf(NAME ": fibril_create() error\n");
+			ddf_msg(LVL_ERROR, "fibril_create() failed.");
 			return ENOMEM;
 		}
@@ -149,4 +151,5 @@
 {
 	printf(NAME ": HelenOS test2 virtual device driver\n");
+	ddf_log_init(NAME, LVL_ERROR);
 	return ddf_driver_main(&test2_driver);
 }
Index: uspace/lib/c/Makefile
===================================================================
--- uspace/lib/c/Makefile	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/lib/c/Makefile	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -76,4 +76,5 @@
 	generic/io/io.c \
 	generic/io/printf.c \
+	generic/io/log.c \
 	generic/io/klog.c \
 	generic/io/snprintf.c \
Index: uspace/lib/c/arch/abs32le/_link.ld.in
===================================================================
--- uspace/lib/c/arch/abs32le/_link.ld.in	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/lib/c/arch/abs32le/_link.ld.in	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -11,6 +11,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
Index: uspace/lib/c/arch/amd64/_link.ld.in
===================================================================
--- uspace/lib/c/arch/amd64/_link.ld.in	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/lib/c/arch/amd64/_link.ld.in	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -16,6 +16,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
Index: uspace/lib/c/arch/arm32/_link.ld.in
===================================================================
--- uspace/lib/c/arch/arm32/_link.ld.in	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/lib/c/arch/arm32/_link.ld.in	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -15,6 +15,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
Index: uspace/lib/c/arch/ia32/_link.ld.in
===================================================================
--- uspace/lib/c/arch/ia32/_link.ld.in	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/lib/c/arch/ia32/_link.ld.in	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -16,6 +16,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
Index: uspace/lib/c/arch/ia64/_link.ld.in
===================================================================
--- uspace/lib/c/arch/ia64/_link.ld.in	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/lib/c/arch/ia64/_link.ld.in	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -15,6 +15,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
@@ -23,5 +23,5 @@
 	.got : {
 		_gp = .;
-		*(.got*);
+		*(.got .got.*);
 	} :data
 	
Index: uspace/lib/c/arch/mips32/_link.ld.in
===================================================================
--- uspace/lib/c/arch/mips32/_link.ld.in	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/lib/c/arch/mips32/_link.ld.in	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -15,6 +15,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
Index: uspace/lib/c/arch/ppc32/_link.ld.in
===================================================================
--- uspace/lib/c/arch/ppc32/_link.ld.in	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/lib/c/arch/ppc32/_link.ld.in	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -15,6 +15,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
Index: uspace/lib/c/arch/sparc64/_link.ld.in
===================================================================
--- uspace/lib/c/arch/sparc64/_link.ld.in	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/lib/c/arch/sparc64/_link.ld.in	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -15,6 +15,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
Index: uspace/lib/c/generic/devman.c
===================================================================
--- uspace/lib/c/generic/devman.c	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/lib/c/generic/devman.c	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -147,6 +147,4 @@
 		ret = devman_send_match_id(phone, match_id);
 		if (ret != EOK) {
-			printf("Driver failed to send match id, error %d\n",
-			    ret);
 			return ret;
 		}
@@ -195,10 +193,15 @@
 	}
 	
-	devman_send_match_ids(phone, match_ids);
-	
-	async_wait_for(req, &retval);
-	
-	async_serialize_end();
-	
+	int match_ids_rc = devman_send_match_ids(phone, match_ids);
+	
+	async_wait_for(req, &retval);
+	
+	async_serialize_end();
+	
+	/* Prefer the answer to DEVMAN_ADD_FUNCTION in case of errors. */
+	if ((match_ids_rc != EOK) && (retval == EOK)) {
+		retval = match_ids_rc;
+	}
+
 	if (retval == EOK)
 		fun_handle = (int) IPC_GET_ARG1(answer);
@@ -326,4 +329,49 @@
 }
 
+int devman_device_get_handle_by_class(const char *classname,
+    const char *devname, devman_handle_t *handle, unsigned int flags)
+{
+	int phone = devman_get_phone(DEVMAN_CLIENT, flags);
+
+	if (phone < 0)
+		return phone;
+
+	async_serialize_start();
+
+	ipc_call_t answer;
+	aid_t req = async_send_1(phone, DEVMAN_DEVICE_GET_HANDLE_BY_CLASS,
+	    flags, &answer);
+
+	sysarg_t retval = async_data_write_start(phone, classname,
+	    str_size(classname));
+	if (retval != EOK) {
+		async_wait_for(req, NULL);
+		async_serialize_end();
+		return retval;
+	}
+	retval = async_data_write_start(phone, devname,
+	    str_size(devname));
+	if (retval != EOK) {
+		async_wait_for(req, NULL);
+		async_serialize_end();
+		return retval;
+	}
+
+	async_wait_for(req, &retval);
+
+	async_serialize_end();
+
+	if (retval != EOK) {
+		if (handle != NULL)
+			*handle = (devman_handle_t) -1;
+		return retval;
+	}
+
+	if (handle != NULL)
+		*handle = (devman_handle_t) IPC_GET_ARG1(answer);
+
+	return retval;
+}
+
 
 /** @}
Index: uspace/lib/c/generic/io/log.c
===================================================================
--- uspace/lib/c/generic/io/log.c	(revision ea5352913e3f4737d9d751831020498633794587)
+++ uspace/lib/c/generic/io/log.c	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2011 Vojtech Horky
+ * Copyright (c) 2011 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 libc
+ * @{
+ */
+
+#include <assert.h>
+#include <errno.h>
+#include <fibril_synch.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <io/log.h>
+
+/** Serialization mutex for logging functions. */
+static FIBRIL_MUTEX_INITIALIZE(log_serializer);
+
+/** Current log level. */
+static log_level_t log_level;
+
+static FILE *log_stream;
+
+static const char *log_prog_name;
+
+/** Prefixes for individual logging levels. */
+static const char *log_level_names[] = {
+	[LVL_FATAL] = "Fatal error",
+	[LVL_ERROR] = "Error",
+	[LVL_WARN] = "Warning",
+	[LVL_NOTE] = "Note",
+	[LVL_DEBUG] = "Debug",
+	[LVL_DEBUG2] = "Debug2"
+};
+
+/** Initialize the logging system.
+ *
+ * @param prog_name	Program name, will be printed as part of message
+ * @param level		Minimum message level to print
+ */
+int log_init(const char *prog_name, log_level_t level)
+{
+	assert(level < LVL_LIMIT);
+	log_level = level;
+
+	log_stream = stdout;
+	log_prog_name = str_dup(prog_name);
+	if (log_prog_name == NULL)
+		return ENOMEM;
+
+	return EOK;
+}
+
+/** Write an entry to the log.
+ *
+ * @param level		Message verbosity level. Message is only printed
+ *			if verbosity is less than or equal to current
+ *			reporting level.
+ * @param fmt		Format string (no traling newline).
+ */
+void log_msg(log_level_t level, const char *fmt, ...)
+{
+	va_list args;
+
+	va_start(args, fmt);
+	log_msgv(level, fmt, args);
+	va_end(args);
+}
+
+/** Write an entry to the log (va_list variant).
+ *
+ * @param level		Message verbosity level. Message is only printed
+ *			if verbosity is less than or equal to current
+ *			reporting level.
+ * @param fmt		Format string (no trailing newline)
+ */
+void log_msgv(log_level_t level, const char *fmt, va_list args)
+{
+	assert(level < LVL_LIMIT);
+
+	/* Higher number means higher verbosity. */
+	if (level <= log_level) {
+		fibril_mutex_lock(&log_serializer);
+
+		fprintf(log_stream, "%s: %s: ", log_prog_name,
+		    log_level_names[level]);
+		vfprintf(log_stream, fmt, args);
+		fputc('\n', log_stream);
+		fflush(log_stream);
+
+		fibril_mutex_unlock(&log_serializer);
+	}
+}
+
+/** @}
+ */
Index: uspace/lib/c/generic/vfs/vfs.c
===================================================================
--- uspace/lib/c/generic/vfs/vfs.c	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/lib/c/generic/vfs/vfs.c	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -756,8 +756,9 @@
 {
 	struct stat stat;
-	int rc;
-
-	rc = fstat(fildes, &stat);
-
+	
+	int rc = fstat(fildes, &stat);
+	if (rc != 0)
+		return rc;
+	
 	if (!stat.device)
 		return -1;
Index: uspace/lib/c/include/devman.h
===================================================================
--- uspace/lib/c/include/devman.h	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/lib/c/include/devman.h	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -53,4 +53,6 @@
 extern int devman_device_get_handle(const char *, devman_handle_t *,
     unsigned int);
+extern int devman_device_get_handle_by_class(const char *, const char *,
+    devman_handle_t *, unsigned int);
 
 extern int devman_add_device_to_class(devman_handle_t, const char *);
Index: uspace/lib/c/include/io/log.h
===================================================================
--- uspace/lib/c/include/io/log.h	(revision ea5352913e3f4737d9d751831020498633794587)
+++ uspace/lib/c/include/io/log.h	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2011 Vojtech Horky
+ * Copyright (c) 2011 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 libc
+ * @{
+ */
+
+#ifndef LIBC_IO_LOG_H_
+#define LIBC_IO_LOG_H_
+
+#include <stdarg.h>
+
+typedef enum {
+	LVL_FATAL,
+	LVL_ERROR,
+	LVL_WARN,
+	LVL_NOTE,
+	LVL_DEBUG,
+	LVL_DEBUG2,
+
+	/** For checking range of values */
+	LVL_LIMIT
+} log_level_t;
+
+extern int log_init(const char *, log_level_t);
+extern void log_msg(log_level_t, const char *, ...);
+extern void log_msgv(log_level_t, const char *, va_list);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/include/ipc/devman.h
===================================================================
--- uspace/lib/c/include/ipc/devman.h	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/lib/c/include/ipc/devman.h	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -148,5 +148,6 @@
 
 typedef enum {
-	DEVMAN_DEVICE_GET_HANDLE = IPC_FIRST_USER_METHOD
+	DEVMAN_DEVICE_GET_HANDLE = IPC_FIRST_USER_METHOD,
+	DEVMAN_DEVICE_GET_HANDLE_BY_CLASS
 } client_to_devman_t;
 
Index: uspace/lib/drv/Makefile
===================================================================
--- uspace/lib/drv/Makefile	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/lib/drv/Makefile	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -35,4 +35,5 @@
 	generic/driver.c \
 	generic/dev_iface.c \
+	generic/log.c \
 	generic/remote_hw_res.c \
 	generic/remote_char_dev.c
Index: uspace/lib/drv/generic/driver.c
===================================================================
--- uspace/lib/drv/generic/driver.c	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/lib/drv/generic/driver.c	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -273,12 +273,6 @@
 	
 	res = driver->driver_ops->add_device(dev);
-	if (res == EOK) {
-		printf("%s: new device with handle=%" PRIun " was added.\n",
-		    driver->name, dev_handle);
-	} else {
-		printf("%s: failed to add a new device with handle = %" PRIun ".\n",
-		    driver->name, dev_handle);
+	if (res != EOK)
 		delete_device(dev);
-	}
 	
 	async_answer_0(iid, res);
Index: uspace/lib/drv/generic/log.c
===================================================================
--- uspace/lib/drv/generic/log.c	(revision ea5352913e3f4737d9d751831020498633794587)
+++ uspace/lib/drv/generic/log.c	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2011 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 libdrv
+ * @{
+ */
+
+#include <io/log.h>
+#include <stdarg.h>
+
+#include <ddf/log.h>
+
+/** Initialize the logging system.
+ *
+ * @param drv_name	Driver name, will be printed as part of message
+ * @param level		Minimum message level to print
+ */
+int ddf_log_init(const char *drv_name, log_level_t level)
+{
+	return log_init(drv_name, level);
+}
+
+/** Log a driver message.
+ *
+ * @param level		Message verbosity level. Message is only printed
+ *			if verbosity is less than or equal to current
+ *			reporting level.
+ * @param fmt		Format string (no trailing newline)
+ */
+void ddf_msg(log_level_t level, const char *fmt, ...)
+{
+	va_list args;
+
+	va_start(args, fmt);
+	log_msgv(level, fmt, args);
+	va_end(args);
+}
+
+/** @}
+ */
Index: uspace/lib/drv/include/ddf/log.h
===================================================================
--- uspace/lib/drv/include/ddf/log.h	(revision ea5352913e3f4737d9d751831020498633794587)
+++ uspace/lib/drv/include/ddf/log.h	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2011 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 libdrv
+ * @{
+ */
+
+#ifndef DDF_LOG_H_
+#define DDF_LOG_H_
+
+#include <io/log.h>
+
+extern int ddf_log_init(const char *, log_level_t);
+extern void ddf_msg(log_level_t, const char *, ...);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/packet/include/netdb.h
===================================================================
--- uspace/lib/packet/include/netdb.h	(revision ea5352913e3f4737d9d751831020498633794587)
+++ uspace/lib/packet/include/netdb.h	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2009 Lukas Mejdrech
+ * 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 netdb
+ *  @{
+ */
+
+/** @file
+ *  Structures and interfaces according to the BSD netdb.h file.
+ */
+
+#ifndef __NET_NETDB_H__
+#define __NET_NETDB_H__
+
+#include <sys/types.h>
+
+/** Structure returned by network data base library.
+ *  All addresses are supplied in host order, and returned in network order (suitable for use in system calls).
+ */
+struct	hostent {
+	/** Official host name.
+	 */
+	char * h_name;
+	/** Alias list.
+	 */
+	char **	h_aliases;
+	/** Host address type.
+	 */
+	int h_addrtype;
+	/** Address length.
+	 */
+	int h_length;
+	/** List of addresses from name server.
+	 */
+	char **	h_addr_list;
+	/** Address, for backward compatiblity.
+	 */
+#define	h_addr	h_addr_list[0]
+};
+
+/** @name Host entry address types definitions.
+ */
+/*@{*/
+
+/** Authoritative Answer Host not found address type.
+ */
+#define	HOST_NOT_FOUND	1
+
+/** Non-Authoritive Host not found, or SERVERFAIL address type.
+ */
+#define	TRY_AGAIN	2
+
+/** Non recoverable errors, FORMERR, REFUSED, NOTIMP address type.
+ */
+#define	NO_RECOVERY	3
+
+/** Valid name, no data record of requested type address type.
+ */
+#define	NO_DATA		4
+
+/** No address, look for MX record address type.
+ */
+#define	NO_ADDRESS	NO_DATA
+
+/*@}*/
+
+/** Returns host entry by the host address.
+ *  @param[in] address The host address.
+ *  @param[in] len The address length.
+ *  @param[in] type The address type.
+ *  @returns Host entry information.
+ */
+//struct hostent *	gethostbyaddr(const void * address, int len, int type);
+
+/** Returns host entry by the host name.
+ *  @param[in] name The host name.
+ *  @returns Host entry information.
+ */
+//struct hostent *	gethostbyname(const char * name);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/packet/include/tcp_codes.h
===================================================================
--- uspace/lib/packet/include/tcp_codes.h	(revision ea5352913e3f4737d9d751831020498633794587)
+++ uspace/lib/packet/include/tcp_codes.h	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2009 Lukas Mejdrech
+ * 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 tcp
+ *  @{
+ */
+
+/** @file
+ *  TCP options definitions.
+ */
+
+#ifndef __NET_TCP_CODES_H__
+#define __NET_TCP_CODES_H__
+
+/** End of list TCP option.
+ */
+#define TCPOPT_END_OF_LIST				0x0
+
+/** No operation TCP option.
+ */
+#define TCPOPT_NO_OPERATION				0x1
+
+/** Maximum segment size TCP option.
+ */
+#define TCPOPT_MAX_SEGMENT_SIZE			0x2
+
+/** Maximum segment size TCP option length.
+ */
+#define TCPOPT_MAX_SEGMENT_SIZE_LENGTH	4
+
+/** Window scale TCP option.
+ */
+#define TCPOPT_WINDOW_SCALE				0x3
+
+/** Window scale TCP option length.
+ */
+#define TCPOPT_WINDOW_SCALE_LENGTH		3
+
+/** Selective acknowledgement permitted TCP option.
+ */
+#define TCPOPT_SACK_PERMITTED			0x4
+
+/** Selective acknowledgement permitted TCP option length.
+ */
+#define TCPOPT_SACK_PERMITTED_LENGTH	2
+
+/** Selective acknowledgement TCP option.
+ *  Has variable length.
+ */
+#define TCPOPT_SACK						0x5
+
+/** Timestamp TCP option.
+ */
+#define TCPOPT_TIMESTAMP				0x8
+
+/** Timestamp TCP option length.
+ */
+#define TCPOPT_TIMESTAMP_LENGTH			10
+
+#endif
+
+/** @}
+ */
Index: uspace/srv/devman/devman.c
===================================================================
--- uspace/srv/devman/devman.c	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/srv/devman/devman.c	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -34,4 +34,5 @@
 #include <fcntl.h>
 #include <sys/stat.h>
+#include <io/log.h>
 #include <ipc/driver.h>
 #include <ipc/devman.h>
@@ -146,6 +147,6 @@
 	fibril_mutex_unlock(&drivers_list->drivers_mutex);
 
-	printf(NAME": the '%s' driver was added to the list of available "
-	    "drivers.\n", drv->name);
+	log_msg(LVL_NOTE, "Driver `%s' was added to the list of available "
+	    "drivers.", drv->name);
 }
 
@@ -237,5 +238,5 @@
 bool read_match_ids(const char *conf_path, match_id_list_t *ids)
 {
-	printf(NAME ": read_match_ids conf_path = %s.\n", conf_path);
+	log_msg(LVL_DEBUG, "read_match_ids(conf_path=\"%s\")", conf_path);
 	
 	bool suc = false;
@@ -247,5 +248,6 @@
 	fd = open(conf_path, O_RDONLY);
 	if (fd < 0) {
-		printf(NAME ": unable to open %s\n", conf_path);
+		log_msg(LVL_ERROR, "Unable to open `%s' for reading: %s.",
+		    conf_path, str_error(fd));
 		goto cleanup;
 	}
@@ -255,5 +257,6 @@
 	lseek(fd, 0, SEEK_SET);
 	if (len == 0) {
-		printf(NAME ": configuration file '%s' is empty.\n", conf_path);
+		log_msg(LVL_ERROR, "Configuration file '%s' is empty.",
+		    conf_path);
 		goto cleanup;
 	}
@@ -261,6 +264,6 @@
 	buf = malloc(len + 1);
 	if (buf == NULL) {
-		printf(NAME ": memory allocation failed when parsing file "
-		    "'%s'.\n", conf_path);
+		log_msg(LVL_ERROR, "Memory allocation failed when parsing file "
+		    "'%s'.", conf_path);
 		goto cleanup;
 	}
@@ -268,5 +271,5 @@
 	ssize_t read_bytes = safe_read(fd, buf, len);
 	if (read_bytes <= 0) {
-		printf(NAME ": unable to read file '%s'.\n", conf_path);
+		log_msg(LVL_ERROR, "Unable to read file '%s'.", conf_path);
 		goto cleanup;
 	}
@@ -306,5 +309,5 @@
 bool get_driver_info(const char *base_path, const char *name, driver_t *drv)
 {
-	printf(NAME ": get_driver_info base_path = %s, name = %s.\n",
+	log_msg(LVL_DEBUG, "get_driver_info(base_path=\"%s\", name=\"%s\")",
 	    base_path, name);
 	
@@ -338,5 +341,6 @@
 	struct stat s;
 	if (stat(drv->binary_path, &s) == ENOENT) { /* FIXME!! */
-		printf(NAME ": driver not found at path %s.", drv->binary_path);
+		log_msg(LVL_ERROR, "Driver not found at path `%s'.",
+		    drv->binary_path);
 		goto cleanup;
 	}
@@ -365,5 +369,5 @@
 int lookup_available_drivers(driver_list_t *drivers_list, const char *dir_path)
 {
-	printf(NAME ": lookup_available_drivers, dir = %s \n", dir_path);
+	log_msg(LVL_DEBUG, "lookup_available_drivers(dir=\"%s\")", dir_path);
 	
 	int drv_cnt = 0;
@@ -399,5 +403,5 @@
 	dev_node_t *dev;
 	
-	printf(NAME ": create_root_nodes\n");
+	log_msg(LVL_DEBUG, "create_root_nodes()");
 	
 	fibril_rwlock_write_lock(&tree->rwlock);
@@ -484,6 +488,6 @@
 void attach_driver(dev_node_t *dev, driver_t *drv)
 {
-	printf(NAME ": attach_driver %s to device %s\n",
-	    drv->name, dev->pfun->pathname);
+	log_msg(LVL_DEBUG, "attach_driver(dev=\"%s\",drv=\"%s\")",
+	    dev->pfun->pathname, drv->name);
 	
 	fibril_mutex_lock(&drv->driver_mutex);
@@ -507,10 +511,10 @@
 	assert(fibril_mutex_is_locked(&drv->driver_mutex));
 	
-	printf(NAME ": start_driver '%s'\n", drv->name);
+	log_msg(LVL_DEBUG, "start_driver(drv=\"%s\")", drv->name);
 	
 	rc = task_spawnl(NULL, drv->binary_path, drv->binary_path, NULL);
 	if (rc != EOK) {
-		printf(NAME ": error spawning %s (%s)\n",
-		    drv->name, str_error(rc));
+		log_msg(LVL_ERROR, "Spawning driver `%s' (%s) failed: %s.",
+		    drv->name, drv->binary_path, str_error(rc));
 		return false;
 	}
@@ -574,5 +578,6 @@
 	int phone;
 
-	printf(NAME ": pass_devices_to_driver(`%s')\n", driver->name);
+	log_msg(LVL_DEBUG, "pass_devices_to_driver(driver=\"%s\")",
+	    driver->name);
 
 	fibril_mutex_lock(&driver->driver_mutex);
@@ -641,5 +646,5 @@
 	 * immediately and possibly started here as well.
 	 */
-	printf(NAME ": driver %s goes into running state.\n", driver->name);
+	log_msg(LVL_DEBUG, "Driver `%s' enters running state.", driver->name);
 	driver->state = DRIVER_RUNNING;
 
@@ -658,5 +663,6 @@
 void initialize_running_driver(driver_t *driver, dev_tree_t *tree)
 {
-	printf(NAME ": initialize_running_driver (`%s')\n", driver->name);
+	log_msg(LVL_DEBUG, "initialize_running_driver(driver=\"%s\")",
+	    driver->name);
 	
 	/*
@@ -748,6 +754,6 @@
 	 * access any structures that would affect driver_t.
 	 */
-	printf(NAME ": add_device (driver `%s', device `%s')\n", drv->name,
-	    dev->pfun->name);
+	log_msg(LVL_DEBUG, "add_device(drv=\"%s\", dev=\"%s\")",
+	    drv->name, dev->pfun->name);
 	
 	sysarg_t rc;
@@ -810,5 +816,5 @@
 	driver_t *drv = find_best_match_driver(drivers_list, dev);
 	if (drv == NULL) {
-		printf(NAME ": no driver found for device '%s'.\n",
+		log_msg(LVL_ERROR, "No driver found for device `%s'.",
 		    dev->pfun->pathname);
 		return false;
@@ -848,5 +854,5 @@
 bool init_device_tree(dev_tree_t *tree, driver_list_t *drivers_list)
 {
-	printf(NAME ": init_device_tree.\n");
+	log_msg(LVL_DEBUG, "init_device_tree()");
 	
 	tree->current_handle = 0;
@@ -1027,5 +1033,5 @@
 	fun->pathname = (char *) malloc(pathsize);
 	if (fun->pathname == NULL) {
-		printf(NAME ": failed to allocate device path.\n");
+		log_msg(LVL_ERROR, "Failed to allocate device path.");
 		return false;
 	}
@@ -1058,4 +1064,7 @@
 	assert(fibril_rwlock_is_write_locked(&tree->rwlock));
 	
+	log_msg(LVL_DEBUG, "insert_dev_node(dev=%p, pfun=%p [\"%s\"])",
+	    dev, pfun, pfun->pathname);
+
 	/* Add the node to the handle-to-node map. */
 	dev->handle = ++tree->current_handle;
@@ -1064,5 +1073,4 @@
 
 	/* Add the node to the list of its parent's children. */
-	printf("insert_dev_node: dev=%p, dev->pfun := %p\n", dev, pfun);
 	dev->pfun = pfun;
 	pfun->child = dev;
@@ -1165,4 +1173,63 @@
 }
 
+/** Find function with a specified name belonging to given device.
+ *
+ * Device tree rwlock should be held at least for reading.
+ *
+ * @param dev Device the function belongs to.
+ * @param name Function name (not path).
+ * @return Function node.
+ * @retval NULL No function with given name.
+ */
+fun_node_t *find_fun_node_in_device(dev_node_t *dev, const char *name)
+{
+	assert(dev != NULL);
+	assert(name != NULL);
+
+	fun_node_t *fun;
+	link_t *link;
+
+	for (link = dev->functions.next;
+	    link != &dev->functions;
+	    link = link->next) {
+		fun = list_get_instance(link, fun_node_t, dev_functions);
+
+		if (str_cmp(name, fun->name) == 0)
+			return fun;
+	}
+
+	return NULL;
+}
+
+/** Find function node by its class name and index. */
+fun_node_t *find_fun_node_by_class(class_list_t *class_list,
+    const char *class_name, const char *dev_name)
+{
+	assert(class_list != NULL);
+	assert(class_name != NULL);
+	assert(dev_name != NULL);
+
+	fibril_rwlock_read_lock(&class_list->rwlock);
+
+	dev_class_t *cl = find_dev_class_no_lock(class_list, class_name);
+	if (cl == NULL) {
+		fibril_rwlock_read_unlock(&class_list->rwlock);
+		return NULL;
+	}
+
+	dev_class_info_t *dev = find_dev_in_class(cl, dev_name);
+	if (dev == NULL) {
+		fibril_rwlock_read_unlock(&class_list->rwlock);
+		return NULL;
+	}
+
+	fun_node_t *fun = dev->fun;
+
+	fibril_rwlock_read_unlock(&class_list->rwlock);
+
+	return fun;
+}
+
+
 /** Find child function node with a specified name.
  *
@@ -1175,19 +1242,5 @@
 fun_node_t *find_node_child(fun_node_t *pfun, const char *name)
 {
-	fun_node_t *fun;
-	link_t *link;
-	
-	link = pfun->child->functions.next;
-	
-	while (link != &pfun->child->functions) {
-		fun = list_get_instance(link, fun_node_t, dev_functions);
-		
-		if (str_cmp(name, fun->name) == 0)
-			return fun;
-		
-		link = link->next;
-	}
-	
-	return NULL;
+	return find_fun_node_in_device(pfun->child, name);
 }
 
@@ -1351,4 +1404,24 @@
 }
 
+dev_class_info_t *find_dev_in_class(dev_class_t *dev_class, const char *dev_name)
+{
+	assert(dev_class != NULL);
+	assert(dev_name != NULL);
+
+	link_t *link;
+	for (link = dev_class->devices.next;
+	    link != &dev_class->devices;
+	    link = link->next) {
+		dev_class_info_t *dev = list_get_instance(link,
+		    dev_class_info_t, link);
+
+		if (str_cmp(dev->dev_name, dev_name) == 0) {
+			return dev;
+		}
+	}
+
+	return NULL;
+}
+
 void init_class_list(class_list_t *class_list)
 {
Index: uspace/srv/devman/devman.h
===================================================================
--- uspace/srv/devman/devman.h	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/srv/devman/devman.h	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -338,4 +338,6 @@
 extern fun_node_t *find_fun_node(dev_tree_t *tree, devman_handle_t handle);
 extern fun_node_t *find_fun_node_by_path(dev_tree_t *, char *);
+extern fun_node_t *find_fun_node_in_device(dev_node_t *, const char *);
+extern fun_node_t *find_fun_node_by_class(class_list_t *, const char *, const char *);
 
 /* Device tree */
@@ -359,4 +361,5 @@
 extern dev_class_t *get_dev_class(class_list_t *, char *);
 extern dev_class_t *find_dev_class_no_lock(class_list_t *, const char *);
+extern dev_class_info_t *find_dev_in_class(dev_class_t *, const char *);
 extern void add_dev_class_no_lock(class_list_t *, dev_class_t *);
 
Index: uspace/srv/devman/main.c
===================================================================
--- uspace/srv/devman/main.c	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/srv/devman/main.c	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -43,4 +43,5 @@
 #include <stdio.h>
 #include <errno.h>
+#include <str_error.h>
 #include <bool.h>
 #include <fibril_synch.h>
@@ -51,4 +52,5 @@
 #include <sys/stat.h>
 #include <ctype.h>
+#include <io/log.h>
 #include <ipc/devman.h>
 #include <ipc/driver.h>
@@ -71,5 +73,5 @@
 	driver_t *driver = NULL;
 
-	printf(NAME ": devman_driver_register \n");
+	log_msg(LVL_DEBUG, "devman_driver_register");
 	
 	iid = async_get_call(&icall);
@@ -88,5 +90,5 @@
 	}
 
-	printf(NAME ": the %s driver is trying to register by the service.\n",
+	log_msg(LVL_DEBUG, "The `%s' driver is trying to register.",
 	    drv_name);
 	
@@ -95,5 +97,5 @@
 	
 	if (driver == NULL) {
-		printf(NAME ": no driver named %s was found.\n", drv_name);
+		log_msg(LVL_ERROR, "No driver named `%s' was found.", drv_name);
 		free(drv_name);
 		drv_name = NULL;
@@ -106,5 +108,6 @@
 	
 	/* Create connection to the driver. */
-	printf(NAME ":  creating connection to the %s driver.\n", driver->name);
+	log_msg(LVL_DEBUG, "Creating connection to the `%s' driver.",
+	    driver->name);
 	ipc_call_t call;
 	ipc_callid_t callid = async_get_call(&call);
@@ -118,5 +121,6 @@
 	set_driver_phone(driver, IPC_GET_ARG5(call));
 	
-	printf(NAME ": the %s driver was successfully registered as running.\n",
+	log_msg(LVL_NOTE, 
+	    "The `%s' driver was successfully registered as running.",
 	    driver->name);
 	
@@ -142,6 +146,6 @@
 	callid = async_get_call(&call);
 	if (DEVMAN_ADD_MATCH_ID != IPC_GET_IMETHOD(call)) {
-		printf(NAME ": ERROR: devman_receive_match_id - invalid "
-		    "protocol.\n");
+		log_msg(LVL_ERROR, 
+		    "Invalid protocol when trying to receive match id.");
 		async_answer_0(callid, EINVAL); 
 		delete_match_id(match_id);
@@ -150,6 +154,5 @@
 	
 	if (match_id == NULL) {
-		printf(NAME ": ERROR: devman_receive_match_id - failed to "
-		    "allocate match id.\n");
+		log_msg(LVL_ERROR, "Failed to allocate match id.");
 		async_answer_0(callid, ENOMEM);
 		return ENOMEM;
@@ -165,6 +168,6 @@
 	if (rc != EOK) {
 		delete_match_id(match_id);
-		printf(NAME ": devman_receive_match_id - failed to receive "
-		    "match id string.\n");
+		log_msg(LVL_ERROR, "Failed to receive match id string: %s.",
+		    str_error(rc));
 		return rc;
 	}
@@ -172,5 +175,5 @@
 	list_append(&match_id->link, &match_ids->ids);
 	
-	printf(NAME ": received match id '%s', score = %d \n",
+	log_msg(LVL_DEBUG, "Received match id `%s', score %d.",
 	    match_id->id, match_id->score);
 	return rc;
@@ -228,5 +231,7 @@
 	if (ftype != fun_inner && ftype != fun_exposed) {
 		/* Unknown function type */
-		printf(NAME ": Error, unknown function type provided by driver!\n");
+		log_msg(LVL_ERROR, 
+		    "Unknown function type %d provided by driver.",
+		    (int) ftype);
 
 		fibril_rwlock_write_unlock(&tree->rwlock);
@@ -243,4 +248,14 @@
 	}
 	
+	/* Check that function with same name is not there already. */
+	if (find_fun_node_in_device(pdev, fun_name) != NULL) {
+		fibril_rwlock_write_unlock(&tree->rwlock);
+		async_answer_0(callid, EEXISTS);
+		printf(NAME ": Warning, driver tried to register `%s' twice.\n",
+		    fun_name);
+		free(fun_name);
+		return;
+	}
+
 	fun_node_t *fun = create_fun_node();
 	if (!insert_fun_node(&device_tree, fun, fun_name, pdev)) {
@@ -265,5 +280,5 @@
 	fibril_rwlock_write_unlock(&tree->rwlock);
 	
-	printf(NAME ": devman_add_function %s\n", fun->pathname);
+	log_msg(LVL_DEBUG, "devman_add_function(fun=\"%s\")", fun->pathname);
 	
 	devman_receive_match_ids(match_count, &fun->match_ids);
@@ -347,6 +362,6 @@
 	devmap_register_class_dev(class_info);
 	
-	printf(NAME ": function'%s' added to class '%s', class name '%s' was "
-	    "asigned to it\n", fun->pathname, class_name, class_info->dev_name);
+	log_msg(LVL_NOTE, "Function `%s' added to class `%s' as `%s'.",
+	    fun->pathname, class_name, class_info->dev_name);
 
 	async_answer_0(callid, EOK);
@@ -363,5 +378,5 @@
 	
 	initialize_running_driver(driver, &device_tree);
-	printf(NAME ": the %s driver was successfully initialized. \n",
+	log_msg(LVL_DEBUG, "The `%s` driver was successfully initialized.",
 	    driver->name);
 	return 0;
@@ -385,6 +400,6 @@
 	fid_t fid = fibril_create(init_running_drv, driver);
 	if (fid == 0) {
-		printf(NAME ": Error creating fibril for the initialization of "
-		    "the newly registered running driver.\n");
+		log_msg(LVL_ERROR, "Failed to create initialization fibril " \
+		    "for driver `%s'.", driver->name);
 		return;
 	}
@@ -438,4 +453,38 @@
 }
 
+/** Find handle for the device instance identified by device class name. */
+static void devman_function_get_handle_by_class(ipc_callid_t iid,
+    ipc_call_t *icall)
+{
+	char *classname;
+	char *devname;
+
+	int rc = async_data_write_accept((void **) &classname, true, 0, 0, 0, 0);
+	if (rc != EOK) {
+		async_answer_0(iid, rc);
+		return;
+	}
+	rc = async_data_write_accept((void **) &devname, true, 0, 0, 0, 0);
+	if (rc != EOK) {
+		free(classname);
+		async_answer_0(iid, rc);
+		return;
+	}
+
+
+	fun_node_t *fun = find_fun_node_by_class(&class_list,
+	    classname, devname);
+
+	free(classname);
+	free(devname);
+
+	if (fun == NULL) {
+		async_answer_0(iid, ENOENT);
+		return;
+	}
+
+	async_answer_1(iid, EOK, fun->handle);
+}
+
 
 /** Function for handling connections from a client to the device manager. */
@@ -457,4 +506,7 @@
 			devman_function_get_handle(callid, &call);
 			break;
+		case DEVMAN_DEVICE_GET_HANDLE_BY_CLASS:
+			devman_function_get_handle_by_class(callid, &call);
+			break;
 		default:
 			async_answer_0(callid, ENOENT);
@@ -484,6 +536,6 @@
 	 */
 	if (dev == NULL) {
-		printf(NAME ": devman_forward error - no device or function with "
-		    "handle %" PRIun " was found.\n", handle);
+		log_msg(LVL_ERROR, "IPC forwarding failed - no device or "
+		    "function with handle %" PRIun " was found.", handle);
 		async_answer_0(iid, ENOENT);
 		return;
@@ -491,6 +543,7 @@
 
 	if (fun == NULL && !drv_to_parent) {
-		printf(NAME ": devman_forward error - cannot connect to "
-		    "handle %" PRIun ", refers to a device.\n", handle);
+		log_msg(LVL_ERROR, NAME ": devman_forward error - cannot "
+		    "connect to handle %" PRIun ", refers to a device.",
+		    handle);
 		async_answer_0(iid, ENOENT);
 		return;
@@ -513,6 +566,6 @@
 	
 	if (driver == NULL) {
-		printf(NAME ": devman_forward error - the device is not in %" PRIun
-		    " usable state.\n", handle);
+		log_msg(LVL_ERROR, "IPC forwarding refused - " \
+		    "the device %" PRIun " is not in usable state.", handle);
 		async_answer_0(iid, ENOENT);
 		return;
@@ -526,7 +579,7 @@
 	
 	if (driver->phone <= 0) {
-		printf(NAME ": devman_forward: cound not forward to driver %s ",
-		    driver->name);
-		printf("the driver's phone is %" PRIun ").\n", driver->phone);
+		log_msg(LVL_ERROR, 
+		    "Could not forward to driver `%s' (phone is %d).",
+		    driver->name, (int) driver->phone);
 		async_answer_0(iid, EINVAL);
 		return;
@@ -534,9 +587,11 @@
 
 	if (fun != NULL) {
-		printf(NAME ": devman_forward: forward connection to function %s to "
-		    "driver %s.\n", fun->pathname, driver->name);
+		log_msg(LVL_DEBUG, 
+		    "Forwarding request for `%s' function to driver `%s'.",
+		    fun->pathname, driver->name);
 	} else {
-		printf(NAME ": devman_forward: forward connection to device %s to "
-		    "driver %s.\n", dev->pfun->pathname, driver->name);
+		log_msg(LVL_DEBUG, 
+		    "Forwarding request for `%s' device to driver `%s'.",
+		    dev->pfun->pathname, driver->name);
 	}
 
@@ -570,6 +625,7 @@
 	async_forward_fast(iid, dev->drv->phone, DRIVER_CLIENT, fun->handle, 0,
 	    IPC_FF_NONE);
-	printf(NAME ": devman_connection_devmapper: forwarded connection to "
-	    "device %s to driver %s.\n", fun->pathname, dev->drv->name);
+	log_msg(LVL_DEBUG, 
+	    "Forwarding devmapper request for `%s' function to driver `%s'.",
+	    fun->pathname, dev->drv->name);
 }
 
@@ -606,5 +662,5 @@
 static bool devman_init(void)
 {
-	printf(NAME ": devman_init - looking for available drivers.\n");
+	log_msg(LVL_DEBUG, "devman_init - looking for available drivers.");
 	
 	/* Initialize list of available drivers. */
@@ -612,13 +668,13 @@
 	if (lookup_available_drivers(&drivers_list,
 	    DRIVER_DEFAULT_STORE) == 0) {
-		printf(NAME " no drivers found.");
+		log_msg(LVL_FATAL, "No drivers found.");
 		return false;
 	}
 
-	printf(NAME ": devman_init  - list of drivers has been initialized.\n");
+	log_msg(LVL_DEBUG, "devman_init - list of drivers has been initialized.");
 
 	/* Create root device node. */
 	if (!init_device_tree(&device_tree, &drivers_list)) {
-		printf(NAME " failed to initialize device tree.");
+		log_msg(LVL_FATAL, "Failed to initialize device tree.");
 		return false;
 	}
@@ -641,6 +697,11 @@
 	printf(NAME ": HelenOS Device Manager\n");
 
+	if (log_init(NAME, LVL_ERROR) != EOK) {
+		printf(NAME ": Error initializing logging subsystem.\n");
+		return -1;
+	}
+
 	if (!devman_init()) {
-		printf(NAME ": Error while initializing service\n");
+		log_msg(LVL_ERROR, "Error while initializing service.");
 		return -1;
 	}
@@ -650,8 +711,10 @@
 
 	/* Register device manager at naming service. */
-	if (service_register(SERVICE_DEVMAN) != EOK)
+	if (service_register(SERVICE_DEVMAN) != EOK) {
+		log_msg(LVL_ERROR, "Failed registering as a service.");
 		return -1;
-
-	printf(NAME ": Accepting connections\n");
+	}
+
+	printf(NAME ": Accepting connections.\n");
 	async_manager();
 
Index: uspace/srv/devmap/devmap.c
===================================================================
--- uspace/srv/devmap/devmap.c	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/srv/devmap/devmap.c	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -551,5 +551,5 @@
 	if (devmap_device_find_name(namespace->name, device->name) != NULL) {
 		printf("%s: Device '%s/%s' already registered\n", NAME,
-		    device->namespace->name, device->name);
+		    namespace->name, device->name);
 		devmap_namespace_destroy(namespace);
 		fibril_mutex_unlock(&devices_list_mutex);
Index: uspace/srv/hw/bus/cuda_adb/cuda_adb.c
===================================================================
--- uspace/srv/hw/bus/cuda_adb/cuda_adb.c	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/srv/hw/bus/cuda_adb/cuda_adb.c	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -367,9 +367,9 @@
 static void cuda_irq_rcv_end(void *buf, size_t *len)
 {
-	uint8_t data, b;
-
+	uint8_t b;
+	
 	b = pio_read_8(&dev->b);
-	data = pio_read_8(&dev->sr);
-
+	pio_read_8(&dev->sr);
+	
 	if ((b & TREQ) == 0) {
 		instance->xstate = cx_receive;
@@ -379,7 +379,7 @@
 		cuda_send_start();
 	}
-
-        memcpy(buf, instance->rcv_buf, instance->bidx);
-        *len = instance->bidx;
+	
+	memcpy(buf, instance->rcv_buf, instance->bidx);
+	*len = instance->bidx;
 	instance->bidx = 0;
 }
Index: uspace/srv/hw/netif/ne2000/dp8390_drv.h
===================================================================
--- uspace/srv/hw/netif/ne2000/dp8390_drv.h	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ 	(revision )
@@ -1,84 +1,0 @@
-/*
- * Copyright (c) 2009 Lukas Mejdrech
- * 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 dp8390
- *  @{
- */
-
-/** @file
- *  DP8390 network interface driver interface.
- */
-
-#ifndef __NET_NETIF_DP8390_DRIVER_H__
-#define __NET_NETIF_DP8390_DRIVER_H__
-
-#include "dp8390.h"
-
-/** Initializes and/or starts the network interface.
- *  @param[in,out] dep The network interface structure.
- *  @param[in] mode The state mode.
- *  @returns EOK on success.
- *  @returns EXDEV if the network interface is disabled.
- */
-int do_init(dpeth_t *dep, int mode);
-
-/** Stops the network interface.
- *  @param[in,out] dep The network interface structure.
- */
-void do_stop(dpeth_t *dep);
-
-/** Processes the interrupt.
- *  @param[in,out] dep The network interface structure.
- *  @param[in] isr The interrupt status register.
- */
-void dp_check_ints(dpeth_t *dep, int isr);
-
-/** Probes and initializes the network interface.
- *  @param[in,out] dep The network interface structure.
- *  @returns EOK on success.
- *  @returns EXDEV if the network interface was not recognized.
- */
-int do_probe(dpeth_t * dep);
-
-/** Sends a packet.
- *  @param[in,out] dep The network interface structure.
- *  @param[in] packet The packet t be sent.
- *  @param[in] from_int The value indicating whether the sending is initialized from the interrupt handler.
- *  @returns 
- */
-int do_pwrite(dpeth_t * dep, packet_t *packet, int from_int);
-
-/** Prints out network interface information.
- *  @param[in] dep The network interface structure.
- */
-void dp8390_dump(dpeth_t * dep);
-
-#endif
-
-/** @}
- */
Index: uspace/srv/hw/netif/ne2000/dp8390_port.h
===================================================================
--- uspace/srv/hw/netif/ne2000/dp8390_port.h	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ 	(revision )
@@ -1,274 +1,0 @@
-/*
- * Copyright (c) 2009 Lukas Mejdrech
- * 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 dp8390
- *  @{
- */
-
-/** @file
- *  DP8390 network interface types and structures ports.
- */
-
-#ifndef __NET_NETIF_DP8390_PORT_H__
-#define __NET_NETIF_DP8390_PORT_H__
-
-#include <errno.h>
-#include <mem.h>
-#include <stdio.h>
-#include <libarch/ddi.h>
-#include <sys/types.h>
-
-/** Macro for difining functions.
- *  @param[in] function The function type and name definition.
- *  @param[in] params The function parameters definition.
- */
-#define _PROTOTYPE(function, params) function params
-
-/** Success error code.
- */
-#define OK	EOK
-
-/** Type definition of the unsigned byte.
- */
-typedef uint8_t u8_t;
-
-/** Type definition of the unsigned short.
- */
-typedef uint16_t u16_t;
-
-/** Compares two memory blocks.
- *  @param[in] first The first memory block.
- *  @param[in] second The second memory block.
- *  @param[in] size The blocks size in bytes.
- *  @returns 0 if equeal.
- *  @returns -1 if the first is greater than the second.
- *  @returns 1 if the second is greater than the first.
- */
-#define memcmp(first, second, size)	bcmp((char *) (first), (char *) (second), (size))
-
-/** Reads 1 byte.
- *  @param[in] port The address to be read.
- *  @returns The read value.
- */
-#define inb(port)	pio_read_8((ioport8_t *) (port))
-
-/** Reads 1 word (2 bytes).
- *  @param[in] port The address to be read.
- *  @returns The read value.
- */
-#define inw(port)	pio_read_16((ioport16_t *) (port))
-
-/** Writes 1 byte.
- *  @param[in] port The address to be written.
- *  @param[in] value The value to be written.
- */
-#define outb(port, value)	pio_write_8((ioport8_t *) (port), (value))
-
-/** Writes 1 word (2 bytes).
- *  @param[in] port The address to be written.
- *  @param[in] value The value to be written.
- */
-#define outw(port, value)	pio_write_16((ioport16_t *) (port), (value))
-
-/** Prints out the driver critical error.
- *  Does not call the system panic().
- */
-#define panic(...)	printf("%s%s%d", __VA_ARGS__)
-
-/** Copies a memory block.
- *  @param proc The source process. Ignored parameter.
- *  @param src_s Ignored parameter.
- *  @param[in] src The source address.
- *  @param me The current proces. Ignored parameter.
- *  @param dst_s Ignored parameter.
- *  @param[in] dst The destination address.
- *  @param[in] bytes The block size in bytes.
- *  @returns EOK.
- */
-#define sys_vircopy(proc, src_s, src, me, dst_s, dst, bytes)	({memcpy((void *)(dst), (void *)(src), (bytes)); EOK;})
-
-/** Reads a memory block byte by byte.
- *  @param[in] port The address to be written.
- *  @param proc The source process. Ignored parameter.
- *  @param[in] dst The destination address.
- *  @param[in] bytes The block size in bytes.
- */
-#define do_vir_insb(port, proc, dst, bytes)	insb((port), (void *)(dst), (bytes))
-
-/** Reads a memory block word by word (2 bytes).
- *  @param[in] port The address to be written.
- *  @param proc The source process. Ignored parameter.
- *  @param[in] dst The destination address.
- *  @param[in] bytes The block size in bytes.
- */
-#define do_vir_insw(port, proc, dst, bytes)	insw((port), (void *)(dst), (bytes))
-
-/** Writes a memory block byte by byte.
- *  @param[in] port The address to be written.
- *  @param proc The source process. Ignored parameter.
- *  @param[in] src The source address.
- *  @param[in] bytes The block size in bytes.
- */
-#define do_vir_outsb(port, proc, src, bytes)	outsb((port), (void *)(src), (bytes))
-
-/** Writes a memory block word by word (2 bytes).
- *  @param[in] port The address to be written.
- *  @param proc The source process. Ignored parameter.
- *  @param[in] src The source address.
- *  @param[in] bytes The block size in bytes.
- */
-#define do_vir_outsw(port, proc, src, bytes)	outsw((port), (void *)(src), (bytes))
-
-/* com.h */
-/* Bits in 'DL_MODE' field of DL requests. */
-#  define DL_NOMODE		0x0
-#  define DL_PROMISC_REQ	0x2
-#  define DL_MULTI_REQ		0x4
-#  define DL_BROAD_REQ		0x8
-
-/* const.h */
-/** True value.
- */
-#define TRUE               1	/* used for turning integers into Booleans */
-
-/** False value.
- */
-#define FALSE              0	/* used for turning integers into Booleans */
-
-/** No number value.
- */
-#define NO_NUM        0x8000	/* used as numerical argument to panic() */
-
-/* devio.h */
-//typedef u16_t port_t;
-/** Type definition of a port.
- */
-typedef long port_t;
-
-/* dl_eth.h */
-/** Ethernet statistics.
- */
-typedef struct eth_stat
-{
-	/** Number of receive errors.
-	 */
-	unsigned long ets_recvErr;
-	/** Number of send error.
-	 */
-	unsigned long ets_sendErr;
-	/** Number of buffer overwrite warnings.
-	 */
-	unsigned long ets_OVW;
-	/** Number of crc errors of read.
-	 */
-	unsigned long ets_CRCerr;
-	/** Number of frames not alligned (number of bits % 8 != 0).
-	 */
-	unsigned long ets_frameAll;
-	/** Number of packets missed due to slow processing.
-	 */
-	unsigned long ets_missedP;
-	/** Number of packets received.
-	 */
-	unsigned long ets_packetR;
-	/** Number of packets transmitted.
-	 */
-	unsigned long ets_packetT;
-	/** Number of transmission defered (Tx was busy).
-	 */
-	unsigned long ets_transDef;
-	/** Number of collissions.
-	 */
-	unsigned long ets_collision;
-	/** Number of Tx aborted due to excess collisions.
-	 */
-	unsigned long ets_transAb;
-	/** Number of carrier sense lost.
-	 */
-	unsigned long ets_carrSense;
-	/** Number of FIFO underruns (processor too busy).
-	 */
-	unsigned long ets_fifoUnder;
-	/** Number of FIFO overruns (processor too busy).
-	 */
-	unsigned long ets_fifoOver;
-	/** Number of times unable to transmit collision sig.
-	 */
-	unsigned long ets_CDheartbeat;
-	/** Number of times out of window collision.
-	 */
-	unsigned long ets_OWC;
-} eth_stat_t;
-
-/* errno.h */
-/** Generic error.
- */
-#define EGENERIC     EINVAL
-
-/* ether.h */
-/** Minimum Ethernet packet size in bytes.
- */
-#define ETH_MIN_PACK_SIZE		  60
-
-/** Maximum Ethernet packet size in bytes.
- */
-#define ETH_MAX_PACK_SIZE_TAGGED	1518
-
-/** Ethernet address type definition.
- */
-typedef struct ether_addr
-{
-	/** Address data.
-	 */
-	u8_t ea_addr[6];
-} ether_addr_t;
-
-/* type.h */
-/** Type definition of the physical addresses and lengths in bytes.
- */
-typedef unsigned long phys_bytes;
-
-/** Type definition of the virtual addresses and lengths in bytes.
- */
-typedef unsigned long vir_bytes;
-
-/** Type definition of the input/output vector.
- */
-typedef struct {
-	/** Address of an I/O buffer.
-	 */
-	vir_bytes iov_addr;
-	/** Sizeof an I/O buffer.
-	 */
-	vir_bytes iov_size;
-} iovec_t;
-
-#endif
-
-/** @}
- */
Index: uspace/srv/hw/netif/ne2000/local.h
===================================================================
--- uspace/srv/hw/netif/ne2000/local.h	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ 	(revision )
@@ -1,99 +1,0 @@
-/*
- * Copyright (c) 1987,1997, 2006, Vrije Universiteit, Amsterdam, The Netherlands All rights reserved. Redistribution and use of the MINIX 3 operating system 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.
- * * Neither the name of the Vrije Universiteit nor the names of the software authors or contributors may be used to endorse or promote products derived from this software without specific prior written permission.
- * * Any deviations from these conditions require written permission from the copyright holder in advance
- *
- *
- * Disclaimer
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS, AUTHORS, AND CONTRIBUTORS ``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 COPYRIGHT HOLDER OR ANY AUTHORS OR CONTRIBUTORS 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.
- *
- * Changes:
- *  2009 ported to HelenOS, Lukas Mejdrech
- */
-
-/** @addtogroup dp8390
- *  @{
- */
-
-/** @file
- *  Network interface probe functions.
- */
-
-#ifndef __NET_NETIF_DP8390_CONFIG_H__
-#define __NET_NETIF_DP8390_CONFIG_H__
-
-#include "dp8390_port.h"
-
-/*
-local.h
-*/
-
-/** WDETH switch.
- */
-#define ENABLE_WDETH 0
-
-/** NE2000 switch.
- */
-#define ENABLE_NE2000 1
-
-/** 3C503 switch.
- */
-#define ENABLE_3C503 0
-
-/** PCI support switch.
- */
-#define ENABLE_PCI 0
-
-struct dpeth;
-
-/* 3c503.c */
-/* * Probes a 3C503 network interface.
- *  @param[in] dep The network interface structure.
- *  @returns 1 if the NE2000 network interface is present.
- *  @returns 0 otherwise.
- */
-//_PROTOTYPE(int el2_probe, (struct dpeth*dep)				);
-
-/* ne2000.c */
-/** Probes a NE2000 or NE1000 network interface.
- *  @param[in] dep The network interface structure.
- *  @returns 1 if the NE2000 network interface is present.
- *  @returns 0 otherwise.
- */
-int ne_probe(struct dpeth * dep);
-//_PROTOTYPE(int ne_probe, (struct dpeth *dep)				);
-//_PROTOTYPE(void ne_init, (struct dpeth *dep)				);
-
-/* rtl8029.c */
-/* * Probes a RTL8029 network interface.
- *  @param[in] dep The network interface structure.
- *  @returns 1 if the NE2000 network interface is present.
- *  @returns 0 otherwise.
- */
-//_PROTOTYPE(int rtl_probe, (struct dpeth *dep)				);
-
-/* wdeth.c */
-/* * Probes a WDETH network interface.
- *  @param[in] dep The network interface structure.
- *  @returns 1 if the NE2000 network interface is present.
- *  @returns 0 otherwise.
- */
-//_PROTOTYPE(int wdeth_probe, (struct dpeth*dep)				);
-
-#endif
-
-/** @}
- */
Index: uspace/srv/hw/netif/ne2000/ne2000.h
===================================================================
--- uspace/srv/hw/netif/ne2000/ne2000.h	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ 	(revision )
@@ -1,111 +1,0 @@
-/*
- * Copyright (c) 1987,1997, 2006, Vrije Universiteit, Amsterdam, The Netherlands All rights reserved. Redistribution and use of the MINIX 3 operating system 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.
- * * Neither the name of the Vrije Universiteit nor the names of the software authors or contributors may be used to endorse or promote products derived from this software without specific prior written permission.
- * * Any deviations from these conditions require written permission from the copyright holder in advance
- *
- *
- * Disclaimer
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS, AUTHORS, AND CONTRIBUTORS ``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 COPYRIGHT HOLDER OR ANY AUTHORS OR CONTRIBUTORS 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.
- *
- * Changes:
- *  2009 ported to HelenOS, Lukas Mejdrech
- */
-
-/*
-ne2000.h
-
-Created:	March 15, 1994 by Philip Homburg <philip@f-mnx.phicoh.com>
-*/
-
-/** @addtogroup ne2k
- *  @{
- */
-
-/** @file
- *  NE1000 and NE2000 network interface definitions.
- */
-
-#ifndef __NET_NETIF_NE2000_H__
-#define __NET_NETIF_NE2000_H__
-
-#include <libarch/ddi.h>
-
-#include "dp8390_port.h"
-
-/** DP8390 register offset.
- */
-#define NE_DP8390	0x00
-
-/** Data register.
- */
-#define NE_DATA		0x10
-
-/** Reset register.
- */
-#define NE_RESET	0x1F
-
-/** NE1000 data start.
- */
-#define NE1000_START	0x2000
-
-/** NE1000 data size.
- */
-#define NE1000_SIZE	0x2000
-
-/** NE2000 data start.
- */
-#define NE2000_START	0x4000
-
-/** NE2000 data size.
- */
-#define NE2000_SIZE	0x4000
-
-/** Reads 1 byte register.
- *  @param[in] dep The network interface structure.
- *  @param[in] reg The register offset.
- *  @returns The read value.
- */
-#define inb_ne(dep, reg)	(inb(dep->de_base_port+reg))
-
-/** Writes 1 byte register.
- *  @param[in] dep The network interface structure.
- *  @param[in] reg The register offset.
- *  @param[in] data The value to be written.
- */
-#define outb_ne(dep, reg, data)	(outb(dep->de_base_port+reg, data))
-
-/** Reads 1 word (2 bytes) register.
- *  @param[in] dep The network interface structure.
- *  @param[in] reg The register offset.
- *  @returns The read value.
- */
-#define inw_ne(dep, reg)	(inw(dep->de_base_port+reg))
-
-/** Writes 1 word (2 bytes) register.
- *  @param[in] dep The network interface structure.
- *  @param[in] reg The register offset.
- *  @param[in] data The value to be written.
- */
-#define outw_ne(dep, reg, data)	(outw(dep->de_base_port+reg, data))
-
-#endif /* __NET_NETIF_NE2000_H__ */
-
-/*
- * $PchId: ne2000.h,v 1.4 2004/08/03 12:03:20 philip Exp $
- */
-
-/** @}
- */
Index: uspace/srv/loader/arch/abs32le/_link.ld.in
===================================================================
--- uspace/srv/loader/arch/abs32le/_link.ld.in	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/srv/loader/arch/abs32le/_link.ld.in	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -21,6 +21,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
Index: uspace/srv/loader/arch/amd64/_link.ld.in
===================================================================
--- uspace/srv/loader/arch/amd64/_link.ld.in	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/srv/loader/arch/amd64/_link.ld.in	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -27,6 +27,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
Index: uspace/srv/loader/arch/arm32/_link.ld.in
===================================================================
--- uspace/srv/loader/arch/arm32/_link.ld.in	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/srv/loader/arch/arm32/_link.ld.in	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -25,6 +25,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
Index: uspace/srv/loader/arch/ia32/_link.ld.in
===================================================================
--- uspace/srv/loader/arch/ia32/_link.ld.in	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/srv/loader/arch/ia32/_link.ld.in	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -26,6 +26,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
Index: uspace/srv/loader/arch/ia64/_link.ld.in
===================================================================
--- uspace/srv/loader/arch/ia64/_link.ld.in	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/srv/loader/arch/ia64/_link.ld.in	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -21,6 +21,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
@@ -29,5 +29,5 @@
 	.got : {
 		_gp = .;
-		*(.got*);
+		*(.got .got.*);
 	} :data
 	
Index: uspace/srv/loader/arch/mips32/_link.ld.in
===================================================================
--- uspace/srv/loader/arch/mips32/_link.ld.in	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/srv/loader/arch/mips32/_link.ld.in	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -25,6 +25,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
Index: uspace/srv/loader/arch/ppc32/_link.ld.in
===================================================================
--- uspace/srv/loader/arch/ppc32/_link.ld.in	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/srv/loader/arch/ppc32/_link.ld.in	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -25,6 +25,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
Index: uspace/srv/loader/arch/sparc64/_link.ld.in
===================================================================
--- uspace/srv/loader/arch/sparc64/_link.ld.in	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/srv/loader/arch/sparc64/_link.ld.in	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -20,6 +20,6 @@
 	
 	.text : {
-		*(.text);
-		*(.rodata*);
+		*(.text .text.*);
+		*(.rodata .rodata.*);
 	} :text
 	
Index: uspace/srv/loader/main.c
===================================================================
--- uspace/srv/loader/main.c	(revision 348c589fdcd2208295fe60593083e96ca9536b3d)
+++ uspace/srv/loader/main.c	(revision ea5352913e3f4737d9d751831020498633794587)
@@ -407,12 +407,10 @@
 			/* Not reached */
 		default:
-			retval = ENOENT;
+			retval = EINVAL;
 			break;
 		}
-		if (IPC_GET_IMETHOD(call) != IPC_M_PHONE_HUNGUP) {
-			DPRINTF("Responding EINVAL to method %d.\n",
-			    IPC_GET_IMETHOD(call));
-			async_answer_0(callid, EINVAL);
-		}
+		
+		if (IPC_GET_IMETHOD(call) != IPC_M_PHONE_HUNGUP)
+			async_answer_0(callid, retval);
 	}
 }
