Index: boot/Makefile.common
===================================================================
--- boot/Makefile.common	(revision 9fe2fd757f8bdd95463c25cf28f946810399aa32)
+++ boot/Makefile.common	(revision f42ee6f303b03f563ca4bf42301c737e9efa2172)
@@ -67,8 +67,9 @@
 INITRD = initrd
 
+# NOTE: Naming service must be first task in the list
 INIT_TASKS = \
 	$(USPACE_PATH)/srv/ns/ns \
 	$(USPACE_PATH)/srv/loader/loader \
-	$(USPACE_PATH)/app/init/init \
+	$(USPACE_PATH)/srv/sysman/sysman \
 	$(USPACE_PATH)/srv/locsrv/locsrv \
 	$(USPACE_PATH)/srv/bd/rd/rd \
Index: uspace/Makefile
===================================================================
--- uspace/Makefile	(revision 9fe2fd757f8bdd95463c25cf28f946810399aa32)
+++ uspace/Makefile	(revision f42ee6f303b03f563ca4bf42301c737e9efa2172)
@@ -119,4 +119,5 @@
 	srv/ns \
 	srv/taskmon \
+	srv/sysman \
 	srv/vfs \
 	srv/bd/sata_bd \
Index: uspace/srv/sysman/Makefile
===================================================================
--- uspace/srv/sysman/Makefile	(revision f42ee6f303b03f563ca4bf42301c737e9efa2172)
+++ uspace/srv/sysman/Makefile	(revision f42ee6f303b03f563ca4bf42301c737e9efa2172)
@@ -0,0 +1,41 @@
+#
+# Copyright (c) 2005 Martin Decky
+# Copyright (c) 2007 Jakub Jermar
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+USPACE_PREFIX = ../..
+BINARY = sysman
+STATIC_NEEDED = y
+
+SOURCES = \
+	configuration.c \
+	dep.c \
+	main.c \
+	sysman.c \
+	unit.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/srv/sysman/configuration.c
===================================================================
--- uspace/srv/sysman/configuration.c	(revision f42ee6f303b03f563ca4bf42301c737e9efa2172)
+++ uspace/srv/sysman/configuration.c	(revision f42ee6f303b03f563ca4bf42301c737e9efa2172)
@@ -0,0 +1,42 @@
+#include <adt/list.h>
+#include <assert.h>
+#include <errno.h>
+#include <fibril_synch.h>
+
+#include "configuration.h"
+
+static list_t units;
+static fibril_mutex_t units_mtx;
+
+void configuration_init(void)
+{
+	list_initialize(&units);
+	fibril_mutex_initialize(&units_mtx);
+}
+
+int configuration_add_unit(unit_t *unit)
+{
+	assert(unit);
+	assert(unit->state == STATE_EMBRYO);
+
+	fibril_mutex_lock(&units_mtx);
+	list_append(&unit->units, &units);
+	
+	// TODO check name uniqueness
+	fibril_mutex_unlock(&units_mtx);
+	return EOK;
+}
+
+/** Marks newly added units as usable (via state change) */
+int configuration_commit(void)
+{
+	fibril_mutex_lock(&units_mtx);
+	list_foreach(units, units, unit_t, u) {
+		if (u->state == STATE_EMBRYO) {
+			u->state = STATE_STOPPED;
+		}
+	}
+	fibril_mutex_unlock(&units_mtx);
+
+	return EOK;
+}
Index: uspace/srv/sysman/configuration.h
===================================================================
--- uspace/srv/sysman/configuration.h	(revision f42ee6f303b03f563ca4bf42301c737e9efa2172)
+++ uspace/srv/sysman/configuration.h	(revision f42ee6f303b03f563ca4bf42301c737e9efa2172)
@@ -0,0 +1,14 @@
+#ifndef SYSMAN_CONFIGURATION_H
+#define SYSMAN_CONFIGURATION_H
+
+#include "unit.h"
+
+extern void configuration_init(void);
+
+extern int configuration_add_unit(unit_t *);
+
+extern int configuration_commit(void);
+
+#endif
+
+
Index: uspace/srv/sysman/dep.c
===================================================================
--- uspace/srv/sysman/dep.c	(revision f42ee6f303b03f563ca4bf42301c737e9efa2172)
+++ uspace/srv/sysman/dep.c	(revision f42ee6f303b03f563ca4bf42301c737e9efa2172)
@@ -0,0 +1,26 @@
+#include <errno.h>
+#include <stdlib.h>
+
+#include "dep.h"
+
+/**
+ * @return        EOK on success
+ * @return        ENOMEM
+ */
+int dep_add_dependency(unit_t *dependant, unit_t *dependency)
+{
+	unit_dependency_t *edge = malloc(sizeof(unit_t));
+	if (edge == NULL) {
+		return ENOMEM;
+	}
+	// TODO check existence of the edge
+	// TODO locking
+	// TODO check types and states of connected units
+	/* Do not initalize links as they are immediately inserted into list */
+	list_append(&edge->dependants, &dependency->dependants);
+	list_append(&edge->dependencies, &dependant->dependencies);
+
+	edge->dependant = dependant;
+	edge->dependency = dependency;
+	return EOK;
+}
Index: uspace/srv/sysman/dep.h
===================================================================
--- uspace/srv/sysman/dep.h	(revision f42ee6f303b03f563ca4bf42301c737e9efa2172)
+++ uspace/srv/sysman/dep.h	(revision f42ee6f303b03f563ca4bf42301c737e9efa2172)
@@ -0,0 +1,23 @@
+#ifndef SYSMAN_DEP_H
+#define SYSMAN_DEP_H
+
+#include <adt/list.h>
+
+#include "unit.h"
+
+/** Dependency edge between unit in dependency graph */
+typedef struct {
+	link_t dependants;
+	link_t dependencies;
+
+	/** Unit that depends on another */
+	unit_t *dependant;
+	/** Unit that is dependency for another */
+	unit_t *dependency;
+} unit_dependency_t;
+
+extern int dep_add_dependency(unit_t *, unit_t *);
+
+#endif
+
+
Index: uspace/srv/sysman/main.c
===================================================================
--- uspace/srv/sysman/main.c	(revision f42ee6f303b03f563ca4bf42301c737e9efa2172)
+++ uspace/srv/sysman/main.c	(revision f42ee6f303b03f563ca4bf42301c737e9efa2172)
@@ -0,0 +1,103 @@
+#include <async.h>
+#include <errno.h>
+#include <fibril.h>
+#include <stddef.h>
+#include <stdio.h>
+
+#include "configuration.h"
+#include "dep.h"
+#include "sysman.h"
+#include "unit.h"
+
+#define NAME "sysman"
+
+static void sysman_connection(ipc_callid_t callid, ipc_call_t *call, void *arg)
+{
+	/* TODO handle client connections */
+}
+
+static int sysman_entry_point(void *arg) {
+	/*
+	 * Build hard coded configuration.
+	 */
+	int result = EOK;
+	unit_t *mnt_initrd = NULL;
+	unit_t *cfg_init = NULL;
+	unit_t *tgt_default = NULL;
+
+	mnt_initrd = unit_create(UNIT_MOUNT);
+	if (mnt_initrd == NULL) {
+		result = ENOMEM;
+		goto fail;
+	}
+	// TODO Use RDFMT
+	mnt_initrd->data.mnt.type       = "ext4fs";
+	mnt_initrd->data.mnt.mountpoint = "/";
+	mnt_initrd->data.mnt.device     = "bd/initrd";
+
+	cfg_init = unit_create(UNIT_CONFIGURATION);
+	if (cfg_init == NULL) {
+		result = ENOMEM;
+		goto fail;
+	}
+	cfg_init->data.cfg.path = "/cfg/";
+	
+	tgt_default = unit_create(UNIT_TARGET);
+	if (tgt_default == NULL) {
+		result = ENOMEM;
+		goto fail;
+	}
+	
+
+	/*
+	 * Add units to configuration and start the default target.
+	 */
+	configuration_add_unit(mnt_initrd);
+	configuration_add_unit(cfg_init);
+	configuration_add_unit(tgt_default);
+
+	result = dep_add_dependency(tgt_default, cfg_init);
+	if (result != EOK) {
+		goto fail;
+	}
+
+	result = dep_add_dependency(cfg_init, mnt_initrd);
+	if (result != EOK) {
+		goto fail;
+	}
+
+	configuration_commit();
+
+	result = sysman_unit_start(tgt_default);
+
+	return result;
+
+fail:
+	unit_destroy(&tgt_default);
+	unit_destroy(&cfg_init);
+	unit_destroy(&mnt_initrd);
+	return result;
+}
+
+int main(int argc, char *argv[])
+{
+	printf(NAME ": HelenOS system daemon\n");
+
+	configuration_init();
+
+	/*
+	 * Create and start initial configuration asynchronously
+	 * so that we can start server's fibril that may be used
+	 * when executing the start.
+	 */
+	fid_t entry_fibril = fibril_create(sysman_entry_point, NULL);
+	fibril_add_ready(entry_fibril);
+
+	/* Prepare and start sysman server */
+	async_set_client_connection(sysman_connection);
+
+	printf(NAME ": Accepting connections\n");
+	async_manager();
+
+	return 0;
+}
Index: uspace/srv/sysman/sysman.c
===================================================================
--- uspace/srv/sysman/sysman.c	(revision f42ee6f303b03f563ca4bf42301c737e9efa2172)
+++ uspace/srv/sysman/sysman.c	(revision f42ee6f303b03f563ca4bf42301c737e9efa2172)
@@ -0,0 +1,10 @@
+#include <errno.h>
+
+#include "sysman.h"
+
+int sysman_unit_start(unit_t *unit)
+{
+	// satisfy dependencies
+	// start unit (via restarter)
+	return EOK;
+}
Index: uspace/srv/sysman/sysman.h
===================================================================
--- uspace/srv/sysman/sysman.h	(revision f42ee6f303b03f563ca4bf42301c737e9efa2172)
+++ uspace/srv/sysman/sysman.h	(revision f42ee6f303b03f563ca4bf42301c737e9efa2172)
@@ -0,0 +1,8 @@
+#ifndef SYSMAN_SYSMAN_H
+#define SYSMAN_SYSMAN_H
+
+#include "unit.h"
+
+extern int sysman_unit_start(unit_t *);
+
+#endif
Index: uspace/srv/sysman/unit.c
===================================================================
--- uspace/srv/sysman/unit.c	(revision f42ee6f303b03f563ca4bf42301c737e9efa2172)
+++ uspace/srv/sysman/unit.c	(revision f42ee6f303b03f563ca4bf42301c737e9efa2172)
@@ -0,0 +1,43 @@
+#include <assert.h>
+#include <mem.h>
+#include <stdlib.h>
+
+#include "unit.h"
+
+static void unit_init(unit_t *unit, unit_type_t type)
+{
+	assert(unit);
+
+	memset(unit, 0, sizeof(unit));
+
+	link_initialize(&unit->units);
+	list_initialize(&unit->dependants);
+	list_initialize(&unit->dependencies);
+
+	unit->type = type;
+	unit->state = STATE_EMBRYO;
+}
+
+unit_t *unit_create(unit_type_t type)
+{
+	unit_t *unit = malloc(sizeof(unit_t));
+	if (unit != NULL) {
+		unit_init(unit, type);
+	}
+	return unit;
+}
+
+/** Release resources used by unit structure */
+void unit_destroy(unit_t **unit)
+{
+	if (*unit == NULL)
+		return;
+	/* TODO:
+	 * 	edges,
+	 * 	specific unit data,
+	 * 	check it's not an active unit,
+	 * 	other resources to come
+	 */
+	free(*unit);
+	*unit = NULL;
+}
Index: uspace/srv/sysman/unit.h
===================================================================
--- uspace/srv/sysman/unit.h	(revision f42ee6f303b03f563ca4bf42301c737e9efa2172)
+++ uspace/srv/sysman/unit.h	(revision f42ee6f303b03f563ca4bf42301c737e9efa2172)
@@ -0,0 +1,40 @@
+#ifndef SYSMAN_UNIT_H
+#define SYSMAN_UNIT_H
+
+#include <adt/list.h>
+
+#include "unit_mnt.h"
+#include "unit_cfg.h"
+
+typedef enum {
+	UNIT_TARGET = 0,
+	UNIT_MOUNT,
+	UNIT_CONFIGURATION
+} unit_type_t;
+
+typedef enum {
+	STATE_EMBRYO = 0,
+	STATE_STOPPED
+} unit_state_t;
+
+typedef struct {
+	link_t units;
+
+	unit_type_t type;
+	unit_state_t state;
+
+	list_t dependencies;
+	list_t dependants;
+
+	union {
+		unit_mnt_t mnt;
+		unit_cfg_t cfg;
+	} data;
+} unit_t;
+
+
+extern unit_t *unit_create(unit_type_t);
+extern void unit_destroy(unit_t **);
+
+
+#endif
Index: uspace/srv/sysman/unit_cfg.h
===================================================================
--- uspace/srv/sysman/unit_cfg.h	(revision f42ee6f303b03f563ca4bf42301c737e9efa2172)
+++ uspace/srv/sysman/unit_cfg.h	(revision f42ee6f303b03f563ca4bf42301c737e9efa2172)
@@ -0,0 +1,8 @@
+#ifndef SYSMAN_UNIT_CFG_H
+#define SYSMAN_UNIT_CFG_H
+
+typedef struct {
+	const char *path;
+} unit_cfg_t;
+
+#endif
Index: uspace/srv/sysman/unit_mnt.h
===================================================================
--- uspace/srv/sysman/unit_mnt.h	(revision f42ee6f303b03f563ca4bf42301c737e9efa2172)
+++ uspace/srv/sysman/unit_mnt.h	(revision f42ee6f303b03f563ca4bf42301c737e9efa2172)
@@ -0,0 +1,11 @@
+#ifndef SYSMAN_UNIT_MNT_H
+#define SYSMAN_UNIT_MNT_H
+
+typedef struct {
+	const char *type;
+	const char *mountpoint;
+	const char *device;
+} unit_mnt_t;
+
+#endif
+
