Index: uspace/app/init/init.c
===================================================================
--- uspace/app/init/init.c	(revision e273e9e0486678e6c751938a061147ebd7d76110)
+++ uspace/app/init/init.c	(revision a72f3b87bcdb8b8f14877d2ce9c68a09661f54c3)
@@ -35,6 +35,4 @@
  */
 
-#include <fibril.h>
-#include <futil.h>
 #include <stdio.h>
 #include <stdarg.h>
@@ -48,8 +46,6 @@
 #include <loc.h>
 #include <str_error.h>
-#include <config.h>
 #include <io/logctl.h>
 #include <vfs/vfs.h>
-#include <vol.h>
 #include "untar.h"
 #include "init.h"
@@ -61,26 +57,6 @@
 #define ROOT_MOUNT_POINT  "/"
 
-#define LOCFS_FS_TYPE      "locfs"
-#define LOCFS_MOUNT_POINT  "/loc"
-
-#define TMPFS_FS_TYPE      "tmpfs"
-#define TMPFS_MOUNT_POINT  "/tmp"
-
-#define SRV_CONSOLE  "/srv/hid/console"
-#define APP_GETTERM  "/app/getterm"
-
-#define SRV_DISPLAY  "/srv/hid/display"
-
-#define HID_INPUT              "hid/input"
-#define HID_OUTPUT             "hid/output"
-
 #define srv_start(path, ...) \
 	srv_startl(path, path, ##__VA_ARGS__, NULL)
-
-static const char *sys_dirs[] = {
-	"/w/cfg",
-	"/w/data",
-	NULL,
-};
 
 /** Print banner */
@@ -174,21 +150,4 @@
 }
 
-/** Mount locfs file system
- *
- * The operation blocks until the locfs file system
- * server is ready for mounting.
- *
- * @return True on success.
- * @return False on failure.
- *
- */
-static bool mount_locfs(void)
-{
-	errno_t rc = vfs_mount_path(LOCFS_MOUNT_POINT, LOCFS_FS_TYPE, "", "",
-	    IPC_FLAG_BLOCKING, 0);
-	return mount_report("Location service file system", LOCFS_MOUNT_POINT,
-	    LOCFS_FS_TYPE, NULL, rc);
-}
-
 static errno_t srv_startl(const char *path, ...)
 {
@@ -253,220 +212,6 @@
 }
 
-static errno_t console(const char *isvc, const char *osvc)
-{
-	/* Wait for the input service to be ready */
-	service_id_t service_id;
-	errno_t rc = loc_service_get_id(isvc, &service_id, IPC_FLAG_BLOCKING);
-	if (rc != EOK) {
-		printf("%s: Error waiting on %s (%s)\n", NAME, isvc,
-		    str_error(rc));
-		return rc;
-	}
-
-	/* Wait for the output service to be ready */
-	rc = loc_service_get_id(osvc, &service_id, IPC_FLAG_BLOCKING);
-	if (rc != EOK) {
-		printf("%s: Error waiting on %s (%s)\n", NAME, osvc,
-		    str_error(rc));
-		return rc;
-	}
-
-	return srv_start(SRV_CONSOLE, isvc, osvc);
-}
-
-#ifdef CONFIG_WINSYS
-
-static errno_t display_server(void)
-{
-	return srv_start(SRV_DISPLAY);
-}
-
-static int app_start(const char *app, const char *arg)
-{
-	printf("%s: Spawning %s\n", NAME, app);
-
-	task_id_t id;
-	task_wait_t wait;
-	errno_t rc = task_spawnl(&id, &wait, app, app, arg, NULL);
-	if (rc != EOK) {
-		oom_check(rc, app);
-		printf("%s: Error spawning %s (%s)\n", NAME, app,
-		    str_error(rc));
-		return -1;
-	}
-
-	task_exit_t texit;
-	int retval;
-	rc = task_wait(&wait, &texit, &retval);
-	if ((rc != EOK) || (texit != TASK_EXIT_NORMAL)) {
-		printf("%s: Error retrieving retval from %s (%s)\n", NAME,
-		    app, str_error(rc));
-		return rc;
-	}
-
-	return retval;
-}
-
-#endif
-
-static void getterm(const char *svc, const char *app, bool msg)
-{
-	if (msg) {
-		printf("%s: Spawning %s %s %s --msg --wait -- %s\n", NAME,
-		    APP_GETTERM, svc, LOCFS_MOUNT_POINT, app);
-
-		errno_t rc = task_spawnl(NULL, NULL, APP_GETTERM, APP_GETTERM, svc,
-		    LOCFS_MOUNT_POINT, "--msg", "--wait", "--", app, NULL);
-		if (rc != EOK) {
-			oom_check(rc, APP_GETTERM);
-			printf("%s: Error spawning %s %s %s --msg --wait -- %s\n",
-			    NAME, APP_GETTERM, svc, LOCFS_MOUNT_POINT, app);
-		}
-	} else {
-		printf("%s: Spawning %s %s %s --wait -- %s\n", NAME,
-		    APP_GETTERM, svc, LOCFS_MOUNT_POINT, app);
-
-		errno_t rc = task_spawnl(NULL, NULL, APP_GETTERM, APP_GETTERM, svc,
-		    LOCFS_MOUNT_POINT, "--wait", "--", app, NULL);
-		if (rc != EOK) {
-			oom_check(rc, APP_GETTERM);
-			printf("%s: Error spawning %s %s %s --wait -- %s\n",
-			    NAME, APP_GETTERM, svc, LOCFS_MOUNT_POINT, app);
-		}
-	}
-}
-
-static bool mount_tmpfs(void)
-{
-	errno_t rc = vfs_mount_path(TMPFS_MOUNT_POINT, TMPFS_FS_TYPE, "", "", 0, 0);
-	return mount_report("Temporary file system", TMPFS_MOUNT_POINT,
-	    TMPFS_FS_TYPE, NULL, rc);
-}
-
-/** Init system volume.
- *
- * See if system volume is configured. If so, try to wait for it to become
- * available. If not, create basic directories for live image omde.
- */
-static errno_t init_sysvol(void)
-{
-	vol_t *vol = NULL;
-	vol_info_t vinfo;
-	volume_id_t *volume_ids = NULL;
-	service_id_t *part_ids = NULL;
-	vol_part_info_t pinfo;
-	size_t nvols;
-	size_t nparts;
-	bool sv_mounted;
-	size_t i;
-	errno_t rc;
-	bool found_cfg;
-	const char **cp;
-
-	rc = vol_create(&vol);
-	if (rc != EOK) {
-		printf("Error contacting volume service.\n");
-		goto error;
-	}
-
-	rc = vol_get_volumes(vol, &volume_ids, &nvols);
-	if (rc != EOK) {
-		printf("Error getting list of volumes.\n");
-		goto error;
-	}
-
-	/* XXX This could be handled more efficiently by volsrv itself */
-	found_cfg = false;
-	for (i = 0; i < nvols; i++) {
-		rc = vol_info(vol, volume_ids[i], &vinfo);
-		if (rc != EOK) {
-			printf("Error getting volume information.\n");
-			rc = EIO;
-			goto error;
-		}
-
-		if (str_cmp(vinfo.path, "/w") == 0) {
-			found_cfg = true;
-			break;
-		}
-	}
-
-	free(volume_ids);
-	volume_ids = NULL;
-
-	if (!found_cfg) {
-		/* Prepare directory structure for live image mode */
-		printf("%s: Creating live image directory structure.\n", NAME);
-		cp = sys_dirs;
-		while (*cp != NULL) {
-			rc = vfs_link_path(*cp, KIND_DIRECTORY, NULL);
-			if (rc != EOK) {
-				printf("%s: Error creating directory '%s'.\n",
-				    NAME, *cp);
-				goto error;
-			}
-
-			++cp;
-		}
-
-		/* Copy initial configuration files */
-		rc = futil_rcopy_contents("/cfg", "/w/cfg");
-		if (rc != EOK)
-			goto error;
-	} else {
-		printf("%s: System volume is configured.\n", NAME);
-
-		/* Wait until system volume is mounted */
-		sv_mounted = false;
-
-		while (true) {
-			rc = vol_get_parts(vol, &part_ids, &nparts);
-			if (rc != EOK) {
-				printf("Error getting list of volumes.\n");
-				goto error;
-			}
-
-			for (i = 0; i < nparts; i++) {
-				rc = vol_part_info(vol, part_ids[i], &pinfo);
-				if (rc != EOK) {
-					printf("Error getting partition "
-					    "information.\n");
-					rc = EIO;
-					goto error;
-				}
-
-				if (str_cmp(pinfo.cur_mp, "/w") == 0) {
-					sv_mounted = true;
-					break;
-				}
-			}
-
-			if (sv_mounted)
-				break;
-
-			free(part_ids);
-			part_ids = NULL;
-
-			fibril_sleep(1);
-			printf("Sleeping(1) for system volume.\n");
-		}
-	}
-
-	vol_destroy(vol);
-	return EOK;
-error:
-	vol_destroy(vol);
-	if (volume_ids != NULL)
-		free(volume_ids);
-	if (part_ids != NULL)
-		free(part_ids);
-
-	return rc;
-}
-
 int main(int argc, char *argv[])
 {
-	errno_t rc;
-
 	info_print();
 
@@ -476,69 +221,6 @@
 	}
 
-	/* Make sure file systems are running. */
-	if (str_cmp(STRING(RDFMT), "tmpfs") != 0)
-		srv_start("/srv/fs/tmpfs");
-	if (str_cmp(STRING(RDFMT), "exfat") != 0)
-		srv_start("/srv/fs/exfat");
-	if (str_cmp(STRING(RDFMT), "fat") != 0)
-		srv_start("/srv/fs/fat");
-	srv_start("/srv/fs/cdfs");
-	srv_start("/srv/fs/mfs");
-
-	srv_start("/srv/klog");
-	srv_start("/srv/fs/locfs");
-
-	if (!mount_locfs()) {
-		printf("%s: Exiting\n", NAME);
-		return 2;
-	}
-
-	mount_tmpfs();
-
-	srv_start("/srv/devman");
-	srv_start("/srv/hid/s3c24xx_uart");
-	srv_start("/srv/hid/s3c24xx_ts");
-
-	srv_start("/srv/bd/vbd");
-	srv_start("/srv/volsrv");
-
-	init_sysvol();
-
-	srv_start("/srv/taskmon");
-
-	srv_start("/srv/net/loopip");
-	srv_start("/srv/net/ethip");
-	srv_start("/srv/net/dhcp");
-	srv_start("/srv/net/inetsrv");
-	srv_start("/srv/net/tcp");
-	srv_start("/srv/net/udp");
-	srv_start("/srv/net/dnsrsrv");
-
-	srv_start("/srv/clipboard");
-	srv_start("/srv/hid/remcons");
-
-	srv_start("/srv/hid/input", HID_INPUT);
-	srv_start("/srv/hid/output", HID_OUTPUT);
-	srv_start("/srv/audio/hound");
-
-#ifdef CONFIG_WINSYS
-	if (!config_key_exists("console")) {
-		rc = display_server();
-		if (rc == EOK) {
-			app_start("/app/taskbar", NULL);
-			app_start("/app/terminal", "-topleft");
-		}
-	}
-#endif
-	rc = console(HID_INPUT, HID_OUTPUT);
-	if (rc == EOK) {
-		getterm("term/vc0", "/app/bdsh", true);
-		getterm("term/vc1", "/app/bdsh", false);
-		getterm("term/vc2", "/app/bdsh", false);
-		getterm("term/vc3", "/app/bdsh", false);
-		getterm("term/vc4", "/app/bdsh", false);
-		getterm("term/vc5", "/app/bdsh", false);
-	}
-
+	/* System server takes over once root is mounted */
+	srv_start("/srv/system");
 	return 0;
 }
Index: uspace/app/init/meson.build
===================================================================
--- uspace/app/init/meson.build	(revision e273e9e0486678e6c751938a061147ebd7d76110)
+++ uspace/app/init/meson.build	(revision a72f3b87bcdb8b8f14877d2ce9c68a09661f54c3)
@@ -1,3 +1,4 @@
 #
+# Copyright (c) 2024 Jiri Svoboda
 # Copyright (c) 2005 Martin Decky
 # Copyright (c) 2007 Jakub Jermar
@@ -28,5 +29,5 @@
 #
 
-deps = [ 'block', 'futil', 'untar' ]
+deps = [ 'block', 'untar' ]
 link_args += '-static'
 src = files('init.c', 'untar.c')
