Index: boot/Makefile.common
===================================================================
--- boot/Makefile.common	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ boot/Makefile.common	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -72,5 +72,5 @@
 	$(USPACE_PATH)/srv/loader/loader \
 	$(USPACE_PATH)/app/init/init \
-	$(USPACE_PATH)/srv/devmap/devmap \
+	$(USPACE_PATH)/srv/loc/loc \
 	$(USPACE_PATH)/srv/bd/rd/rd \
 	$(USPACE_PATH)/srv/vfs/vfs
@@ -88,5 +88,5 @@
 	$(USPACE_PATH)/srv/hid/input/input \
 	$(USPACE_PATH)/srv/hid/console/console \
-	$(USPACE_PATH)/srv/fs/devfs/devfs
+	$(USPACE_PATH)/srv/fs/locfs/locfs
 
 RD_SRVS_NON_ESSENTIAL = \
Index: uspace/Makefile
===================================================================
--- uspace/Makefile	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/Makefile	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -65,5 +65,5 @@
 	app/mkbd \
 	srv/clip \
-	srv/devmap \
+	srv/loc \
 	srv/devman \
 	srv/loader \
@@ -79,5 +79,5 @@
 	srv/fs/fat \
 	srv/fs/tmpfs \
-	srv/fs/devfs \
+	srv/fs/locfs \
 	srv/fs/ext2fs \
 	srv/hid/s3c24xx_ts \
Index: uspace/app/bdsh/cmds/modules/bdd/bdd.c
===================================================================
--- uspace/app/bdsh/cmds/modules/bdd/bdd.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/app/bdsh/cmds/modules/bdd/bdd.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -39,5 +39,5 @@
 
 #include <libblock.h>
-#include <devmap.h>
+#include <loc.h>
 #include <errno.h>
 #include <assert.h>
@@ -69,5 +69,5 @@
 	unsigned int argc;
 	unsigned int i, j;
-	devmap_handle_t handle;
+	service_id_t service_id;
 	aoff64_t offset;
 	uint8_t *blk;
@@ -96,5 +96,5 @@
 		size = 256;
 
-	rc = devmap_device_get_handle(argv[1], &handle, 0);
+	rc = loc_service_get_id(argv[1], &service_id, 0);
 	if (rc != EOK) {
 		printf("%s: Error resolving device `%s'.\n", cmdname, argv[1]);
@@ -102,5 +102,5 @@
 	}
 
-	rc = block_init(EXCHANGE_SERIALIZE, handle, 2048);
+	rc = block_init(EXCHANGE_SERIALIZE, service_id, 2048);
 	if (rc != EOK)  {
 		printf("%s: Error initializing libblock.\n", cmdname);
@@ -108,5 +108,5 @@
 	}
 
-	rc = block_get_bsize(handle, &block_size);
+	rc = block_get_bsize(service_id, &block_size);
 	if (rc != EOK) {
 		printf("%s: Error determining device block size.\n", cmdname);
@@ -117,5 +117,5 @@
 	if (blk == NULL) {
 		printf("%s: Error allocating memory.\n", cmdname);
-		block_fini(handle);
+		block_fini(service_id);
 		return CMD_FAILURE;
 	}
@@ -124,9 +124,9 @@
 
 	while (size > 0) {
-		rc = block_read_direct(handle, ba, 1, blk);
+		rc = block_read_direct(service_id, ba, 1, blk);
 		if (rc != EOK) {
 			printf("%s: Error reading block %" PRIuOFF64 "\n", cmdname, ba);
 			free(blk);
-			block_fini(handle);
+			block_fini(service_id);
 			return CMD_FAILURE;
 		}
@@ -170,5 +170,5 @@
 
 	free(blk);
-	block_fini(handle);
+	block_fini(service_id);
 
 	return CMD_SUCCESS;
Index: uspace/app/blkdump/blkdump.c
===================================================================
--- uspace/app/blkdump/blkdump.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/app/blkdump/blkdump.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -42,5 +42,5 @@
 #include <libblock.h>
 #include <mem.h>
-#include <devmap.h>
+#include <loc.h>
 #include <byteorder.h>
 #include <sys/types.h>
@@ -59,5 +59,5 @@
 	int rc;
 	char *dev_path;
-	devmap_handle_t handle;
+	service_id_t service_id;
 	size_t block_size;
 	char *endptr;
@@ -128,5 +128,5 @@
 	dev_path = *argv;
 
-	rc = devmap_device_get_handle(dev_path, &handle, 0);
+	rc = loc_service_get_id(dev_path, &service_id, 0);
 	if (rc != EOK) {
 		printf(NAME ": Error resolving device `%s'.\n", dev_path);
@@ -134,5 +134,5 @@
 	}
 
-	rc = block_init(EXCHANGE_SERIALIZE, handle, 2048);
+	rc = block_init(EXCHANGE_SERIALIZE, service_id, 2048);
 	if (rc != EOK)  {
 		printf(NAME ": Error initializing libblock.\n");
@@ -140,5 +140,5 @@
 	}
 
-	rc = block_get_bsize(handle, &block_size);
+	rc = block_get_bsize(service_id, &block_size);
 	if (rc != EOK) {
 		printf(NAME ": Error determining device block size.\n");
@@ -146,5 +146,5 @@
 	}
 
-	rc = block_get_nblocks(handle, &dev_nblocks);
+	rc = block_get_nblocks(service_id, &dev_nblocks);
 	if (rc != EOK) {
 		printf(NAME ": Warning, failed to obtain block device size.\n");
@@ -156,5 +156,5 @@
 	if (data == NULL) {
 		printf(NAME ": Error allocating data buffer of %" PRIuOFF64 " bytes", (aoff64_t) block_size);
-		block_fini(handle);
+		block_fini(service_id);
 		return 3;
 	}
@@ -162,5 +162,5 @@
 	limit = block_offset + block_count;
 	for (current = block_offset; current < limit; current++) {
-		rc = block_read_direct(handle, current, 1, data);
+		rc = block_read_direct(service_id, current, 1, data);
 		if (rc != EOK) {
 			printf(NAME ": Error reading block at %" PRIuOFF64 " \n", current);
@@ -186,5 +186,5 @@
 	free(data);
 
-	block_fini(handle);
+	block_fini(service_id);
 
 	return 0;
Index: uspace/app/bnchmark/bnchmark.c
===================================================================
--- uspace/app/bnchmark/bnchmark.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/app/bnchmark/bnchmark.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -41,5 +41,5 @@
 #include <stdlib.h>
 #include <mem.h>
-#include <devmap.h>
+#include <loc.h>
 #include <byteorder.h>
 #include <sys/types.h>
Index: uspace/app/ext2info/ext2info.c
===================================================================
--- uspace/app/ext2info/ext2info.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/app/ext2info/ext2info.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -42,5 +42,5 @@
 #include <libblock.h>
 #include <mem.h>
-#include <devmap.h>
+#include <loc.h>
 #include <byteorder.h>
 #include <sys/types.h>
@@ -81,5 +81,5 @@
 	char *endptr;
 	char *dev_path;
-	devmap_handle_t handle;
+	service_id_t service_id;
 	ext2_filesystem_t filesystem;
 	int arg_flags;
@@ -178,5 +178,5 @@
 	dev_path = *argv;
 
-	rc = devmap_device_get_handle(dev_path, &handle, 0);
+	rc = loc_service_get_id(dev_path, &service_id, 0);
 	if (rc != EOK) {
 		printf(NAME ": Error resolving device `%s'.\n", dev_path);
@@ -184,5 +184,5 @@
 	}
 
-	rc = ext2_filesystem_init(&filesystem, handle);
+	rc = ext2_filesystem_init(&filesystem, service_id);
 	if (rc != EOK)  {
 		printf(NAME ": Error initializing libext2.\n");
Index: uspace/app/init/init.c
===================================================================
--- uspace/app/init/init.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/app/init/init.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -46,5 +46,5 @@
 #include <macros.h>
 #include <str.h>
-#include <devmap.h>
+#include <loc.h>
 #include <str_error.h>
 #include "init.h"
@@ -53,6 +53,6 @@
 #define ROOT_MOUNT_POINT  "/"
 
-#define DEVFS_FS_TYPE      "devfs"
-#define DEVFS_MOUNT_POINT  "/dev"
+#define LOCFS_FS_TYPE      "locfs"
+#define LOCFS_MOUNT_POINT  "/loc"
 
 #define TMPFS_FS_TYPE      "tmpfs"
@@ -113,10 +113,10 @@
 }
 
-static bool mount_devfs(void)
-{
-	int rc = mount(DEVFS_FS_TYPE, DEVFS_MOUNT_POINT, "", "",
+static bool mount_locfs(void)
+{
+	int rc = mount(LOCFS_FS_TYPE, LOCFS_MOUNT_POINT, "", "",
 	    IPC_FLAG_BLOCKING);
-	return mount_report("Device filesystem", DEVFS_MOUNT_POINT, DEVFS_FS_TYPE,
-	    NULL, rc);
+	return mount_report("Location service filesystem", LOCFS_MOUNT_POINT,
+	    LOCFS_FS_TYPE, NULL, rc);
 }
 
@@ -174,36 +174,36 @@
 }
 
-static void console(const char *dev)
-{
-	printf("%s: Spawning %s %s\n", NAME, SRV_CONSOLE, dev);
-	
-	/* Wait for the input device to be ready */
-	devmap_handle_t handle;
-	int rc = devmap_device_get_handle(dev, &handle, IPC_FLAG_BLOCKING);
-	if (rc != EOK) {
-		printf("%s: Error waiting on %s (%s)\n", NAME, dev,
-		    str_error(rc));
-		return;
-	}
-	
-	rc = task_spawnl(NULL, SRV_CONSOLE, SRV_CONSOLE, dev, NULL);
+static void console(const char *svc)
+{
+	printf("%s: Spawning %s %s\n", NAME, SRV_CONSOLE, svc);
+	
+	/* Wait for the input service to be ready */
+	service_id_t service_id;
+	int rc = loc_service_get_id(svc, &service_id, IPC_FLAG_BLOCKING);
+	if (rc != EOK) {
+		printf("%s: Error waiting on %s (%s)\n", NAME, svc,
+		    str_error(rc));
+		return;
+	}
+	
+	rc = task_spawnl(NULL, SRV_CONSOLE, SRV_CONSOLE, svc, NULL);
 	if (rc != EOK) {
 		printf("%s: Error spawning %s %s (%s)\n", NAME, SRV_CONSOLE,
-		    dev, str_error(rc));
-	}
-}
-
-static void getterm(const char *dev, const char *app, bool wmsg)
-{
-	char term[DEVMAP_NAME_MAXLEN];
+		    svc, str_error(rc));
+	}
+}
+
+static void getterm(const char *svc, const char *app, bool wmsg)
+{
+	char term[LOC_NAME_MAXLEN];
 	int rc;
 	
-	snprintf(term, DEVMAP_NAME_MAXLEN, "%s/%s", DEVFS_MOUNT_POINT, dev);
+	snprintf(term, LOC_NAME_MAXLEN, "%s/%s", LOCFS_MOUNT_POINT, svc);
 	
 	printf("%s: Spawning %s %s %s\n", NAME, APP_GETTERM, term, app);
 	
-	/* Wait for the terminal device to be ready */
-	devmap_handle_t handle;
-	rc = devmap_device_get_handle(dev, &handle, IPC_FLAG_BLOCKING);
+	/* Wait for the terminal service to be ready */
+	service_id_t service_id;
+	rc = loc_service_get_id(svc, &service_id, IPC_FLAG_BLOCKING);
 	if (rc != EOK) {
 		printf("%s: Error waiting on %s (%s)\n", NAME, term,
@@ -257,8 +257,8 @@
 	}
 	
-	spawn("/srv/devfs");
+	spawn("/srv/locfs");
 	spawn("/srv/taskmon");
 	
-	if (!mount_devfs()) {
+	if (!mount_locfs()) {
 		printf("%s: Exiting\n", NAME);
 		return -2;
Index: uspace/app/lsusb/main.c
===================================================================
--- uspace/app/lsusb/main.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/app/lsusb/main.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -43,5 +43,5 @@
 #include <getopt.h>
 #include <devman.h>
-#include <devmap.h>
+#include <loc.h>
 #include <usb/dev/hub.h>
 #include <usb/hc.h>
Index: uspace/app/mkbd/main.c
===================================================================
--- uspace/app/mkbd/main.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/app/mkbd/main.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -43,5 +43,5 @@
 #include <getopt.h>
 #include <devman.h>
-#include <devmap.h>
+#include <loc.h>
 #include <usb/dev/hub.h>
 #include <usb/hid/iface.h>
Index: uspace/app/mkfat/mkfat.c
===================================================================
--- uspace/app/mkfat/mkfat.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/app/mkfat/mkfat.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -42,5 +42,5 @@
 #include <libblock.h>
 #include <mem.h>
-#include <devmap.h>
+#include <loc.h>
 #include <byteorder.h>
 #include <sys/types.h>
@@ -85,5 +85,5 @@
     struct fat_params *par);
 static int fat_blocks_write(struct fat_params const *par,
-    devmap_handle_t handle);
+    service_id_t service_id);
 static void fat_bootsec_create(struct fat_params const *par, struct fat_bs *bs);
 
@@ -95,5 +95,5 @@
 	int rc;
 	char *dev_path;
-	devmap_handle_t handle;
+	service_id_t service_id;
 	size_t block_size;
 	char *endptr;
@@ -138,5 +138,5 @@
 	dev_path = *argv;
 
-	rc = devmap_device_get_handle(dev_path, &handle, 0);
+	rc = loc_service_get_id(dev_path, &service_id, 0);
 	if (rc != EOK) {
 		printf(NAME ": Error resolving device `%s'.\n", dev_path);
@@ -144,5 +144,5 @@
 	}
 
-	rc = block_init(EXCHANGE_SERIALIZE, handle, 2048);
+	rc = block_init(EXCHANGE_SERIALIZE, service_id, 2048);
 	if (rc != EOK)  {
 		printf(NAME ": Error initializing libblock.\n");
@@ -150,5 +150,5 @@
 	}
 
-	rc = block_get_bsize(handle, &block_size);
+	rc = block_get_bsize(service_id, &block_size);
 	if (rc != EOK) {
 		printf(NAME ": Error determining device block size.\n");
@@ -156,5 +156,5 @@
 	}
 
-	rc = block_get_nblocks(handle, &dev_nblocks);
+	rc = block_get_nblocks(service_id, &dev_nblocks);
 	if (rc != EOK) {
 		printf(NAME ": Warning, failed to obtain block device size.\n");
@@ -183,5 +183,5 @@
 	}
 
-	rc = fat_blocks_write(&par, handle);
+	rc = fat_blocks_write(&par, service_id);
 	if (rc != EOK) {
 		printf(NAME ": Error writing device.\n");
@@ -189,5 +189,5 @@
 	}
 
-	block_fini(handle);
+	block_fini(service_id);
 	printf("Success.\n");
 
@@ -234,5 +234,5 @@
 
 /** Create file system with the given parameters. */
-static int fat_blocks_write(struct fat_params const *par, devmap_handle_t handle)
+static int fat_blocks_write(struct fat_params const *par, service_id_t service_id)
 {
 	aoff64_t addr;
@@ -245,5 +245,5 @@
 	fat_bootsec_create(par, &bs);
 
-	rc = block_write_direct(handle, BS_BLOCK, 1, &bs);
+	rc = block_write_direct(service_id, BS_BLOCK, 1, &bs);
 	if (rc != EOK)
 		return EIO;
@@ -257,5 +257,5 @@
 	/* Reserved sectors */
 	for (i = 0; i < par->reserved_sectors - 1; ++i) {
-		rc = block_write_direct(handle, addr, 1, buffer);
+		rc = block_write_direct(service_id, addr, 1, buffer);
 		if (rc != EOK)
 			return EIO;
@@ -277,5 +277,5 @@
 			}
 
-			rc = block_write_direct(handle, addr, 1, buffer);
+			rc = block_write_direct(service_id, addr, 1, buffer);
 			if (rc != EOK)
 				return EIO;
@@ -291,5 +291,5 @@
 	/* Root directory */
 	for (i = 0; i < par->rootdir_sectors; ++i) {
-		rc = block_write_direct(handle, addr, 1, buffer);
+		rc = block_write_direct(service_id, addr, 1, buffer);
 		if (rc != EOK)
 			return EIO;
Index: uspace/app/tester/devs/devman2.c
===================================================================
--- uspace/app/tester/devs/devman2.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/app/tester/devs/devman2.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -58,5 +58,5 @@
 	char *path = NULL;
 	while (rc == EOK) {
-		rc = asprintf(&path, "/dev/class/%s\\%zu", DEVICE_CLASS, idx);
+		rc = asprintf(&path, "/loc/class/%s\\%zu", DEVICE_CLASS, idx);
 		if (rc < 0) {
 			continue;
Index: uspace/app/tester/hw/misc/virtchar1.c
===================================================================
--- uspace/app/tester/hw/misc/virtchar1.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/app/tester/hw/misc/virtchar1.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -48,6 +48,6 @@
 #include "../../tester.h"
 
-#define DEVICE_PATH_NORMAL "/dev/devices/\\virt\\null\\a"
-#define DEVICE_PATH_CLASSES "/dev/class/virt-null\\1"
+#define DEVICE_PATH_NORMAL "/loc/devices/\\virt\\null\\a"
+#define DEVICE_PATH_CLASSES "/loc/class/virt-null\\1"
 #define BUFFER_SIZE 64
 
Index: uspace/app/tester/vfs/vfs1.c
===================================================================
--- uspace/app/tester/vfs/vfs1.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/app/tester/vfs/vfs1.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -35,5 +35,5 @@
 #include <fcntl.h>
 #include <dirent.h>
-#include <devmap.h>
+#include <loc.h>
 #include <sys/types.h>
 #include <sys/stat.h>
Index: uspace/app/testread/testread.c
===================================================================
--- uspace/app/testread/testread.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/app/testread/testread.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -50,5 +50,5 @@
 #include <stdlib.h>
 #include <mem.h>
-#include <devmap.h>
+#include <loc.h>
 #include <byteorder.h>
 #include <sys/types.h>
Index: uspace/app/usbinfo/main.c
===================================================================
--- uspace/app/usbinfo/main.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/app/usbinfo/main.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -42,5 +42,5 @@
 #include <getopt.h>
 #include <devman.h>
-#include <devmap.h>
+#include <loc.h>
 #include <usb/hc.h>
 #include <usb/dev/pipes.h>
Index: uspace/doc/doxygroups.h
===================================================================
--- uspace/doc/doxygroups.h	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/doc/doxygroups.h	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -322,6 +322,6 @@
 	 * The purpose of this driver is to simplify querying of unknown
 	 * devices from within HelenOS (without a driver, no node at all
-	 * may appear under /dev/devices).
-	 */
-
-
+	 * may appear under /loc/devices).
+	 */
+
+
Index: uspace/drv/bus/usb/usbhid/generic/hiddev.c
===================================================================
--- uspace/drv/bus/usb/usbhid/generic/hiddev.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/drv/bus/usb/usbhid/generic/hiddev.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -192,5 +192,5 @@
 static int usb_generic_hid_create_function(usb_hid_dev_t *hid_dev)
 {	
-	/* Create the function exposed under /dev/devices. */
+	/* Create the exposed function. */
 	/** @todo Generate numbers for the devices? */
 	usb_log_debug("Creating DDF function %s...\n", HID_GENERIC_FUN_NAME);
Index: uspace/drv/bus/usb/usbhid/kbd/kbddev.c
===================================================================
--- uspace/drv/bus/usb/usbhid/kbd/kbddev.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/drv/bus/usb/usbhid/kbd/kbddev.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -524,5 +524,5 @@
 	assert(kbd_dev != NULL);
 	
-	/* Create the function exposed under /dev/devices. */
+	/* Create the exposed function. */
 	usb_log_debug("Creating DDF function %s...\n", HID_KBD_FUN_NAME);
 	ddf_fun_t *fun = ddf_fun_create(hid_dev->usb_dev->ddf_dev, fun_exposed, 
Index: uspace/drv/bus/usb/usbhid/mouse/mousedev.c
===================================================================
--- uspace/drv/bus/usb/usbhid/mouse/mousedev.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/drv/bus/usb/usbhid/mouse/mousedev.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -325,5 +325,5 @@
 	assert(mouse != NULL);
 	
-	/* Create the function exposed under /dev/devices. */
+	/* Create the exposed function. */
 	usb_log_debug("Creating DDF function %s...\n", HID_MOUSE_FUN_NAME);
 	ddf_fun_t *fun = ddf_fun_create(hid_dev->usb_dev->ddf_dev, fun_exposed, 
Index: uspace/drv/bus/usb/usbhid/multimedia/multimedia.c
===================================================================
--- uspace/drv/bus/usb/usbhid/multimedia/multimedia.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/drv/bus/usb/usbhid/multimedia/multimedia.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -185,5 +185,5 @@
     usb_multimedia_t *multim_dev)
 {
-	/* Create the function exposed under /dev/devices. */
+	/* Create the exposed function. */
 	ddf_fun_t *fun = ddf_fun_create(hid_dev->usb_dev->ddf_dev, fun_exposed, 
 	    NAME);
Index: uspace/drv/bus/usb/vhc/main.c
===================================================================
--- uspace/drv/bus/usb/vhc/main.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/drv/bus/usb/vhc/main.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -34,5 +34,5 @@
  */
 
-#include <devmap.h>
+#include <loc.h>
 #include <async.h>
 #include <unistd.h>
Index: uspace/lib/block/libblock.c
===================================================================
--- uspace/lib/block/libblock.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/lib/block/libblock.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -39,5 +39,5 @@
 #include "libblock.h"
 #include "../../srv/vfs/vfs.h"
-#include <ipc/devmap.h>
+#include <ipc/loc.h>
 #include <ipc/bd.h>
 #include <ipc/services.h>
@@ -78,5 +78,5 @@
 typedef struct {
 	link_t link;
-	devmap_handle_t devmap_handle;
+	service_id_t service_id;
 	async_sess_t *sess;
 	fibril_mutex_t comm_area_lock;
@@ -95,5 +95,5 @@
 static aoff64_t ba_ltop(devcon_t *, aoff64_t);
 
-static devcon_t *devcon_search(devmap_handle_t devmap_handle)
+static devcon_t *devcon_search(service_id_t service_id)
 {
 	fibril_mutex_lock(&dcl_lock);
@@ -101,5 +101,5 @@
 	list_foreach(dcl, cur) {
 		devcon_t *devcon = list_get_instance(cur, devcon_t, link);
-		if (devcon->devmap_handle == devmap_handle) {
+		if (devcon->service_id == service_id) {
 			fibril_mutex_unlock(&dcl_lock);
 			return devcon;
@@ -111,5 +111,5 @@
 }
 
-static int devcon_add(devmap_handle_t devmap_handle, async_sess_t *sess,
+static int devcon_add(service_id_t service_id, async_sess_t *sess,
     size_t bsize, void *comm_area, size_t comm_size)
 {
@@ -124,5 +124,5 @@
 	
 	link_initialize(&devcon->link);
-	devcon->devmap_handle = devmap_handle;
+	devcon->service_id = service_id;
 	devcon->sess = sess;
 	fibril_mutex_initialize(&devcon->comm_area_lock);
@@ -137,5 +137,5 @@
 	list_foreach(dcl, cur) {
 		devcon_t *d = list_get_instance(cur, devcon_t, link);
-		if (d->devmap_handle == devmap_handle) {
+		if (d->service_id == service_id) {
 			fibril_mutex_unlock(&dcl_lock);
 			free(devcon);
@@ -155,5 +155,5 @@
 }
 
-int block_init(exch_mgmt_t mgmt, devmap_handle_t devmap_handle,
+int block_init(exch_mgmt_t mgmt, service_id_t service_id,
     size_t comm_size)
 {
@@ -163,5 +163,5 @@
 		return ENOMEM;
 	
-	async_sess_t *sess = devmap_device_connect(mgmt, devmap_handle,
+	async_sess_t *sess = loc_service_connect(mgmt, service_id,
 	    IPC_FLAG_BLOCKING);
 	if (!sess) {
@@ -190,5 +190,5 @@
 	}
 	
-	rc = devcon_add(devmap_handle, sess, bsize, comm_area, comm_size);
+	rc = devcon_add(service_id, sess, bsize, comm_area, comm_size);
 	if (rc != EOK) {
 		munmap(comm_area, comm_size);
@@ -200,11 +200,11 @@
 }
 
-void block_fini(devmap_handle_t devmap_handle)
-{
-	devcon_t *devcon = devcon_search(devmap_handle);
+void block_fini(service_id_t service_id)
+{
+	devcon_t *devcon = devcon_search(service_id);
 	assert(devcon);
 	
 	if (devcon->cache)
-		(void) block_cache_fini(devmap_handle);
+		(void) block_cache_fini(service_id);
 	
 	devcon_remove(devcon);
@@ -219,10 +219,10 @@
 }
 
-int block_bb_read(devmap_handle_t devmap_handle, aoff64_t ba)
+int block_bb_read(service_id_t service_id, aoff64_t ba)
 {
 	void *bb_buf;
 	int rc;
 
-	devcon_t *devcon = devcon_search(devmap_handle);
+	devcon_t *devcon = devcon_search(service_id);
 	if (!devcon)
 		return ENOENT;
@@ -249,7 +249,7 @@
 }
 
-void *block_bb_get(devmap_handle_t devmap_handle)
-{
-	devcon_t *devcon = devcon_search(devmap_handle);
+void *block_bb_get(service_id_t service_id)
+{
+	devcon_t *devcon = devcon_search(service_id);
 	assert(devcon);
 	return devcon->bb_buf;
@@ -277,8 +277,8 @@
 };
 
-int block_cache_init(devmap_handle_t devmap_handle, size_t size, unsigned blocks,
+int block_cache_init(service_id_t service_id, size_t size, unsigned blocks,
     enum cache_mode mode)
 {
-	devcon_t *devcon = devcon_search(devmap_handle);
+	devcon_t *devcon = devcon_search(service_id);
 	cache_t *cache;
 	if (!devcon)
@@ -315,7 +315,7 @@
 }
 
-int block_cache_fini(devmap_handle_t devmap_handle)
-{
-	devcon_t *devcon = devcon_search(devmap_handle);
+int block_cache_fini(service_id_t service_id)
+{
+	devcon_t *devcon = devcon_search(service_id);
 	cache_t *cache;
 	int rc;
@@ -384,5 +384,5 @@
  * @param block			Pointer to where the function will store the
  * 				block pointer on success.
- * @param devmap_handle		Device handle of the block device.
+ * @param service_id		Service ID of the block device.
  * @param ba			Block address (logical).
  * @param flags			If BLOCK_FLAGS_NOREAD is specified, block_get()
@@ -392,5 +392,5 @@
  * @return			EOK on success or a negative error code.
  */
-int block_get(block_t **block, devmap_handle_t devmap_handle, aoff64_t ba, int flags)
+int block_get(block_t **block, service_id_t service_id, aoff64_t ba, int flags)
 {
 	devcon_t *devcon;
@@ -401,5 +401,5 @@
 	int rc;
 	
-	devcon = devcon_search(devmap_handle);
+	devcon = devcon_search(service_id);
 
 	assert(devcon);
@@ -527,5 +527,5 @@
 
 		block_initialize(b);
-		b->devmap_handle = devmap_handle;
+		b->service_id = service_id;
 		b->size = cache->lblock_size;
 		b->lba = ba;
@@ -577,5 +577,5 @@
 int block_put(block_t *block)
 {
-	devcon_t *devcon = devcon_search(block->devmap_handle);
+	devcon_t *devcon = devcon_search(block->service_id);
 	cache_t *cache;
 	unsigned blocks_cached;
@@ -675,5 +675,5 @@
 /** Read sequential data from a block device.
  *
- * @param devmap_handle	Device handle of the block device.
+ * @param service_id	Service ID of the block device.
  * @param bufpos	Pointer to the first unread valid offset within the
  * 			communication buffer.
@@ -687,5 +687,5 @@
  * @return		EOK on success or a negative return code on failure.
  */
-int block_seqread(devmap_handle_t devmap_handle, size_t *bufpos, size_t *buflen,
+int block_seqread(service_id_t service_id, size_t *bufpos, size_t *buflen,
     aoff64_t *pos, void *dst, size_t size)
 {
@@ -695,5 +695,5 @@
 	devcon_t *devcon;
 
-	devcon = devcon_search(devmap_handle);
+	devcon = devcon_search(service_id);
 	assert(devcon);
 	block_size = devcon->pblock_size;
@@ -741,5 +741,5 @@
 /** Read blocks directly from device (bypass cache).
  *
- * @param devmap_handle	Device handle of the block device.
+ * @param service_id	Service ID of the block device.
  * @param ba		Address of first block (physical).
  * @param cnt		Number of blocks.
@@ -748,10 +748,10 @@
  * @return		EOK on success or negative error code on failure.
  */
-int block_read_direct(devmap_handle_t devmap_handle, aoff64_t ba, size_t cnt, void *buf)
+int block_read_direct(service_id_t service_id, aoff64_t ba, size_t cnt, void *buf)
 {
 	devcon_t *devcon;
 	int rc;
 
-	devcon = devcon_search(devmap_handle);
+	devcon = devcon_search(service_id);
 	assert(devcon);
 	
@@ -769,5 +769,5 @@
 /** Write blocks directly to device (bypass cache).
  *
- * @param devmap_handle	Device handle of the block device.
+ * @param service_id	Service ID of the block device.
  * @param ba		Address of first block (physical).
  * @param cnt		Number of blocks.
@@ -776,5 +776,5 @@
  * @return		EOK on success or negative error code on failure.
  */
-int block_write_direct(devmap_handle_t devmap_handle, aoff64_t ba, size_t cnt,
+int block_write_direct(service_id_t service_id, aoff64_t ba, size_t cnt,
     const void *data)
 {
@@ -782,5 +782,5 @@
 	int rc;
 
-	devcon = devcon_search(devmap_handle);
+	devcon = devcon_search(service_id);
 	assert(devcon);
 	
@@ -797,14 +797,14 @@
 /** Get device block size.
  *
- * @param devmap_handle	Device handle of the block device.
+ * @param service_id	Service ID of the block device.
  * @param bsize		Output block size.
  *
  * @return		EOK on success or negative error code on failure.
  */
-int block_get_bsize(devmap_handle_t devmap_handle, size_t *bsize)
+int block_get_bsize(service_id_t service_id, size_t *bsize)
 {
 	devcon_t *devcon;
 
-	devcon = devcon_search(devmap_handle);
+	devcon = devcon_search(service_id);
 	assert(devcon);
 	
@@ -814,12 +814,12 @@
 /** Get number of blocks on device.
  *
- * @param devmap_handle	Device handle of the block device.
+ * @param service_id	Service ID of the block device.
  * @param nblocks	Output number of blocks.
  *
  * @return		EOK on success or negative error code on failure.
  */
-int block_get_nblocks(devmap_handle_t devmap_handle, aoff64_t *nblocks)
-{
-	devcon_t *devcon = devcon_search(devmap_handle);
+int block_get_nblocks(service_id_t service_id, aoff64_t *nblocks)
+{
+	devcon_t *devcon = devcon_search(service_id);
 	assert(devcon);
 	
@@ -829,5 +829,5 @@
 /** Read bytes directly from the device (bypass cache)
  * 
- * @param devmap_handle	Device handle of the block device.
+ * @param service_id	Service ID of the block device.
  * @param abs_offset	Absolute offset in bytes where to start reading
  * @param bytes			Number of bytes to read
@@ -836,5 +836,5 @@
  * @return		EOK on success or negative error code on failure.
  */
-int block_read_bytes_direct(devmap_handle_t devmap_handle, aoff64_t abs_offset,
+int block_read_bytes_direct(service_id_t service_id, aoff64_t abs_offset,
     size_t bytes, void *data)
 {
@@ -848,5 +848,5 @@
 	size_t offset;
 	
-	rc = block_get_bsize(devmap_handle, &phys_block_size);
+	rc = block_get_bsize(service_id, &phys_block_size);
 	if (rc != EOK) {
 		return rc;
@@ -866,5 +866,5 @@
 	}
 	
-	rc = block_read_direct(devmap_handle, first_block, blocks, buffer);
+	rc = block_read_direct(service_id, first_block, blocks, buffer);
 	if (rc != EOK) {
 		free(buffer);
@@ -900,5 +900,5 @@
 		printf("Error %d reading %zu blocks starting at block %" PRIuOFF64
 		    " from device handle %" PRIun "\n", rc, cnt, ba,
-		    devcon->devmap_handle);
+		    devcon->service_id);
 #ifndef NDEBUG
 		stacktrace_print();
@@ -929,5 +929,5 @@
 	if (rc != EOK) {
 		printf("Error %d writing %zu blocks starting at block %" PRIuOFF64
-		    " to device handle %" PRIun "\n", rc, cnt, ba, devcon->devmap_handle);
+		    " to device handle %" PRIun "\n", rc, cnt, ba, devcon->service_id);
 #ifndef NDEBUG
 		stacktrace_print();
Index: uspace/lib/block/libblock.h
===================================================================
--- uspace/lib/block/libblock.h	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/lib/block/libblock.h	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2008 Jakub Jermar
- * Copyright (c) 2008 Martin Decky 
- * Copyright (c) 2011 Martin Sucha 
+ * Copyright (c) 2008 Martin Decky
+ * Copyright (c) 2011 Martin Sucha
  * All rights reserved.
  *
@@ -73,6 +73,6 @@
 	/** Readers / Writer lock protecting the contents of the block. */
 	fibril_rwlock_t contents_lock;
-	/** Handle of the device where the block resides. */
-	devmap_handle_t devmap_handle;
+	/** Service ID of service providing the block device. */
+	service_id_t service_id;
 	/** Logical block address */
 	aoff64_t lba;
@@ -97,24 +97,24 @@
 };
 
-extern int block_init(exch_mgmt_t, devmap_handle_t, size_t);
-extern void block_fini(devmap_handle_t);
+extern int block_init(exch_mgmt_t, service_id_t, size_t);
+extern void block_fini(service_id_t);
 
-extern int block_bb_read(devmap_handle_t, aoff64_t);
-extern void *block_bb_get(devmap_handle_t);
+extern int block_bb_read(service_id_t, aoff64_t);
+extern void *block_bb_get(service_id_t);
 
-extern int block_cache_init(devmap_handle_t, size_t, unsigned, enum cache_mode);
-extern int block_cache_fini(devmap_handle_t);
+extern int block_cache_init(service_id_t, size_t, unsigned, enum cache_mode);
+extern int block_cache_fini(service_id_t);
 
-extern int block_get(block_t **, devmap_handle_t, aoff64_t, int);
+extern int block_get(block_t **, service_id_t, aoff64_t, int);
 extern int block_put(block_t *);
 
-extern int block_seqread(devmap_handle_t, size_t *, size_t *, aoff64_t *, void *,
+extern int block_seqread(service_id_t, size_t *, size_t *, aoff64_t *, void *,
     size_t);
 
-extern int block_get_bsize(devmap_handle_t, size_t *);
-extern int block_get_nblocks(devmap_handle_t, aoff64_t *);
-extern int block_read_direct(devmap_handle_t, aoff64_t, size_t, void *);
-extern int block_read_bytes_direct(devmap_handle_t, aoff64_t, size_t, void *);
-extern int block_write_direct(devmap_handle_t, aoff64_t, size_t, const void *);
+extern int block_get_bsize(service_id_t, size_t *);
+extern int block_get_nblocks(service_id_t, aoff64_t *);
+extern int block_read_direct(service_id_t, aoff64_t, size_t, void *);
+extern int block_read_bytes_direct(service_id_t, aoff64_t, size_t, void *);
+extern int block_write_direct(service_id_t, aoff64_t, size_t, const void *);
 
 #endif
Index: uspace/lib/c/Makefile
===================================================================
--- uspace/lib/c/Makefile	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/lib/c/Makefile	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -67,5 +67,4 @@
 	generic/cap.c \
 	generic/clipboard.c \
-	generic/devmap.c \
 	generic/devman.c \
 	generic/device/hw_res.c \
@@ -73,4 +72,5 @@
 	generic/event.c \
 	generic/errno.c \
+	generic/loc.c \
 	generic/mem.c \
 	generic/str.c \
Index: pace/lib/c/generic/devmap.c
===================================================================
--- uspace/lib/c/generic/devmap.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ 	(revision )
@@ -1,521 +1,0 @@
-/*
- * Copyright (c) 2007 Josef Cejka
- * Copyright (c) 2009 Jiri Svoboda
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <str.h>
-#include <ipc/services.h>
-#include <ns.h>
-#include <ipc/devmap.h>
-#include <devmap.h>
-#include <fibril_synch.h>
-#include <async.h>
-#include <errno.h>
-#include <malloc.h>
-#include <bool.h>
-
-static FIBRIL_MUTEX_INITIALIZE(devmap_driver_block_mutex);
-static FIBRIL_MUTEX_INITIALIZE(devmap_client_block_mutex);
-
-static FIBRIL_MUTEX_INITIALIZE(devmap_driver_mutex);
-static FIBRIL_MUTEX_INITIALIZE(devmap_client_mutex);
-
-static async_sess_t *devmap_driver_block_sess = NULL;
-static async_sess_t *devmap_client_block_sess = NULL;
-
-static async_sess_t *devmap_driver_sess = NULL;
-static async_sess_t *devmap_client_sess = NULL;
-
-static void clone_session(fibril_mutex_t *mtx, async_sess_t *src,
-    async_sess_t **dst)
-{
-	fibril_mutex_lock(mtx);
-	
-	if ((*dst == NULL) && (src != NULL))
-		*dst = src;
-	
-	fibril_mutex_unlock(mtx);
-}
-
-/** Start an async exchange on the devmap session (blocking).
- *
- * @param iface Device mapper interface to choose
- *
- * @return New exchange.
- *
- */
-async_exch_t *devmap_exchange_begin_blocking(devmap_interface_t iface)
-{
-	switch (iface) {
-	case DEVMAP_DRIVER:
-		fibril_mutex_lock(&devmap_driver_block_mutex);
-		
-		while (devmap_driver_block_sess == NULL) {
-			clone_session(&devmap_driver_mutex, devmap_driver_sess,
-			    &devmap_driver_block_sess);
-			
-			if (devmap_driver_block_sess == NULL)
-				devmap_driver_block_sess =
-				    service_connect_blocking(EXCHANGE_SERIALIZE,
-				    SERVICE_DEVMAP, DEVMAP_DRIVER, 0);
-		}
-		
-		fibril_mutex_unlock(&devmap_driver_block_mutex);
-		
-		clone_session(&devmap_driver_mutex, devmap_driver_block_sess,
-		    &devmap_driver_sess);
-		
-		return async_exchange_begin(devmap_driver_block_sess);
-	case DEVMAP_CLIENT:
-		fibril_mutex_lock(&devmap_client_block_mutex);
-		
-		while (devmap_client_block_sess == NULL) {
-			clone_session(&devmap_client_mutex, devmap_client_sess,
-			    &devmap_client_block_sess);
-			
-			if (devmap_client_block_sess == NULL)
-				devmap_client_block_sess =
-				    service_connect_blocking(EXCHANGE_SERIALIZE,
-				    SERVICE_DEVMAP, DEVMAP_CLIENT, 0);
-		}
-		
-		fibril_mutex_unlock(&devmap_client_block_mutex);
-		
-		clone_session(&devmap_client_mutex, devmap_client_block_sess,
-		    &devmap_client_sess);
-		
-		return async_exchange_begin(devmap_client_block_sess);
-	default:
-		return NULL;
-	}
-}
-
-/** Start an async exchange on the devmap session.
- *
- * @param iface Device mapper interface to choose
- *
- * @return New exchange.
- *
- */
-async_exch_t *devmap_exchange_begin(devmap_interface_t iface)
-{
-	switch (iface) {
-	case DEVMAP_DRIVER:
-		fibril_mutex_lock(&devmap_driver_mutex);
-		
-		if (devmap_driver_sess == NULL)
-			devmap_driver_sess =
-			    service_connect(EXCHANGE_SERIALIZE, SERVICE_DEVMAP,
-			    DEVMAP_DRIVER, 0);
-		
-		fibril_mutex_unlock(&devmap_driver_mutex);
-		
-		if (devmap_driver_sess == NULL)
-			return NULL;
-		
-		return async_exchange_begin(devmap_driver_sess);
-	case DEVMAP_CLIENT:
-		fibril_mutex_lock(&devmap_client_mutex);
-		
-		if (devmap_client_sess == NULL)
-			devmap_client_sess =
-			    service_connect(EXCHANGE_SERIALIZE, SERVICE_DEVMAP,
-			    DEVMAP_CLIENT, 0);
-		
-		fibril_mutex_unlock(&devmap_client_mutex);
-		
-		if (devmap_client_sess == NULL)
-			return NULL;
-		
-		return async_exchange_begin(devmap_client_sess);
-	default:
-		return NULL;
-	}
-}
-
-/** Finish an async exchange on the devmap session.
- *
- * @param exch Exchange to be finished.
- *
- */
-void devmap_exchange_end(async_exch_t *exch)
-{
-	async_exchange_end(exch);
-}
-
-/** Register new driver with devmap. */
-int devmap_driver_register(const char *name, async_client_conn_t conn)
-{
-	async_exch_t *exch = devmap_exchange_begin_blocking(DEVMAP_DRIVER);
-	
-	ipc_call_t answer;
-	aid_t req = async_send_2(exch, DEVMAP_DRIVER_REGISTER, 0, 0, &answer);
-	sysarg_t retval = async_data_write_start(exch, name, str_size(name));
-	
-	devmap_exchange_end(exch);
-	
-	if (retval != EOK) {
-		async_wait_for(req, NULL);
-		return retval;
-	}
-	
-	async_set_client_connection(conn);
-	
-	exch = devmap_exchange_begin(DEVMAP_DRIVER);
-	async_connect_to_me(exch, 0, 0, 0, NULL, NULL);
-	devmap_exchange_end(exch);
-	
-	async_wait_for(req, &retval);
-	return retval;
-}
-
-/** Register new device.
- *
- * The @p interface is used when forwarding connection to the driver.
- * If not 0, the first argument is the interface and the second argument
- * is the devmap handle of the device.
- *
- * When the interface is zero (default), the first argument is directly
- * the handle (to ensure backward compatibility).
- *
- * @param      fqdn      Fully qualified device name.
- * @param[out] handle    Handle to the created instance of device.
- * @param      interface Interface when forwarding.
- *
- */
-int devmap_device_register_with_iface(const char *fqdn,
-    devmap_handle_t *handle, sysarg_t interface)
-{
-	async_exch_t *exch = devmap_exchange_begin_blocking(DEVMAP_DRIVER);
-	
-	ipc_call_t answer;
-	aid_t req = async_send_2(exch, DEVMAP_DEVICE_REGISTER, interface, 0,
-	    &answer);
-	sysarg_t retval = async_data_write_start(exch, fqdn, str_size(fqdn));
-	
-	devmap_exchange_end(exch);
-	
-	if (retval != EOK) {
-		async_wait_for(req, NULL);
-		return retval;
-	}
-	
-	async_wait_for(req, &retval);
-	
-	if (retval != EOK) {
-		if (handle != NULL)
-			*handle = -1;
-		
-		return retval;
-	}
-	
-	if (handle != NULL)
-		*handle = (devmap_handle_t) IPC_GET_ARG1(answer);
-	
-	return retval;
-}
-
-/** Register new device.
- *
- * @param fqdn   Fully qualified device name.
- * @param handle Output: Handle to the created instance of device.
- *
- */
-int devmap_device_register(const char *fqdn, devmap_handle_t *handle)
-{
-	return devmap_device_register_with_iface(fqdn, handle, 0);
-}
-
-int devmap_device_get_handle(const char *fqdn, devmap_handle_t *handle,
-    unsigned int flags)
-{
-	async_exch_t *exch;
-	
-	if (flags & IPC_FLAG_BLOCKING)
-		exch = devmap_exchange_begin_blocking(DEVMAP_CLIENT);
-	else {
-		exch = devmap_exchange_begin(DEVMAP_CLIENT);
-		if (exch == NULL)
-			return errno;
-	}
-	
-	ipc_call_t answer;
-	aid_t req = async_send_2(exch, DEVMAP_DEVICE_GET_HANDLE, flags, 0,
-	    &answer);
-	sysarg_t retval = async_data_write_start(exch, fqdn, str_size(fqdn));
-	
-	devmap_exchange_end(exch);
-	
-	if (retval != EOK) {
-		async_wait_for(req, NULL);
-		return retval;
-	}
-	
-	async_wait_for(req, &retval);
-	
-	if (retval != EOK) {
-		if (handle != NULL)
-			*handle = (devmap_handle_t) -1;
-		
-		return retval;
-	}
-	
-	if (handle != NULL)
-		*handle = (devmap_handle_t) IPC_GET_ARG1(answer);
-	
-	return retval;
-}
-
-int devmap_namespace_get_handle(const char *name, devmap_handle_t *handle,
-    unsigned int flags)
-{
-	async_exch_t *exch;
-	
-	if (flags & IPC_FLAG_BLOCKING)
-		exch = devmap_exchange_begin_blocking(DEVMAP_CLIENT);
-	else {
-		exch = devmap_exchange_begin(DEVMAP_CLIENT);
-		if (exch == NULL)
-			return errno;
-	}
-	
-	ipc_call_t answer;
-	aid_t req = async_send_2(exch, DEVMAP_NAMESPACE_GET_HANDLE, flags, 0,
-	    &answer);
-	sysarg_t retval = async_data_write_start(exch, name, str_size(name));
-	
-	devmap_exchange_end(exch);
-	
-	if (retval != EOK) {
-		async_wait_for(req, NULL);
-		return retval;
-	}
-	
-	async_wait_for(req, &retval);
-	
-	if (retval != EOK) {
-		if (handle != NULL)
-			*handle = (devmap_handle_t) -1;
-		
-		return retval;
-	}
-	
-	if (handle != NULL)
-		*handle = (devmap_handle_t) IPC_GET_ARG1(answer);
-	
-	return retval;
-}
-
-devmap_handle_type_t devmap_handle_probe(devmap_handle_t handle)
-{
-	async_exch_t *exch = devmap_exchange_begin_blocking(DEVMAP_CLIENT);
-	
-	sysarg_t type;
-	int retval = async_req_1_1(exch, DEVMAP_HANDLE_PROBE, handle, &type);
-	
-	devmap_exchange_end(exch);
-	
-	if (retval != EOK)
-		return DEV_HANDLE_NONE;
-	
-	return (devmap_handle_type_t) type;
-}
-
-async_sess_t *devmap_device_connect(exch_mgmt_t mgmt, devmap_handle_t handle,
-    unsigned int flags)
-{
-	async_sess_t *sess;
-	
-	if (flags & IPC_FLAG_BLOCKING)
-		sess = service_connect_blocking(mgmt, SERVICE_DEVMAP,
-		    DEVMAP_CONNECT_TO_DEVICE, handle);
-	else
-		sess = service_connect(mgmt, SERVICE_DEVMAP,
-		    DEVMAP_CONNECT_TO_DEVICE, handle);
-	
-	return sess;
-}
-
-int devmap_null_create(void)
-{
-	async_exch_t *exch = devmap_exchange_begin_blocking(DEVMAP_CLIENT);
-	
-	sysarg_t null_id;
-	int retval = async_req_0_1(exch, DEVMAP_NULL_CREATE, &null_id);
-	
-	devmap_exchange_end(exch);
-	
-	if (retval != EOK)
-		return -1;
-	
-	return (int) null_id;
-}
-
-void devmap_null_destroy(int null_id)
-{
-	async_exch_t *exch = devmap_exchange_begin_blocking(DEVMAP_CLIENT);
-	async_req_1_0(exch, DEVMAP_NULL_DESTROY, (sysarg_t) null_id);
-	devmap_exchange_end(exch);
-}
-
-static size_t devmap_count_namespaces_internal(async_exch_t *exch)
-{
-	sysarg_t count;
-	int retval = async_req_0_1(exch, DEVMAP_GET_NAMESPACE_COUNT, &count);
-	if (retval != EOK)
-		return 0;
-	
-	return count;
-}
-
-static size_t devmap_count_devices_internal(async_exch_t *exch,
-    devmap_handle_t ns_handle)
-{
-	sysarg_t count;
-	int retval = async_req_1_1(exch, DEVMAP_GET_DEVICE_COUNT, ns_handle,
-	    &count);
-	if (retval != EOK)
-		return 0;
-	
-	return count;
-}
-
-size_t devmap_count_namespaces(void)
-{
-	async_exch_t *exch = devmap_exchange_begin_blocking(DEVMAP_CLIENT);
-	size_t size = devmap_count_namespaces_internal(exch);
-	devmap_exchange_end(exch);
-	
-	return size;
-}
-
-size_t devmap_count_devices(devmap_handle_t ns_handle)
-{
-	async_exch_t *exch = devmap_exchange_begin_blocking(DEVMAP_CLIENT);
-	size_t size = devmap_count_devices_internal(exch, ns_handle);
-	devmap_exchange_end(exch);
-	
-	return size;
-}
-
-size_t devmap_get_namespaces(dev_desc_t **data)
-{
-	/* Loop until namespaces read succesful */
-	while (true) {
-		async_exch_t *exch = devmap_exchange_begin_blocking(DEVMAP_CLIENT);
-		size_t count = devmap_count_namespaces_internal(exch);
-		devmap_exchange_end(exch);
-		
-		if (count == 0)
-			return 0;
-		
-		dev_desc_t *devs = (dev_desc_t *) calloc(count, sizeof(dev_desc_t));
-		if (devs == NULL)
-			return 0;
-		
-		exch = devmap_exchange_begin(DEVMAP_CLIENT);
-		
-		ipc_call_t answer;
-		aid_t req = async_send_0(exch, DEVMAP_GET_NAMESPACES, &answer);
-		int rc = async_data_read_start(exch, devs, count * sizeof(dev_desc_t));
-		
-		devmap_exchange_end(exch);
-		
-		if (rc == EOVERFLOW) {
-			/*
-			 * Number of namespaces has changed since
-			 * the last call of DEVMAP_DEVICE_GET_NAMESPACE_COUNT
-			 */
-			free(devs);
-			continue;
-		}
-		
-		if (rc != EOK) {
-			async_wait_for(req, NULL);
-			free(devs);
-			return 0;
-		}
-		
-		sysarg_t retval;
-		async_wait_for(req, &retval);
-		
-		if (retval != EOK)
-			return 0;
-		
-		*data = devs;
-		return count;
-	}
-}
-
-size_t devmap_get_devices(devmap_handle_t ns_handle, dev_desc_t **data)
-{
-	/* Loop until devices read succesful */
-	while (true) {
-		async_exch_t *exch = devmap_exchange_begin_blocking(DEVMAP_CLIENT);
-		size_t count = devmap_count_devices_internal(exch, ns_handle);
-		devmap_exchange_end(exch);
-		
-		if (count == 0)
-			return 0;
-		
-		dev_desc_t *devs = (dev_desc_t *) calloc(count, sizeof(dev_desc_t));
-		if (devs == NULL)
-			return 0;
-		
-		exch = devmap_exchange_begin(DEVMAP_CLIENT);
-		
-		ipc_call_t answer;
-		aid_t req = async_send_1(exch, DEVMAP_GET_DEVICES, ns_handle, &answer);
-		int rc = async_data_read_start(exch, devs, count * sizeof(dev_desc_t));
-		
-		devmap_exchange_end(exch);
-		
-		if (rc == EOVERFLOW) {
-			/*
-			 * Number of devices has changed since
-			 * the last call of DEVMAP_DEVICE_GET_DEVICE_COUNT
-			 */
-			free(devs);
-			continue;
-		}
-		
-		if (rc != EOK) {
-			async_wait_for(req, NULL);
-			free(devs);
-			return 0;
-		}
-		
-		sysarg_t retval;
-		async_wait_for(req, &retval);
-		
-		if (retval != EOK)
-			return 0;
-		
-		*data = devs;
-		return count;
-	}
-}
Index: uspace/lib/c/generic/io/io.c
===================================================================
--- uspace/lib/c/generic/io/io.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/lib/c/generic/io/io.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -45,5 +45,5 @@
 #include <vfs/vfs.h>
 #include <vfs/vfs_sess.h>
-#include <ipc/devmap.h>
+#include <ipc/loc.h>
 #include <adt/list.h>
 #include "../private/io.h"
Index: uspace/lib/c/generic/loc.c
===================================================================
--- uspace/lib/c/generic/loc.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
+++ uspace/lib/c/generic/loc.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -0,0 +1,521 @@
+/*
+ * Copyright (c) 2007 Josef Cejka
+ * Copyright (c) 2009 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <str.h>
+#include <ipc/services.h>
+#include <ns.h>
+#include <ipc/loc.h>
+#include <loc.h>
+#include <fibril_synch.h>
+#include <async.h>
+#include <errno.h>
+#include <malloc.h>
+#include <bool.h>
+
+static FIBRIL_MUTEX_INITIALIZE(loc_supp_block_mutex);
+static FIBRIL_MUTEX_INITIALIZE(loc_cons_block_mutex);
+
+static FIBRIL_MUTEX_INITIALIZE(loc_supplier_mutex);
+static FIBRIL_MUTEX_INITIALIZE(loc_consumer_mutex);
+
+static async_sess_t *loc_supp_block_sess = NULL;
+static async_sess_t *loc_cons_block_sess = NULL;
+
+static async_sess_t *loc_supplier_sess = NULL;
+static async_sess_t *loc_consumer_sess = NULL;
+
+static void clone_session(fibril_mutex_t *mtx, async_sess_t *src,
+    async_sess_t **dst)
+{
+	fibril_mutex_lock(mtx);
+	
+	if ((*dst == NULL) && (src != NULL))
+		*dst = src;
+	
+	fibril_mutex_unlock(mtx);
+}
+
+/** Start an async exchange on the loc session (blocking).
+ *
+ * @param iface Location service interface to choose
+ *
+ * @return New exchange.
+ *
+ */
+async_exch_t *loc_exchange_begin_blocking(loc_interface_t iface)
+{
+	switch (iface) {
+	case LOC_PORT_SUPPLIER:
+		fibril_mutex_lock(&loc_supp_block_mutex);
+		
+		while (loc_supp_block_sess == NULL) {
+			clone_session(&loc_supplier_mutex, loc_supplier_sess,
+			    &loc_supp_block_sess);
+			
+			if (loc_supp_block_sess == NULL)
+				loc_supp_block_sess =
+				    service_connect_blocking(EXCHANGE_SERIALIZE,
+				    SERVICE_LOC, LOC_PORT_SUPPLIER, 0);
+		}
+		
+		fibril_mutex_unlock(&loc_supp_block_mutex);
+		
+		clone_session(&loc_supplier_mutex, loc_supp_block_sess,
+		    &loc_supplier_sess);
+		
+		return async_exchange_begin(loc_supp_block_sess);
+	case LOC_PORT_CONSUMER:
+		fibril_mutex_lock(&loc_cons_block_mutex);
+		
+		while (loc_cons_block_sess == NULL) {
+			clone_session(&loc_consumer_mutex, loc_consumer_sess,
+			    &loc_cons_block_sess);
+			
+			if (loc_cons_block_sess == NULL)
+				loc_cons_block_sess =
+				    service_connect_blocking(EXCHANGE_SERIALIZE,
+				    SERVICE_LOC, LOC_PORT_CONSUMER, 0);
+		}
+		
+		fibril_mutex_unlock(&loc_cons_block_mutex);
+		
+		clone_session(&loc_consumer_mutex, loc_cons_block_sess,
+		    &loc_consumer_sess);
+		
+		return async_exchange_begin(loc_cons_block_sess);
+	default:
+		return NULL;
+	}
+}
+
+/** Start an async exchange on the loc session.
+ *
+ * @param iface Location service interface to choose
+ *
+ * @return New exchange.
+ *
+ */
+async_exch_t *loc_exchange_begin(loc_interface_t iface)
+{
+	switch (iface) {
+	case LOC_PORT_SUPPLIER:
+		fibril_mutex_lock(&loc_supplier_mutex);
+		
+		if (loc_supplier_sess == NULL)
+			loc_supplier_sess =
+			    service_connect(EXCHANGE_SERIALIZE, SERVICE_LOC,
+			    LOC_PORT_SUPPLIER, 0);
+		
+		fibril_mutex_unlock(&loc_supplier_mutex);
+		
+		if (loc_supplier_sess == NULL)
+			return NULL;
+		
+		return async_exchange_begin(loc_supplier_sess);
+	case LOC_PORT_CONSUMER:
+		fibril_mutex_lock(&loc_consumer_mutex);
+		
+		if (loc_consumer_sess == NULL)
+			loc_consumer_sess =
+			    service_connect(EXCHANGE_SERIALIZE, SERVICE_LOC,
+			    LOC_PORT_CONSUMER, 0);
+		
+		fibril_mutex_unlock(&loc_consumer_mutex);
+		
+		if (loc_consumer_sess == NULL)
+			return NULL;
+		
+		return async_exchange_begin(loc_consumer_sess);
+	default:
+		return NULL;
+	}
+}
+
+/** Finish an async exchange on the loc session.
+ *
+ * @param exch Exchange to be finished.
+ *
+ */
+void loc_exchange_end(async_exch_t *exch)
+{
+	async_exchange_end(exch);
+}
+
+/** Register new driver with loc. */
+int loc_server_register(const char *name, async_client_conn_t conn)
+{
+	async_exch_t *exch = loc_exchange_begin_blocking(LOC_PORT_SUPPLIER);
+	
+	ipc_call_t answer;
+	aid_t req = async_send_2(exch, LOC_SERVER_REGISTER, 0, 0, &answer);
+	sysarg_t retval = async_data_write_start(exch, name, str_size(name));
+	
+	loc_exchange_end(exch);
+	
+	if (retval != EOK) {
+		async_wait_for(req, NULL);
+		return retval;
+	}
+	
+	async_set_client_connection(conn);
+	
+	exch = loc_exchange_begin(LOC_PORT_SUPPLIER);
+	async_connect_to_me(exch, 0, 0, 0, NULL, NULL);
+	loc_exchange_end(exch);
+	
+	async_wait_for(req, &retval);
+	return retval;
+}
+
+/** Register new device.
+ *
+ * The @p interface is used when forwarding connection to the driver.
+ * If not 0, the first argument is the interface and the second argument
+ * is the service ID.
+ *
+ * When the interface is zero (default), the first argument is directly
+ * the handle (to ensure backward compatibility).
+ *
+ * @param      fqdn      Fully qualified device name.
+ * @param[out] handle    Handle to the created instance of device.
+ * @param      interface Interface when forwarding.
+ *
+ */
+int loc_service_register_with_iface(const char *fqdn,
+    service_id_t *handle, sysarg_t interface)
+{
+	async_exch_t *exch = loc_exchange_begin_blocking(LOC_PORT_SUPPLIER);
+	
+	ipc_call_t answer;
+	aid_t req = async_send_2(exch, LOC_SERVICE_REGISTER, interface, 0,
+	    &answer);
+	sysarg_t retval = async_data_write_start(exch, fqdn, str_size(fqdn));
+	
+	loc_exchange_end(exch);
+	
+	if (retval != EOK) {
+		async_wait_for(req, NULL);
+		return retval;
+	}
+	
+	async_wait_for(req, &retval);
+	
+	if (retval != EOK) {
+		if (handle != NULL)
+			*handle = -1;
+		
+		return retval;
+	}
+	
+	if (handle != NULL)
+		*handle = (service_id_t) IPC_GET_ARG1(answer);
+	
+	return retval;
+}
+
+/** Register new device.
+ *
+ * @param fqdn   Fully qualified device name.
+ * @param handle Output: Handle to the created instance of device.
+ *
+ */
+int loc_service_register(const char *fqdn, service_id_t *handle)
+{
+	return loc_service_register_with_iface(fqdn, handle, 0);
+}
+
+int loc_service_get_id(const char *fqdn, service_id_t *handle,
+    unsigned int flags)
+{
+	async_exch_t *exch;
+	
+	if (flags & IPC_FLAG_BLOCKING)
+		exch = loc_exchange_begin_blocking(LOC_PORT_CONSUMER);
+	else {
+		exch = loc_exchange_begin(LOC_PORT_CONSUMER);
+		if (exch == NULL)
+			return errno;
+	}
+	
+	ipc_call_t answer;
+	aid_t req = async_send_2(exch, LOC_SERVICE_GET_ID, flags, 0,
+	    &answer);
+	sysarg_t retval = async_data_write_start(exch, fqdn, str_size(fqdn));
+	
+	loc_exchange_end(exch);
+	
+	if (retval != EOK) {
+		async_wait_for(req, NULL);
+		return retval;
+	}
+	
+	async_wait_for(req, &retval);
+	
+	if (retval != EOK) {
+		if (handle != NULL)
+			*handle = (service_id_t) -1;
+		
+		return retval;
+	}
+	
+	if (handle != NULL)
+		*handle = (service_id_t) IPC_GET_ARG1(answer);
+	
+	return retval;
+}
+
+int loc_namespace_get_id(const char *name, service_id_t *handle,
+    unsigned int flags)
+{
+	async_exch_t *exch;
+	
+	if (flags & IPC_FLAG_BLOCKING)
+		exch = loc_exchange_begin_blocking(LOC_PORT_CONSUMER);
+	else {
+		exch = loc_exchange_begin(LOC_PORT_CONSUMER);
+		if (exch == NULL)
+			return errno;
+	}
+	
+	ipc_call_t answer;
+	aid_t req = async_send_2(exch, LOC_NAMESPACE_GET_ID, flags, 0,
+	    &answer);
+	sysarg_t retval = async_data_write_start(exch, name, str_size(name));
+	
+	loc_exchange_end(exch);
+	
+	if (retval != EOK) {
+		async_wait_for(req, NULL);
+		return retval;
+	}
+	
+	async_wait_for(req, &retval);
+	
+	if (retval != EOK) {
+		if (handle != NULL)
+			*handle = (service_id_t) -1;
+		
+		return retval;
+	}
+	
+	if (handle != NULL)
+		*handle = (service_id_t) IPC_GET_ARG1(answer);
+	
+	return retval;
+}
+
+loc_object_type_t loc_id_probe(service_id_t handle)
+{
+	async_exch_t *exch = loc_exchange_begin_blocking(LOC_PORT_CONSUMER);
+	
+	sysarg_t type;
+	int retval = async_req_1_1(exch, LOC_ID_PROBE, handle, &type);
+	
+	loc_exchange_end(exch);
+	
+	if (retval != EOK)
+		return LOC_OBJECT_NONE;
+	
+	return (loc_object_type_t) type;
+}
+
+async_sess_t *loc_service_connect(exch_mgmt_t mgmt, service_id_t handle,
+    unsigned int flags)
+{
+	async_sess_t *sess;
+	
+	if (flags & IPC_FLAG_BLOCKING)
+		sess = service_connect_blocking(mgmt, SERVICE_LOC,
+		    LOC_CONNECT_TO_SERVICE, handle);
+	else
+		sess = service_connect(mgmt, SERVICE_LOC,
+		    LOC_CONNECT_TO_SERVICE, handle);
+	
+	return sess;
+}
+
+int loc_null_create(void)
+{
+	async_exch_t *exch = loc_exchange_begin_blocking(LOC_PORT_CONSUMER);
+	
+	sysarg_t null_id;
+	int retval = async_req_0_1(exch, LOC_NULL_CREATE, &null_id);
+	
+	loc_exchange_end(exch);
+	
+	if (retval != EOK)
+		return -1;
+	
+	return (int) null_id;
+}
+
+void loc_null_destroy(int null_id)
+{
+	async_exch_t *exch = loc_exchange_begin_blocking(LOC_PORT_CONSUMER);
+	async_req_1_0(exch, LOC_NULL_DESTROY, (sysarg_t) null_id);
+	loc_exchange_end(exch);
+}
+
+static size_t loc_count_namespaces_internal(async_exch_t *exch)
+{
+	sysarg_t count;
+	int retval = async_req_0_1(exch, LOC_GET_NAMESPACE_COUNT, &count);
+	if (retval != EOK)
+		return 0;
+	
+	return count;
+}
+
+static size_t loc_count_services_internal(async_exch_t *exch,
+    service_id_t ns_handle)
+{
+	sysarg_t count;
+	int retval = async_req_1_1(exch, LOC_GET_SERVICE_COUNT, ns_handle,
+	    &count);
+	if (retval != EOK)
+		return 0;
+	
+	return count;
+}
+
+size_t loc_count_namespaces(void)
+{
+	async_exch_t *exch = loc_exchange_begin_blocking(LOC_PORT_CONSUMER);
+	size_t size = loc_count_namespaces_internal(exch);
+	loc_exchange_end(exch);
+	
+	return size;
+}
+
+size_t loc_count_services(service_id_t ns_handle)
+{
+	async_exch_t *exch = loc_exchange_begin_blocking(LOC_PORT_CONSUMER);
+	size_t size = loc_count_services_internal(exch, ns_handle);
+	loc_exchange_end(exch);
+	
+	return size;
+}
+
+size_t loc_get_namespaces(loc_sdesc_t **data)
+{
+	/* Loop until namespaces read succesful */
+	while (true) {
+		async_exch_t *exch = loc_exchange_begin_blocking(LOC_PORT_CONSUMER);
+		size_t count = loc_count_namespaces_internal(exch);
+		loc_exchange_end(exch);
+		
+		if (count == 0)
+			return 0;
+		
+		loc_sdesc_t *devs = (loc_sdesc_t *) calloc(count, sizeof(loc_sdesc_t));
+		if (devs == NULL)
+			return 0;
+		
+		exch = loc_exchange_begin(LOC_PORT_CONSUMER);
+		
+		ipc_call_t answer;
+		aid_t req = async_send_0(exch, LOC_GET_NAMESPACES, &answer);
+		int rc = async_data_read_start(exch, devs, count * sizeof(loc_sdesc_t));
+		
+		loc_exchange_end(exch);
+		
+		if (rc == EOVERFLOW) {
+			/*
+			 * Number of namespaces has changed since
+			 * the last call of LOC_GET_NAMESPACE_COUNT
+			 */
+			free(devs);
+			continue;
+		}
+		
+		if (rc != EOK) {
+			async_wait_for(req, NULL);
+			free(devs);
+			return 0;
+		}
+		
+		sysarg_t retval;
+		async_wait_for(req, &retval);
+		
+		if (retval != EOK)
+			return 0;
+		
+		*data = devs;
+		return count;
+	}
+}
+
+size_t loc_get_services(service_id_t ns_handle, loc_sdesc_t **data)
+{
+	/* Loop until devices read succesful */
+	while (true) {
+		async_exch_t *exch = loc_exchange_begin_blocking(LOC_PORT_CONSUMER);
+		size_t count = loc_count_services_internal(exch, ns_handle);
+		loc_exchange_end(exch);
+		
+		if (count == 0)
+			return 0;
+		
+		loc_sdesc_t *devs = (loc_sdesc_t *) calloc(count, sizeof(loc_sdesc_t));
+		if (devs == NULL)
+			return 0;
+		
+		exch = loc_exchange_begin(LOC_PORT_CONSUMER);
+		
+		ipc_call_t answer;
+		aid_t req = async_send_1(exch, LOC_GET_SERVICES, ns_handle, &answer);
+		int rc = async_data_read_start(exch, devs, count * sizeof(loc_sdesc_t));
+		
+		loc_exchange_end(exch);
+		
+		if (rc == EOVERFLOW) {
+			/*
+			 * Number of services has changed since
+			 * the last call of LOC_GET_SERVICE_COUNT
+			 */
+			free(devs);
+			continue;
+		}
+		
+		if (rc != EOK) {
+			async_wait_for(req, NULL);
+			free(devs);
+			return 0;
+		}
+		
+		sysarg_t retval;
+		async_wait_for(req, &retval);
+		
+		if (retval != EOK)
+			return 0;
+		
+		*data = devs;
+		return count;
+	}
+}
Index: uspace/lib/c/generic/vfs/vfs.c
===================================================================
--- uspace/lib/c/generic/vfs/vfs.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/lib/c/generic/vfs/vfs.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -51,7 +51,7 @@
 #include <assert.h>
 #include <str.h>
-#include <devmap.h>
+#include <loc.h>
 #include <ipc/vfs.h>
-#include <ipc/devmap.h>
+#include <ipc/loc.h>
 
 static FIBRIL_MUTEX_INITIALIZE(vfs_mutex);
@@ -142,27 +142,27 @@
 }
 
-int mount(const char *fs_name, const char *mp, const char *fqdn,
+int mount(const char *fs_name, const char *mp, const char *fqsn,
     const char *opts, unsigned int flags)
 {
 	int null_id = -1;
-	char null[DEVMAP_NAME_MAXLEN];
-	
-	if (str_cmp(fqdn, "") == 0) {
+	char null[LOC_NAME_MAXLEN];
+	
+	if (str_cmp(fqsn, "") == 0) {
 		/* No device specified, create a fresh
 		   null/%d device instead */
-		null_id = devmap_null_create();
+		null_id = loc_null_create();
 		
 		if (null_id == -1)
 			return ENOMEM;
 		
-		snprintf(null, DEVMAP_NAME_MAXLEN, "null/%d", null_id);
-		fqdn = null;
-	}
-	
-	devmap_handle_t devmap_handle;
-	int res = devmap_device_get_handle(fqdn, &devmap_handle, flags);
+		snprintf(null, LOC_NAME_MAXLEN, "null/%d", null_id);
+		fqsn = null;
+	}
+	
+	service_id_t service_id;
+	int res = loc_service_get_id(fqsn, &service_id, flags);
 	if (res != EOK) {
 		if (null_id != -1)
-			devmap_null_destroy(null_id);
+			loc_null_destroy(null_id);
 		
 		return res;
@@ -173,5 +173,5 @@
 	if (!mpa) {
 		if (null_id != -1)
-			devmap_null_destroy(null_id);
+			loc_null_destroy(null_id);
 		
 		return ENOMEM;
@@ -181,5 +181,5 @@
 
 	sysarg_t rc_orig;
-	aid_t req = async_send_2(exch, VFS_IN_MOUNT, devmap_handle, flags, NULL);
+	aid_t req = async_send_2(exch, VFS_IN_MOUNT, service_id, flags, NULL);
 	sysarg_t rc = async_data_write_start(exch, (void *) mpa, mpa_size);
 	if (rc != EOK) {
@@ -189,5 +189,5 @@
 		
 		if (null_id != -1)
-			devmap_null_destroy(null_id);
+			loc_null_destroy(null_id);
 		
 		if (rc_orig == EOK)
@@ -204,5 +204,5 @@
 		
 		if (null_id != -1)
-			devmap_null_destroy(null_id);
+			loc_null_destroy(null_id);
 		
 		if (rc_orig == EOK)
@@ -219,5 +219,5 @@
 		
 		if (null_id != -1)
-			devmap_null_destroy(null_id);
+			loc_null_destroy(null_id);
 		
 		if (rc_orig == EOK)
@@ -235,5 +235,5 @@
 		
 		if (null_id != -1)
-			devmap_null_destroy(null_id);
+			loc_null_destroy(null_id);
 		
 		if (rc_orig == EOK)
@@ -248,5 +248,5 @@
 	
 	if ((rc != EOK) && (null_id != -1))
-		devmap_null_destroy(null_id);
+		loc_null_destroy(null_id);
 	
 	return (int) rc;
@@ -335,5 +335,5 @@
 	ipc_call_t answer;
 	aid_t req = async_send_4(exch, VFS_IN_OPEN_NODE, node->fs_handle,
-	    node->devmap_handle, node->index, oflag, &answer);
+	    node->service_id, node->index, oflag, &answer);
 	
 	vfs_exchange_end(exch);
@@ -749,10 +749,10 @@
 	}
 	
-	if (!stat.device) {
+	if (!stat.service) {
 		errno = ENOENT;
 		return NULL;
 	}
 	
-	return devmap_device_connect(mgmt, stat.device, 0);
+	return loc_service_connect(mgmt, stat.service, 0);
 }
 
@@ -764,5 +764,5 @@
 	if (rc == EOK) {
 		node->fs_handle = stat.fs_handle;
-		node->devmap_handle = stat.devmap_handle;
+		node->service_id = stat.service_id;
 		node->index = stat.index;
 	}
Index: pace/lib/c/include/devmap.h
===================================================================
--- uspace/lib/c/include/devmap.h	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ 	(revision )
@@ -1,72 +1,0 @@
-/*
- * Copyright (c) 2009 Jiri Svoboda
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libc
- * @{
- */
-/** @file
- */
-
-#ifndef LIBC_DEVMAP_H_
-#define LIBC_DEVMAP_H_
-
-#include <ipc/devmap.h>
-#include <async.h>
-#include <bool.h>
-
-extern async_exch_t *devmap_exchange_begin_blocking(devmap_interface_t);
-extern async_exch_t *devmap_exchange_begin(devmap_interface_t);
-extern void devmap_exchange_end(async_exch_t *);
-
-extern int devmap_driver_register(const char *, async_client_conn_t);
-extern int devmap_device_register(const char *, devmap_handle_t *);
-extern int devmap_device_register_with_iface(const char *, devmap_handle_t *,
-    sysarg_t);
-
-extern int devmap_device_get_handle(const char *, devmap_handle_t *,
-    unsigned int);
-extern int devmap_namespace_get_handle(const char *, devmap_handle_t *,
-    unsigned int);
-extern devmap_handle_type_t devmap_handle_probe(devmap_handle_t);
-
-extern async_sess_t *devmap_device_connect(exch_mgmt_t, devmap_handle_t,
-    unsigned int);
-
-extern int devmap_null_create(void);
-extern void devmap_null_destroy(int);
-
-extern size_t devmap_count_namespaces(void);
-extern size_t devmap_count_devices(devmap_handle_t);
-
-extern size_t devmap_get_namespaces(dev_desc_t **);
-extern size_t devmap_get_devices(devmap_handle_t, dev_desc_t **);
-
-#endif
-
-/** @}
- */
Index: uspace/lib/c/include/ipc/devman.h
===================================================================
--- uspace/lib/c/include/ipc/devman.h	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/lib/c/include/ipc/devman.h	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -130,5 +130,5 @@
 	DEVMAN_CLIENT,
 	DEVMAN_CONNECT_TO_DEVICE,
-	DEVMAN_CONNECT_FROM_DEVMAP,
+	DEVMAN_CONNECT_FROM_LOC,
 	DEVMAN_CONNECT_TO_PARENTS_DEVICE
 } devman_interface_t;
Index: pace/lib/c/include/ipc/devmap.h
===================================================================
--- uspace/lib/c/include/ipc/devmap.h	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ 	(revision )
@@ -1,85 +1,0 @@
-/*
- * Copyright (c) 2007 Josef Cejka
- * 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 devmap
- * @{
- */
-
-#ifndef LIBC_IPC_DEVMAP_H_
-#define LIBC_IPC_DEVMAP_H_
-
-#include <ipc/common.h>
-
-#define DEVMAP_NAME_MAXLEN  255
-
-typedef sysarg_t devmap_handle_t;
-
-typedef enum {
-	DEV_HANDLE_NONE,
-	DEV_HANDLE_NAMESPACE,
-	DEV_HANDLE_DEVICE
-} devmap_handle_type_t;
-
-typedef enum {
-	DEVMAP_DRIVER_REGISTER = IPC_FIRST_USER_METHOD,
-	DEVMAP_DRIVER_UNREGISTER,
-	DEVMAP_DEVICE_REGISTER,
-	DEVMAP_DEVICE_UNREGISTER,
-	DEVMAP_DEVICE_GET_HANDLE,
-	DEVMAP_NAMESPACE_GET_HANDLE,
-	DEVMAP_HANDLE_PROBE,
-	DEVMAP_NULL_CREATE,
-	DEVMAP_NULL_DESTROY,
-	DEVMAP_GET_NAMESPACE_COUNT,
-	DEVMAP_GET_DEVICE_COUNT,
-	DEVMAP_GET_NAMESPACES,
-	DEVMAP_GET_DEVICES
-} devmap_request_t;
-
-/** Interface provided by devmap.
- *
- * Every process that connects to devmap must ask one of following
- * interfaces otherwise connection will be refused.
- *
- */
-typedef enum {
-	/** Connect as device driver */
-	DEVMAP_DRIVER = 1,
-	/** Connect as client */
-	DEVMAP_CLIENT,
-	/** Create new connection to instance of device that
-	    is specified by second argument of call. */
-	DEVMAP_CONNECT_TO_DEVICE
-} devmap_interface_t;
-
-typedef struct {
-	devmap_handle_t handle;
-	char name[DEVMAP_NAME_MAXLEN + 1];
-} dev_desc_t;
-
-#endif
Index: uspace/lib/c/include/ipc/loc.h
===================================================================
--- uspace/lib/c/include/ipc/loc.h	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
+++ uspace/lib/c/include/ipc/loc.h	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2007 Josef Cejka
+ * 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 loc
+ * @{
+ */
+
+#ifndef LIBC_IPC_LOC_H_
+#define LIBC_IPC_LOC_H_
+
+#include <ipc/common.h>
+
+#define LOC_NAME_MAXLEN  255
+
+typedef sysarg_t service_id_t;
+
+typedef enum {
+	LOC_OBJECT_NONE,
+	LOC_OBJECT_NAMESPACE,
+	LOC_OBJECT_SERVICE
+} loc_object_type_t;
+
+typedef enum {
+	LOC_SERVER_REGISTER = IPC_FIRST_USER_METHOD,
+	LOC_SERVER_UNREGISTER,
+	LOC_SERVICE_REGISTER,
+	LOC_SERVICE_UNREGISTER,
+	LOC_SERVICE_GET_ID,
+	LOC_NAMESPACE_GET_ID,
+	LOC_ID_PROBE,
+	LOC_NULL_CREATE,
+	LOC_NULL_DESTROY,
+	LOC_GET_NAMESPACE_COUNT,
+	LOC_GET_SERVICE_COUNT,
+	LOC_GET_NAMESPACES,
+	LOC_GET_SERVICES
+} loc_request_t;
+
+/** Ports provided by location service.
+ *
+ * Every process that connects to loc must ask one of following
+ * ports, otherwise connection will be refused.
+ *
+ */
+typedef enum {
+	/** Service supplier (server) port */
+	LOC_PORT_SUPPLIER = 1,
+	/** Service consumer (client) port */
+	LOC_PORT_CONSUMER,
+	/** Create new connection to instance of device that
+	    is specified by second argument of call. */
+	LOC_CONNECT_TO_SERVICE
+} loc_interface_t;
+
+typedef struct {
+	service_id_t id;
+	char name[LOC_NAME_MAXLEN + 1];
+} loc_sdesc_t;
+
+#endif
Index: uspace/lib/c/include/ipc/services.h
===================================================================
--- uspace/lib/c/include/ipc/services.h	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/lib/c/include/ipc/services.h	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -43,5 +43,5 @@
 	SERVICE_VIDEO,
 	SERVICE_VFS,
-	SERVICE_DEVMAP,
+	SERVICE_LOC,
 	SERVICE_DEVMAN,
 	SERVICE_IRC,
Index: uspace/lib/c/include/loc.h
===================================================================
--- uspace/lib/c/include/loc.h	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
+++ uspace/lib/c/include/loc.h	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2009 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_LOC_H_
+#define LIBC_LOC_H_
+
+#include <ipc/loc.h>
+#include <async.h>
+#include <bool.h>
+
+extern async_exch_t *loc_exchange_begin_blocking(loc_interface_t);
+extern async_exch_t *loc_exchange_begin(loc_interface_t);
+extern void loc_exchange_end(async_exch_t *);
+
+extern int loc_server_register(const char *, async_client_conn_t);
+extern int loc_service_register(const char *, service_id_t *);
+extern int loc_service_register_with_iface(const char *, service_id_t *,
+    sysarg_t);
+
+extern int loc_service_get_id(const char *, service_id_t *,
+    unsigned int);
+extern int loc_namespace_get_id(const char *, service_id_t *,
+    unsigned int);
+extern loc_object_type_t loc_id_probe(service_id_t);
+
+extern async_sess_t *loc_service_connect(exch_mgmt_t, service_id_t,
+    unsigned int);
+
+extern int loc_null_create(void);
+extern void loc_null_destroy(int);
+
+extern size_t loc_count_namespaces(void);
+extern size_t loc_count_services(service_id_t);
+
+extern size_t loc_get_namespaces(loc_sdesc_t **);
+extern size_t loc_get_services(service_id_t, loc_sdesc_t **);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/include/sys/stat.h
===================================================================
--- uspace/lib/c/include/sys/stat.h	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/lib/c/include/sys/stat.h	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -39,9 +39,9 @@
 #include <bool.h>
 #include <ipc/vfs.h>
-#include <ipc/devmap.h>
+#include <ipc/loc.h>
 
 struct stat {
 	fs_handle_t fs_handle;
-	devmap_handle_t devmap_handle;
+	service_id_t service_id;
 	fs_index_t index;
 	unsigned int lnkcnt;
@@ -49,5 +49,5 @@
 	bool is_directory;
 	aoff64_t size;
-	devmap_handle_t device;
+	service_id_t service;
 };
 
Index: uspace/lib/c/include/vfs/vfs.h
===================================================================
--- uspace/lib/c/include/vfs/vfs.h	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/lib/c/include/vfs/vfs.h	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -38,5 +38,5 @@
 #include <sys/types.h>
 #include <ipc/vfs.h>
-#include <ipc/devmap.h>
+#include <ipc/loc.h>
 #include <stdio.h>
 
@@ -49,5 +49,5 @@
 typedef struct {
 	fs_handle_t fs_handle;
-	devmap_handle_t devmap_handle;
+	service_id_t service_id;
 	fs_index_t index;
 } fdi_node_t;
Index: uspace/lib/ext2/libext2_filesystem.c
===================================================================
--- uspace/lib/ext2/libext2_filesystem.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/lib/ext2/libext2_filesystem.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -50,9 +50,9 @@
  * 
  * @param fs			Pointer to ext2_filesystem_t to initialize
- * @param devmap_handle	Device handle of the block device
- * 
- * @return 		EOK on success or negative error code on failure
- */
-int ext2_filesystem_init(ext2_filesystem_t *fs, devmap_handle_t devmap_handle)
+ * @param service_id	Service ID of the block device
+ * 
+ * @return 		EOK on success or negative error code on failure
+ */
+int ext2_filesystem_init(ext2_filesystem_t *fs, service_id_t service_id)
 {
 	int rc;
@@ -60,5 +60,5 @@
 	size_t block_size;
 	
-	fs->device = devmap_handle;
+	fs->device = service_id;
 	
 	rc = block_init(EXCHANGE_SERIALIZE, fs->device, 2048);
@@ -80,5 +80,5 @@
 	}
 	
-	rc = block_cache_init(devmap_handle, block_size, 0, CACHE_MODE_WT);
+	rc = block_cache_init(service_id, block_size, 0, CACHE_MODE_WT);
 	if (rc != EOK) {
 		block_fini(fs->device);
Index: uspace/lib/ext2/libext2_filesystem.h
===================================================================
--- uspace/lib/ext2/libext2_filesystem.h	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/lib/ext2/libext2_filesystem.h	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -43,5 +43,5 @@
 
 typedef struct ext2_filesystem {
-	devmap_handle_t		device;
+	service_id_t		device;
 	ext2_superblock_t *	superblock;
 } ext2_filesystem_t;
@@ -59,5 +59,5 @@
 #define EXT2_SUPPORTED_READ_ONLY_FEATURES 0
 
-extern int ext2_filesystem_init(ext2_filesystem_t *, devmap_handle_t);
+extern int ext2_filesystem_init(ext2_filesystem_t *, service_id_t);
 extern int ext2_filesystem_check_sanity(ext2_filesystem_t *);
 extern int ext2_filesystem_check_flags(ext2_filesystem_t *, bool *);
Index: uspace/lib/ext2/libext2_superblock.c
===================================================================
--- uspace/lib/ext2/libext2_superblock.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/lib/ext2/libext2_superblock.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -321,10 +321,10 @@
 /** Read a superblock directly from device (i.e. no libblock cache)
  * 
- * @param devmap_handle	Device handle of the block device.
+ * @param service_id	Service ID of the block device.
  * @param superblock	Pointer where to store pointer to new superblock
  * 
  * @return		EOK on success or negative error code on failure.
  */
-int ext2_superblock_read_direct(devmap_handle_t devmap_handle,
+int ext2_superblock_read_direct(service_id_t service_id,
     ext2_superblock_t **superblock)
 {
@@ -337,5 +337,5 @@
 	}
 	
-	rc = block_read_bytes_direct(devmap_handle, EXT2_SUPERBLOCK_OFFSET,
+	rc = block_read_bytes_direct(service_id, EXT2_SUPERBLOCK_OFFSET,
 	    EXT2_SUPERBLOCK_SIZE, data);
 	if (rc != EOK) {
Index: uspace/lib/ext2/libext2_superblock.h
===================================================================
--- uspace/lib/ext2/libext2_superblock.h	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/lib/ext2/libext2_superblock.h	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -110,5 +110,5 @@
 extern uint32_t	ext2_superblock_get_features_read_only(ext2_superblock_t *);
 
-extern int ext2_superblock_read_direct(devmap_handle_t, ext2_superblock_t **);
+extern int ext2_superblock_read_direct(service_id_t, ext2_superblock_t **);
 extern int ext2_superblock_check_sanity(ext2_superblock_t *);
 
Index: uspace/lib/fs/libfs.c
===================================================================
--- uspace/lib/fs/libfs.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/lib/fs/libfs.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -153,8 +153,8 @@
     ipc_call_t *request)
 {
-	devmap_handle_t mp_devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
+	service_id_t mp_service_id = (service_id_t) IPC_GET_ARG1(*request);
 	fs_index_t mp_fs_index = (fs_index_t) IPC_GET_ARG2(*request);
 	fs_handle_t mr_fs_handle = (fs_handle_t) IPC_GET_ARG3(*request);
-	devmap_handle_t mr_devmap_handle = (devmap_handle_t) IPC_GET_ARG4(*request);
+	service_id_t mr_service_id = (service_id_t) IPC_GET_ARG4(*request);
 	
 	async_sess_t *mountee_sess = async_clone_receive(EXCHANGE_PARALLEL);
@@ -165,5 +165,5 @@
 	
 	fs_node_t *fn;
-	int res = ops->node_get(&fn, mp_devmap_handle, mp_fs_index);
+	int res = ops->node_get(&fn, mp_service_id, mp_fs_index);
 	if ((res != EOK) || (!fn)) {
 		async_hangup(mountee_sess);
@@ -195,5 +195,5 @@
 	ipc_call_t answer;
 	int rc = async_data_write_forward_1_1(exch, VFS_OUT_MOUNTED,
-	    mr_devmap_handle, &answer);
+	    mr_service_id, &answer);
 	async_exchange_end(exch);
 	
@@ -201,5 +201,5 @@
 		fn->mp_data.mp_active = true;
 		fn->mp_data.fs_handle = mr_fs_handle;
-		fn->mp_data.devmap_handle = mr_devmap_handle;
+		fn->mp_data.service_id = mr_service_id;
 		fn->mp_data.sess = mountee_sess;
 	}
@@ -214,10 +214,10 @@
 void libfs_unmount(libfs_ops_t *ops, ipc_callid_t rid, ipc_call_t *request)
 {
-	devmap_handle_t mp_devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
+	service_id_t mp_service_id = (service_id_t) IPC_GET_ARG1(*request);
 	fs_index_t mp_fs_index = (fs_index_t) IPC_GET_ARG2(*request);
 	fs_node_t *fn;
 	int res;
 
-	res = ops->node_get(&fn, mp_devmap_handle, mp_fs_index);
+	res = ops->node_get(&fn, mp_service_id, mp_fs_index);
 	if ((res != EOK) || (!fn)) {
 		async_answer_0(rid, combine_rc(res, ENOENT));
@@ -238,5 +238,5 @@
 	 */
 	async_exch_t *exch = async_exchange_begin(fn->mp_data.sess);
-	res = async_req_1_0(exch, VFS_OUT_UNMOUNTED, fn->mp_data.devmap_handle);
+	res = async_req_1_0(exch, VFS_OUT_UNMOUNTED, fn->mp_data.service_id);
 	async_exchange_end(exch);
 
@@ -248,5 +248,5 @@
 		fn->mp_data.mp_active = false;
 		fn->mp_data.fs_handle = 0;
-		fn->mp_data.devmap_handle = 0;
+		fn->mp_data.service_id = 0;
 		fn->mp_data.sess = NULL;
 		
@@ -278,5 +278,5 @@
 	unsigned int last = IPC_GET_ARG2(*request);
 	unsigned int next = first;
-	devmap_handle_t devmap_handle = IPC_GET_ARG3(*request);
+	service_id_t service_id = IPC_GET_ARG3(*request);
 	int lflag = IPC_GET_ARG4(*request);
 	fs_index_t index = IPC_GET_ARG5(*request);
@@ -292,5 +292,5 @@
 	fs_node_t *tmp = NULL;
 	
-	rc = ops->root_get(&cur, devmap_handle);
+	rc = ops->root_get(&cur, service_id);
 	on_error(rc, goto out_with_answer);
 	
@@ -298,5 +298,5 @@
 		async_exch_t *exch = async_exchange_begin(cur->mp_data.sess);
 		async_forward_slow(rid, exch, VFS_OUT_LOOKUP, next, last,
-		    cur->mp_data.devmap_handle, lflag, index, IPC_FF_ROUTE_FROM_ME);
+		    cur->mp_data.service_id, lflag, index, IPC_FF_ROUTE_FROM_ME);
 		async_exchange_end(exch);
 		
@@ -358,5 +358,5 @@
 			async_exch_t *exch = async_exchange_begin(tmp->mp_data.sess);
 			async_forward_slow(rid, exch, VFS_OUT_LOOKUP, next, last,
-			    tmp->mp_data.devmap_handle, lflag, index,
+			    tmp->mp_data.service_id, lflag, index,
 			    IPC_FF_ROUTE_FROM_ME);
 			async_exchange_end(exch);
@@ -387,8 +387,8 @@
 				fs_node_t *fn;
 				if (lflag & L_CREATE)
-					rc = ops->create(&fn, devmap_handle,
+					rc = ops->create(&fn, service_id,
 					    lflag);
 				else
-					rc = ops->node_get(&fn, devmap_handle,
+					rc = ops->node_get(&fn, service_id,
 					    index);
 				on_error(rc, goto out_with_answer);
@@ -405,5 +405,5 @@
 						aoff64_t size = ops->size_get(fn);
 						async_answer_5(rid, fs_handle,
-						    devmap_handle,
+						    service_id,
 						    ops->index_get(fn),
 						    LOWER32(size),
@@ -473,7 +473,7 @@
 			fs_node_t *fn;
 			if (lflag & L_CREATE)
-				rc = ops->create(&fn, devmap_handle, lflag);
+				rc = ops->create(&fn, service_id, lflag);
 			else
-				rc = ops->node_get(&fn, devmap_handle, index);
+				rc = ops->node_get(&fn, service_id, index);
 			on_error(rc, goto out_with_answer);
 			
@@ -489,5 +489,5 @@
 					aoff64_t size = ops->size_get(fn);
 					async_answer_5(rid, fs_handle,
-					    devmap_handle,
+					    service_id,
 					    ops->index_get(fn),
 					    LOWER32(size),
@@ -515,5 +515,5 @@
 		if (rc == EOK) {
 			aoff64_t size = ops->size_get(cur);
-			async_answer_5(rid, fs_handle, devmap_handle,
+			async_answer_5(rid, fs_handle, service_id,
 			    ops->index_get(cur), LOWER32(size), UPPER32(size),
 			    old_lnkcnt);
@@ -553,5 +553,5 @@
 		if (rc == EOK) {
 			aoff64_t size = ops->size_get(cur);
-			async_answer_5(rid, fs_handle, devmap_handle,
+			async_answer_5(rid, fs_handle, service_id,
 			    ops->index_get(cur), LOWER32(size), UPPER32(size),
 			    ops->lnkcnt_get(cur));
@@ -577,9 +577,9 @@
     ipc_call_t *request)
 {
-	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
+	service_id_t service_id = (service_id_t) IPC_GET_ARG1(*request);
 	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
 	
 	fs_node_t *fn;
-	int rc = ops->node_get(&fn, devmap_handle, index);
+	int rc = ops->node_get(&fn, service_id, index);
 	on_error(rc, answer_and_return(rid, rc));
 	
@@ -598,5 +598,5 @@
 	
 	stat.fs_handle = fs_handle;
-	stat.devmap_handle = devmap_handle;
+	stat.service_id = service_id;
 	stat.index = index;
 	stat.lnkcnt = ops->lnkcnt_get(fn);
@@ -604,5 +604,5 @@
 	stat.is_directory = ops->is_directory(fn);
 	stat.size = ops->size_get(fn);
-	stat.device = ops->device_get(fn);
+	stat.service = ops->device_get(fn);
 	
 	ops->node_put(fn);
@@ -623,9 +623,9 @@
     ipc_call_t *request)
 {
-	devmap_handle_t devmap_handle = IPC_GET_ARG1(*request);
+	service_id_t service_id = IPC_GET_ARG1(*request);
 	fs_index_t index = IPC_GET_ARG2(*request);
 	
 	fs_node_t *fn;
-	int rc = ops->node_get(&fn, devmap_handle, index);
+	int rc = ops->node_get(&fn, service_id, index);
 	on_error(rc, answer_and_return(rid, rc));
 	
Index: uspace/lib/fs/libfs.h
===================================================================
--- uspace/lib/fs/libfs.h	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/lib/fs/libfs.h	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -40,5 +40,5 @@
 #include <stdint.h>
 #include <async.h>
-#include <devmap.h>
+#include <loc.h>
 
 typedef struct {
@@ -46,5 +46,5 @@
 	async_sess_t *sess;
 	fs_handle_t fs_handle;
-	devmap_handle_t devmap_handle;
+	service_id_t service_id;
 } mp_data_t;
 
@@ -60,10 +60,10 @@
 	 * argument holds the output argument.
 	 */
-	int (* root_get)(fs_node_t **, devmap_handle_t);
+	int (* root_get)(fs_node_t **, service_id_t);
 	int (* match)(fs_node_t **, fs_node_t *, const char *);
-	int (* node_get)(fs_node_t **, devmap_handle_t, fs_index_t);
+	int (* node_get)(fs_node_t **, service_id_t, fs_index_t);
 	int (* node_open)(fs_node_t *);
 	int (* node_put)(fs_node_t *);
-	int (* create)(fs_node_t **, devmap_handle_t, int);
+	int (* create)(fs_node_t **, service_id_t, int);
 	int (* destroy)(fs_node_t *);
 	int (* link)(fs_node_t *, fs_node_t *, const char *);
@@ -80,5 +80,5 @@
 	bool (* is_directory)(fs_node_t *);
 	bool (* is_file)(fs_node_t *);
-	devmap_handle_t (* device_get)(fs_node_t *);
+	service_id_t (* device_get)(fs_node_t *);
 } libfs_ops_t;
 
Index: uspace/srv/bd/ata_bd/ata_bd.c
===================================================================
--- uspace/srv/bd/ata_bd/ata_bd.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/bd/ata_bd/ata_bd.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -57,5 +57,5 @@
 #include <stdint.h>
 #include <str.h>
-#include <devmap.h>
+#include <loc.h>
 #include <sys/types.h>
 #include <inttypes.h>
@@ -179,5 +179,5 @@
 		
 		snprintf(name, 16, "%s/ata%udisk%d", NAMESPACE, ctl_num, i);
-		rc = devmap_device_register(name, &disk[i].devmap_handle);
+		rc = loc_service_register(name, &disk[i].service_id);
 		if (rc != EOK) {
 			printf(NAME ": Unable to register device %s.\n", name);
@@ -247,5 +247,5 @@
 	int rc;
 
-	rc = devmap_driver_register(NAME, ata_bd_connection);
+	rc = loc_server_register(NAME, ata_bd_connection);
 	if (rc < 0) {
 		printf(NAME ": Unable to register driver.\n");
@@ -280,5 +280,5 @@
 	ipc_call_t call;
 	sysarg_t method;
-	devmap_handle_t dh;
+	service_id_t dsid;
 	unsigned int flags;
 	int retval;
@@ -287,11 +287,11 @@
 	int disk_id, i;
 
-	/* Get the device handle. */
-	dh = IPC_GET_ARG1(*icall);
+	/* Get the device service ID. */
+	dsid = IPC_GET_ARG1(*icall);
 
 	/* Determine which disk device is the client connecting to. */
 	disk_id = -1;
 	for (i = 0; i < MAX_DISKS; i++)
-		if (disk[i].devmap_handle == dh)
+		if (disk[i].service_id == dsid)
 			disk_id = i;
 
Index: uspace/srv/bd/ata_bd/ata_bd.h
===================================================================
--- uspace/srv/bd/ata_bd/ata_bd.h	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/bd/ata_bd/ata_bd.h	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -116,5 +116,5 @@
 
 	fibril_mutex_t lock;
-	devmap_handle_t devmap_handle;
+	service_id_t service_id;
 } disk_t;
 
Index: uspace/srv/bd/file_bd/file_bd.c
===================================================================
--- uspace/srv/bd/file_bd/file_bd.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/bd/file_bd/file_bd.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -45,5 +45,5 @@
 #include <as.h>
 #include <fibril_synch.h>
-#include <devmap.h>
+#include <loc.h>
 #include <sys/types.h>
 #include <sys/typefmt.h>
@@ -61,5 +61,5 @@
 static FILE *img;
 
-static devmap_handle_t devmap_handle;
+static service_id_t service_id;
 static fibril_mutex_t dev_lock;
 
@@ -117,5 +117,5 @@
 		return -1;
 
-	rc = devmap_device_register(device_name, &devmap_handle);
+	rc = loc_service_register(device_name, &service_id);
 	if (rc != EOK) {
 		printf(NAME ": Unable to register device '%s'.\n",
@@ -142,5 +142,5 @@
 	long img_size;
 
-	rc = devmap_driver_register(NAME, file_bd_connection);
+	rc = loc_server_register(NAME, file_bd_connection);
 	if (rc < 0) {
 		printf(NAME ": Unable to register driver.\n");
Index: uspace/srv/bd/gxe_bd/gxe_bd.c
===================================================================
--- uspace/srv/bd/gxe_bd/gxe_bd.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/bd/gxe_bd/gxe_bd.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -43,5 +43,5 @@
 #include <as.h>
 #include <fibril_synch.h>
-#include <devmap.h>
+#include <loc.h>
 #include <sys/types.h>
 #include <errno.h>
@@ -92,5 +92,5 @@
 static gxe_bd_t *dev;
 
-static devmap_handle_t devmap_handle[MAX_DISKS];
+static service_id_t service_id[MAX_DISKS];
 
 static fibril_mutex_t dev_lock[MAX_DISKS];
@@ -126,5 +126,5 @@
 	char name[16];
 
-	rc = devmap_driver_register(NAME, gxe_bd_connection);
+	rc = loc_server_register(NAME, gxe_bd_connection);
 	if (rc < 0) {
 		printf(NAME ": Unable to register driver.\n");
@@ -142,5 +142,5 @@
 	for (i = 0; i < MAX_DISKS; i++) {
 		snprintf(name, 16, "%s/disk%d", NAMESPACE, i);
-		rc = devmap_device_register(name, &devmap_handle[i]);
+		rc = loc_service_register(name, &service_id[i]);
 		if (rc != EOK) {
 			printf(NAME ": Unable to register device %s.\n", name);
@@ -159,5 +159,5 @@
 	ipc_call_t call;
 	sysarg_t method;
-	devmap_handle_t dh;
+	service_id_t dsid;
 	unsigned int flags;
 	int retval;
@@ -167,10 +167,10 @@
 
 	/* Get the device handle. */
-	dh = IPC_GET_ARG1(*icall);
+	dsid = IPC_GET_ARG1(*icall);
 
 	/* Determine which disk device is the client connecting to. */
 	disk_id = -1;
 	for (i = 0; i < MAX_DISKS; i++)
-		if (devmap_handle[i] == dh)
+		if (service_id[i] == dsid)
 			disk_id = i;
 
Index: uspace/srv/bd/part/guid_part/guid_part.c
===================================================================
--- uspace/srv/bd/part/guid_part/guid_part.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/bd/part/guid_part/guid_part.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -51,10 +51,10 @@
 #include <as.h>
 #include <fibril_synch.h>
-#include <devmap.h>
+#include <loc.h>
 #include <sys/types.h>
 #include <sys/typefmt.h>
 #include <inttypes.h>
 #include <libblock.h>
-#include <devmap.h>
+#include <loc.h>
 #include <errno.h>
 #include <bool.h>
@@ -81,6 +81,6 @@
 	/** Number of blocks */
 	aoff64_t length;
-	/** Device representing the partition (outbound device) */
-	devmap_handle_t dev;
+	/** Service representing the partition (outbound device) */
+	service_id_t dsid;
 	/** Points to next partition structure. */
 	struct part *next;
@@ -90,5 +90,5 @@
 
 /** Partitioned device (inbound device) */
-static devmap_handle_t indev_handle;
+static service_id_t indev_sid;
 
 /** List of partitions. This structure is an empty head. */
@@ -129,9 +129,9 @@
 	int i;
 	char *name;
-	devmap_handle_t dev;
+	service_id_t dsid;
 	uint64_t size_mb;
 	part_t *part;
 
-	rc = devmap_device_get_handle(dev_name, &indev_handle, 0);
+	rc = loc_service_get_id(dev_name, &indev_sid, 0);
 	if (rc != EOK) {
 		printf(NAME ": could not resolve device `%s'.\n", dev_name);
@@ -139,5 +139,5 @@
 	}
 
-	rc = block_init(EXCHANGE_SERIALIZE, indev_handle, 2048);
+	rc = block_init(EXCHANGE_SERIALIZE, indev_sid, 2048);
 	if (rc != EOK)  {
 		printf(NAME ": could not init libblock.\n");
@@ -147,5 +147,5 @@
 	/* Determine and verify block size. */
 
-	rc = block_get_bsize(indev_handle, &block_size);
+	rc = block_get_bsize(indev_sid, &block_size);
 	if (rc != EOK) {
 		printf(NAME ": error getting block size.\n");
@@ -163,8 +163,8 @@
 		return rc;
 
-	/* Register the driver with device mapper. */
-	rc = devmap_driver_register(NAME, gpt_connection);
+	/* Register server with location service. */
+	rc = loc_server_register(NAME, gpt_connection);
 	if (rc != EOK) {
-		printf(NAME ": Unable to register driver.\n");
+		printf(NAME ": Unable to register server.\n");
 		return rc;
 	}
@@ -188,7 +188,7 @@
 			return ENOMEM;
 
-		rc = devmap_device_register(name, &dev);
+		rc = loc_service_register(name, &dsid);
 		if (rc != EOK) {
-			printf(NAME ": Unable to register device %s.\n", name);
+			printf(NAME ": Unable to register service %s.\n", name);
 			return rc;
 		}
@@ -199,5 +199,5 @@
 		    "%" PRIuOFF64 " MB.\n", name, part->length, size_mb);
 
-		part->dev = dev;
+		part->dsid = dsid;
 		free(name);
 
@@ -228,5 +228,5 @@
 	}
 
-	rc = block_read_direct(indev_handle, GPT_HDR_BA, 1, gpt_hdr);
+	rc = block_read_direct(indev_sid, GPT_HDR_BA, 1, gpt_hdr);
 	if (rc != EOK) {
 		printf(NAME ": Failed reading GPT header block.\n");
@@ -256,5 +256,5 @@
 	}
 
-	rc = block_read_direct(indev_handle, ba, bcnt, etable);
+	rc = block_read_direct(indev_sid, ba, bcnt, etable);
 	if (rc != EOK) {
 		printf(NAME ": Failed reading GPT entries.\n");
@@ -303,5 +303,5 @@
 	}
 
-	part->dev = 0;
+	part->dsid = 0;
 	part->next = NULL;
 }
@@ -314,5 +314,5 @@
 	ipc_call_t call;
 	sysarg_t method;
-	devmap_handle_t dh;
+	service_id_t dh;
 	unsigned int flags;
 	int retval;
@@ -330,5 +330,5 @@
 	 */
 	part = plist_head.next;
-	while (part != NULL && part->dev != dh)
+	while (part != NULL && part->dsid != dh)
 		part = part->next;
 
@@ -410,5 +410,5 @@
 		return ELIMIT;
 
-	return block_read_direct(indev_handle, gba, cnt, buf);
+	return block_read_direct(indev_sid, gba, cnt, buf);
 }
 
@@ -421,5 +421,5 @@
 		return ELIMIT;
 
-	return block_write_direct(indev_handle, gba, cnt, buf);
+	return block_write_direct(indev_sid, gba, cnt, buf);
 }
 
Index: uspace/srv/bd/part/mbr_part/mbr_part.c
===================================================================
--- uspace/srv/bd/part/mbr_part/mbr_part.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/bd/part/mbr_part/mbr_part.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -61,10 +61,10 @@
 #include <as.h>
 #include <fibril_synch.h>
-#include <devmap.h>
+#include <loc.h>
 #include <sys/types.h>
 #include <sys/typefmt.h>
 #include <inttypes.h>
 #include <libblock.h>
-#include <devmap.h>
+#include <loc.h>
 #include <errno.h>
 #include <bool.h>
@@ -100,5 +100,5 @@
 	aoff64_t length;
 	/** Device representing the partition (outbound device) */
-	devmap_handle_t dev;
+	service_id_t dsid;
 	/** Points to next partition structure. */
 	struct part *next;
@@ -141,5 +141,5 @@
 
 /** Partitioned device (inbound device) */
-static devmap_handle_t indev_handle;
+static service_id_t indef_sid;
 
 /** List of partitions. This structure is an empty head. */
@@ -180,9 +180,9 @@
 	int i;
 	char *name;
-	devmap_handle_t dev;
+	service_id_t dsid;
 	uint64_t size_mb;
 	part_t *part;
 
-	rc = devmap_device_get_handle(dev_name, &indev_handle, 0);
+	rc = loc_service_get_id(dev_name, &indef_sid, 0);
 	if (rc != EOK) {
 		printf(NAME ": could not resolve device `%s'.\n", dev_name);
@@ -190,5 +190,5 @@
 	}
 
-	rc = block_init(EXCHANGE_SERIALIZE, indev_handle, 2048);
+	rc = block_init(EXCHANGE_SERIALIZE, indef_sid, 2048);
 	if (rc != EOK)  {
 		printf(NAME ": could not init libblock.\n");
@@ -198,5 +198,5 @@
 	/* Determine and verify block size. */
 
-	rc = block_get_bsize(indev_handle, &block_size);
+	rc = block_get_bsize(indef_sid, &block_size);
 	if (rc != EOK) {
 		printf(NAME ": error getting block size.\n");
@@ -214,8 +214,8 @@
 		return rc;
 
-	/* Register the driver with device mapper. */
-	rc = devmap_driver_register(NAME, mbr_connection);
+	/* Register server with location service. */
+	rc = loc_server_register(NAME, mbr_connection);
 	if (rc != EOK) {
-		printf(NAME ": Unable to register driver.\n");
+		printf(NAME ": Unable to register server.\n");
 		return rc;
 	}
@@ -239,7 +239,7 @@
 			return ENOMEM;
 
-		rc = devmap_device_register(name, &dev);
+		rc = loc_service_register(name, &dsid);
 		if (rc != EOK) {
-			printf(NAME ": Unable to register device %s.\n", name);
+			printf(NAME ": Unable to register service %s.\n", name);
 			return rc;
 		}
@@ -250,5 +250,5 @@
 		    "%" PRIu64 " MB.\n", name, part->length, size_mb);
 
-		part->dev = dev;
+		part->dsid = dsid;
 		free(name);
 
@@ -281,5 +281,5 @@
 	 */
 
-	rc = block_read_direct(indev_handle, 0, 1, brb);
+	rc = block_read_direct(indef_sid, 0, 1, brb);
 	if (rc != EOK) {
 		printf(NAME ": Failed reading MBR block.\n");
@@ -332,5 +332,5 @@
 		 */
 		ba = cp.start_addr;
-		rc = block_read_direct(indev_handle, ba, 1, brb);
+		rc = block_read_direct(indef_sid, ba, 1, brb);
 		if (rc != EOK) {
 			printf(NAME ": Failed reading EBR block at %"
@@ -381,5 +381,5 @@
 	part->present = (pte->ptype != PT_UNUSED) ? true : false;
 
-	part->dev = 0;
+	part->dsid = 0;
 	part->next = NULL;
 }
@@ -392,5 +392,5 @@
 	ipc_call_t call;
 	sysarg_t method;
-	devmap_handle_t dh;
+	service_id_t dh;
 	unsigned int flags;
 	int retval;
@@ -408,5 +408,5 @@
 	 */
 	part = plist_head.next;
-	while (part != NULL && part->dev != dh)
+	while (part != NULL && part->dsid != dh)
 		part = part->next;
 
@@ -488,5 +488,5 @@
 		return ELIMIT;
 
-	return block_read_direct(indev_handle, gba, cnt, buf);
+	return block_read_direct(indef_sid, gba, cnt, buf);
 }
 
@@ -499,5 +499,5 @@
 		return ELIMIT;
 
-	return block_write_direct(indev_handle, gba, cnt, buf);
+	return block_write_direct(indef_sid, gba, cnt, buf);
 }
 
Index: uspace/srv/bd/rd/rd.c
===================================================================
--- uspace/srv/bd/rd/rd.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/bd/rd/rd.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -52,5 +52,5 @@
 #include <fibril_synch.h>
 #include <stdio.h>
-#include <devmap.h>
+#include <loc.h>
 #include <ipc/bd.h>
 #include <macros.h>
@@ -235,5 +235,5 @@
 	    (void *) rd_ph_addr, rd_size);
 	
-	int rc = devmap_driver_register(NAME, rd_connection);
+	int rc = loc_server_register(NAME, rd_connection);
 	if (rc < 0) {
 		printf("%s: Unable to register driver (%d)\n", NAME, rc);
@@ -241,7 +241,7 @@
 	}
 	
-	devmap_handle_t devmap_handle;
-	if (devmap_device_register("bd/initrd", &devmap_handle) != EOK) {
-		printf("%s: Unable to register device\n", NAME);
+	service_id_t service_id;
+	if (loc_service_register("bd/initrd", &service_id) != EOK) {
+		printf("%s: Unable to register device service\n", NAME);
 		return false;
 	}
Index: uspace/srv/devman/devman.c
===================================================================
--- uspace/srv/devman/devman.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/devman/devman.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -37,5 +37,5 @@
 #include <ipc/driver.h>
 #include <ipc/devman.h>
-#include <devmap.h>
+#include <loc.h>
 #include <str_error.h>
 #include <stdio.h>
@@ -66,19 +66,19 @@
 }
 
-static int devmap_functions_compare(unsigned long key[], hash_count_t keys,
+static int loc_functions_compare(unsigned long key[], hash_count_t keys,
     link_t *item)
 {
-	fun_node_t *fun = hash_table_get_instance(item, fun_node_t, devmap_fun);
-	return (fun->devmap_handle == (devmap_handle_t) key[0]);
-}
-
-static int devmap_devices_class_compare(unsigned long key[], hash_count_t keys,
+	fun_node_t *fun = hash_table_get_instance(item, fun_node_t, loc_fun);
+	return (fun->service_id == (service_id_t) key[0]);
+}
+
+static int loc_devices_class_compare(unsigned long key[], hash_count_t keys,
     link_t *item)
 {
 	dev_class_info_t *class_info
-	    = hash_table_get_instance(item, dev_class_info_t, devmap_link);
+	    = hash_table_get_instance(item, dev_class_info_t, loc_link);
 	assert(class_info != NULL);
 
-	return (class_info->devmap_handle == (devmap_handle_t) key[0]);
+	return (class_info->service_id == (service_id_t) key[0]);
 }
 
@@ -99,13 +99,13 @@
 };
 
-static hash_table_operations_t devmap_devices_ops = {
+static hash_table_operations_t loc_devices_ops = {
 	.hash = devices_hash,
-	.compare = devmap_functions_compare,
+	.compare = loc_functions_compare,
 	.remove_callback = devices_remove_callback
 };
 
-static hash_table_operations_t devmap_devices_class_ops = {
+static hash_table_operations_t loc_devices_class_ops = {
 	.hash = devices_hash,
-	.compare = devmap_devices_class_compare,
+	.compare = loc_devices_class_compare,
 	.remove_callback = devices_remove_callback
 };
@@ -700,30 +700,30 @@
 }
 
-/** Create devmap path and name for the function. */
-void devmap_register_tree_function(fun_node_t *fun, dev_tree_t *tree)
-{
-	char *devmap_pathname = NULL;
-	char *devmap_name = NULL;
-	
-	asprintf(&devmap_name, "%s", fun->pathname);
-	if (devmap_name == NULL)
+/** Create loc path and name for the function. */
+void loc_register_tree_function(fun_node_t *fun, dev_tree_t *tree)
+{
+	char *loc_pathname = NULL;
+	char *loc_name = NULL;
+	
+	asprintf(&loc_name, "%s", fun->pathname);
+	if (loc_name == NULL)
 		return;
 	
-	replace_char(devmap_name, '/', DEVMAP_SEPARATOR);
-	
-	asprintf(&devmap_pathname, "%s/%s", DEVMAP_DEVICE_NAMESPACE,
-	    devmap_name);
-	if (devmap_pathname == NULL) {
-		free(devmap_name);
+	replace_char(loc_name, '/', LOC_SEPARATOR);
+	
+	asprintf(&loc_pathname, "%s/%s", LOC_DEVICE_NAMESPACE,
+	    loc_name);
+	if (loc_pathname == NULL) {
+		free(loc_name);
 		return;
 	}
 	
-	devmap_device_register_with_iface(devmap_pathname,
-	    &fun->devmap_handle, DEVMAN_CONNECT_FROM_DEVMAP);
-	
-	tree_add_devmap_function(tree, fun);
-	
-	free(devmap_name);
-	free(devmap_pathname);
+	loc_service_register_with_iface(loc_pathname,
+	    &fun->service_id, DEVMAN_CONNECT_FROM_LOC);
+	
+	tree_add_loc_function(tree, fun);
+	
+	free(loc_name);
+	free(loc_pathname);
 }
 
@@ -855,6 +855,6 @@
 	hash_table_create(&tree->devman_functions, DEVICE_BUCKETS, 1,
 	    &devman_functions_ops);
-	hash_table_create(&tree->devmap_functions, DEVICE_BUCKETS, 1,
-	    &devmap_devices_ops);
+	hash_table_create(&tree->loc_functions, DEVICE_BUCKETS, 1,
+	    &loc_devices_ops);
 	
 	fibril_rwlock_initialize(&tree->rwlock);
@@ -951,5 +951,5 @@
 		list_initialize(&res->classes);
 		link_initialize(&res->devman_fun);
-		link_initialize(&res->devmap_fun);
+		link_initialize(&res->loc_fun);
 	}
 	
@@ -1267,5 +1267,5 @@
 		memset(info, 0, sizeof(dev_class_info_t));
 		link_initialize(&info->dev_classes);
-		link_initialize(&info->devmap_link);
+		link_initialize(&info->loc_link);
 		link_initialize(&info->link);
 	}
@@ -1413,21 +1413,21 @@
 	list_initialize(&class_list->classes);
 	fibril_rwlock_initialize(&class_list->rwlock);
-	hash_table_create(&class_list->devmap_functions, DEVICE_BUCKETS, 1,
-	    &devmap_devices_class_ops);
-}
-
-
-/* Devmap devices */
-
-fun_node_t *find_devmap_tree_function(dev_tree_t *tree, devmap_handle_t devmap_handle)
+	hash_table_create(&class_list->loc_functions, DEVICE_BUCKETS, 1,
+	    &loc_devices_class_ops);
+}
+
+
+/* loc devices */
+
+fun_node_t *find_loc_tree_function(dev_tree_t *tree, service_id_t service_id)
 {
 	fun_node_t *fun = NULL;
 	link_t *link;
-	unsigned long key = (unsigned long) devmap_handle;
+	unsigned long key = (unsigned long) service_id;
 	
 	fibril_rwlock_read_lock(&tree->rwlock);
-	link = hash_table_find(&tree->devmap_functions, &key);
+	link = hash_table_find(&tree->loc_functions, &key);
 	if (link != NULL)
-		fun = hash_table_get_instance(link, fun_node_t, devmap_fun);
+		fun = hash_table_get_instance(link, fun_node_t, loc_fun);
 	fibril_rwlock_read_unlock(&tree->rwlock);
 	
@@ -1435,17 +1435,17 @@
 }
 
-fun_node_t *find_devmap_class_function(class_list_t *classes,
-    devmap_handle_t devmap_handle)
+fun_node_t *find_loc_class_function(class_list_t *classes,
+    service_id_t service_id)
 {
 	fun_node_t *fun = NULL;
 	dev_class_info_t *cli;
 	link_t *link;
-	unsigned long key = (unsigned long)devmap_handle;
+	unsigned long key = (unsigned long)service_id;
 	
 	fibril_rwlock_read_lock(&classes->rwlock);
-	link = hash_table_find(&classes->devmap_functions, &key);
+	link = hash_table_find(&classes->loc_functions, &key);
 	if (link != NULL) {
 		cli = hash_table_get_instance(link, dev_class_info_t,
-		    devmap_link);
+		    loc_link);
 		fun = cli->fun;
 	}
@@ -1455,20 +1455,20 @@
 }
 
-void class_add_devmap_function(class_list_t *class_list, dev_class_info_t *cli)
-{
-	unsigned long key = (unsigned long) cli->devmap_handle;
+void class_add_loc_function(class_list_t *class_list, dev_class_info_t *cli)
+{
+	unsigned long key = (unsigned long) cli->service_id;
 	
 	fibril_rwlock_write_lock(&class_list->rwlock);
-	hash_table_insert(&class_list->devmap_functions, &key, &cli->devmap_link);
+	hash_table_insert(&class_list->loc_functions, &key, &cli->loc_link);
 	fibril_rwlock_write_unlock(&class_list->rwlock);
 
-	assert(find_devmap_class_function(class_list, cli->devmap_handle) != NULL);
-}
-
-void tree_add_devmap_function(dev_tree_t *tree, fun_node_t *fun)
-{
-	unsigned long key = (unsigned long) fun->devmap_handle;
+	assert(find_loc_class_function(class_list, cli->service_id) != NULL);
+}
+
+void tree_add_loc_function(dev_tree_t *tree, fun_node_t *fun)
+{
+	unsigned long key = (unsigned long) fun->service_id;
 	fibril_rwlock_write_lock(&tree->rwlock);
-	hash_table_insert(&tree->devmap_functions, &key, &fun->devmap_fun);
+	hash_table_insert(&tree->loc_functions, &key, &fun->loc_fun);
 	fibril_rwlock_write_unlock(&tree->rwlock);
 }
Index: uspace/srv/devman/devman.h
===================================================================
--- uspace/srv/devman/devman.h	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/devman/devman.h	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -41,5 +41,5 @@
 #include <adt/hash_table.h>
 #include <ipc/devman.h>
-#include <ipc/devmap.h>
+#include <ipc/loc.h>
 #include <fibril_synch.h>
 #include <atomic.h>
@@ -53,7 +53,7 @@
 #define DEVICE_BUCKETS 256
 
-#define DEVMAP_CLASS_NAMESPACE "class"
-#define DEVMAP_DEVICE_NAMESPACE "devices"
-#define DEVMAP_SEPARATOR '\\'
+#define LOC_CLASS_NAMESPACE "class"
+#define LOC_DEVICE_NAMESPACE "devices"
+#define LOC_SEPARATOR '\\'
 
 struct dev_node;
@@ -172,6 +172,6 @@
 	/** List of device classes to which this device function belongs. */
 	list_t classes;
-	/** Devmap handle if the device function is registered by devmap. */
-	devmap_handle_t devmap_handle;
+	/** Service ID if the device function is registered with loc. */
+	service_id_t service_id;
 	
 	/**
@@ -181,7 +181,7 @@
 	
 	/**
-	 * Used by the hash table of functions indexed by devmap device handles.
-	 */
-	link_t devmap_fun;
+	 * Used by the hash table of functions indexed by service IDs.
+	 */
+	link_t loc_fun;
 };
 
@@ -208,8 +208,8 @@
 	
 	/**
-	 * Hash table of devices registered by devmapper, indexed by devmap
-	 * handles.
-	 */
-	hash_table_t devmap_functions;
+	 * Hash table of services registered with location service, indexed by
+	 * service IDs.
+	 */
+	hash_table_t loc_functions;
 } dev_tree_t;
 
@@ -267,12 +267,12 @@
 	/** The name of the device function within the class. */
 	char *dev_name;
-	/** The handle of the device by device mapper in the class namespace. */
-	devmap_handle_t devmap_handle;
-	
-	/**
-	 * Link in the hash table of devices registered by the devmapper using
+	/** Service ID in the class namespace. */
+	service_id_t service_id;
+	
+	/**
+	 * Link to hash table of services registered with location service using
 	 * their class names.
 	 */
-	link_t devmap_link;
+	link_t loc_link;
 } dev_class_info_t;
 
@@ -283,8 +283,8 @@
 	
 	/**
-	 * Hash table of devices registered by devmapper using their class name,
-	 * indexed by devmap handles.
-	 */
-	hash_table_t devmap_functions;
+	 * Hash table of services registered with location service using their
+	 * class name, indexed by service IDs.
+	 */
+	hash_table_t loc_functions;
 	
 	/** Fibril mutex for list of classes. */
@@ -364,13 +364,13 @@
 extern void add_dev_class_no_lock(class_list_t *, dev_class_t *);
 
-/* Devmap devices */
-
-extern void devmap_register_tree_function(fun_node_t *, dev_tree_t *);
-
-extern fun_node_t *find_devmap_tree_function(dev_tree_t *, devmap_handle_t);
-extern fun_node_t *find_devmap_class_function(class_list_t *, devmap_handle_t);
-
-extern void class_add_devmap_function(class_list_t *, dev_class_info_t *);
-extern void tree_add_devmap_function(dev_tree_t *, fun_node_t *);
+/* Loc services */
+
+extern void loc_register_tree_function(fun_node_t *, dev_tree_t *);
+
+extern fun_node_t *find_loc_tree_function(dev_tree_t *, service_id_t);
+extern fun_node_t *find_loc_class_function(class_list_t *, service_id_t);
+
+extern void class_add_loc_function(class_list_t *, dev_class_info_t *);
+extern void tree_add_loc_function(dev_tree_t *, fun_node_t *);
 
 #endif
Index: uspace/srv/devman/main.c
===================================================================
--- uspace/srv/devman/main.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/devman/main.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -56,5 +56,5 @@
 #include <ipc/driver.h>
 #include <thread.h>
-#include <devmap.h>
+#include <loc.h>
 
 #include "devman.h"
@@ -326,5 +326,5 @@
 		}
 	} else {
-		devmap_register_tree_function(fun, tree);
+		loc_register_tree_function(fun, tree);
 	}
 	
@@ -333,28 +333,28 @@
 }
 
-static void devmap_register_class_dev(dev_class_info_t *cli)
-{
-	/* Create devmap path and name for the device. */
-	char *devmap_pathname = NULL;
-
-	asprintf(&devmap_pathname, "%s/%s%c%s", DEVMAP_CLASS_NAMESPACE,
-	    cli->dev_class->name, DEVMAP_SEPARATOR, cli->dev_name);
-	if (devmap_pathname == NULL)
+static void loc_register_class_dev(dev_class_info_t *cli)
+{
+	/* Create loc path and name for the service. */
+	char *loc_pathname = NULL;
+
+	asprintf(&loc_pathname, "%s/%s%c%s", LOC_CLASS_NAMESPACE,
+	    cli->dev_class->name, LOC_SEPARATOR, cli->dev_name);
+	if (loc_pathname == NULL)
 		return;
 	
 	/*
-	 * Register the device by the device mapper and remember its devmap
-	 * handle.
+	 * Register the device with location service and remember its
+	 * service ID.
 	 */
-	devmap_device_register_with_iface(devmap_pathname,
-	    &cli->devmap_handle, DEVMAN_CONNECT_FROM_DEVMAP);
+	loc_service_register_with_iface(loc_pathname,
+	    &cli->service_id, DEVMAN_CONNECT_FROM_LOC);
 	
 	/*
-	 * Add device to the hash map of class devices registered by device
-	 * mapper.
+	 * Add device to the hash map of class devices registered with
+	 * location service.
 	 */
-	class_add_devmap_function(&class_list, cli);
-	
-	free(devmap_pathname);
+	class_add_loc_function(&class_list, cli);
+	
+	free(loc_pathname);
 }
 
@@ -381,6 +381,6 @@
 	dev_class_info_t *class_info = add_function_to_class(fun, cl, NULL);
 	
-	/* Register the device's class alias by devmapper. */
-	devmap_register_class_dev(class_info);
+	/* Register the device's class alias with location service. */
+	loc_register_class_dev(class_info);
 	
 	log_msg(LVL_NOTE, "Function `%s' added to class `%s' as `%s'.",
@@ -659,15 +659,15 @@
 }
 
-/** Function for handling connections from a client forwarded by the device
- * mapper to the device manager. */
-static void devman_connection_devmapper(ipc_callid_t iid, ipc_call_t *icall)
-{
-	devmap_handle_t devmap_handle = IPC_GET_ARG2(*icall);
+/** Function for handling connections from a client forwarded by the location
+ * service to the device manager. */
+static void devman_connection_loc(ipc_callid_t iid, ipc_call_t *icall)
+{
+	service_id_t service_id = IPC_GET_ARG2(*icall);
 	fun_node_t *fun;
 	dev_node_t *dev;
 
-	fun = find_devmap_tree_function(&device_tree, devmap_handle);
+	fun = find_loc_tree_function(&device_tree, service_id);
 	if (fun == NULL)
-		fun = find_devmap_class_function(&class_list, devmap_handle);
+		fun = find_loc_class_function(&class_list, service_id);
 	
 	if (fun == NULL || fun->dev->drv == NULL) {
@@ -689,5 +689,5 @@
 	
 	log_msg(LVL_DEBUG,
-	    "Forwarding devmapper request for `%s' function to driver `%s'.",
+	    "Forwarding loc service request for `%s' function to driver `%s'.",
 	    fun->pathname, dev->drv->name);
 }
@@ -708,7 +708,7 @@
 		devman_forward(iid, icall, false);
 		break;
-	case DEVMAN_CONNECT_FROM_DEVMAP:
-		/* Someone connected through devmap node. */
-		devman_connection_devmapper(iid, icall);
+	case DEVMAN_CONNECT_FROM_LOC:
+		/* Someone connected through loc node. */
+		devman_connection_loc(iid, icall);
 		break;
 	case DEVMAN_CONNECT_TO_PARENTS_DEVICE:
@@ -746,10 +746,10 @@
 	
 	/*
-	 * !!! devman_connection ... as the device manager is not a real devmap
+	 * !!! devman_connection ... as the device manager is not a real loc
 	 * driver (it uses a completely different ipc protocol than an ordinary
-	 * devmap driver) forwarding a connection from client to the devman by
-	 * devmapper would not work.
+	 * loc driver) forwarding a connection from client to the devman by
+	 * location service would not work.
 	 */
-	devmap_driver_register(NAME, devman_connection);
+	loc_server_register(NAME, devman_connection);
 	
 	return true;
Index: pace/srv/devmap/Makefile
===================================================================
--- uspace/srv/devmap/Makefile	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ 	(revision )
@@ -1,37 +1,0 @@
-#
-# Copyright (c) 2005 Martin Decky
-# Copyright (c) 2007 Jakub Jermar
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-USPACE_PREFIX = ../..
-BINARY = devmap
-STATIC_NEEDED = y
-
-SOURCES = \
-	devmap.c
-
-include $(USPACE_PREFIX)/Makefile.common
Index: pace/srv/devmap/devmap.c
===================================================================
--- uspace/srv/devmap/devmap.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ 	(revision )
@@ -1,1163 +1,0 @@
-/*
- * Copyright (c) 2007 Josef Cejka
- * 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.
- */
-
-/**
- * @defgroup devmap Device mapper.
- * @brief HelenOS device mapper.
- * @{
- */
-
-/** @file
- */
-
-#include <ipc/services.h>
-#include <ns.h>
-#include <async.h>
-#include <stdio.h>
-#include <errno.h>
-#include <bool.h>
-#include <fibril_synch.h>
-#include <stdlib.h>
-#include <str.h>
-#include <ipc/devmap.h>
-#include <assert.h>
-
-#define NAME          "devmap"
-#define NULL_DEVICES  256
-
-/** Representation of device driver.
- *
- * Each driver is responsible for a set of devices.
- *
- */
-typedef struct {
-	/** Link to drivers_list */
-	link_t drivers;
-	
-	/** List of devices controlled by this driver */
-	list_t devices;
-	
-	/** Session asociated with this driver */
-	async_sess_t *sess;
-	
-	/** Device driver name */
-	char *name;
-	
-	/** Fibril mutex for list of devices owned by this driver */
-	fibril_mutex_t devices_mutex;
-} devmap_driver_t;
-
-/** Info about registered namespaces
- *
- */
-typedef struct {
-	/** Link to namespaces_list */
-	link_t namespaces;
-	
-	/** Unique namespace identifier */
-	devmap_handle_t handle;
-	
-	/** Namespace name */
-	char *name;
-	
-	/** Reference count */
-	size_t refcnt;
-} devmap_namespace_t;
-
-/** Info about registered device
- *
- */
-typedef struct {
-	/** Link to global list of devices (devices_list) */
-	link_t devices;
-	/** Link to driver list of devices (devmap_driver_t.devices) */
-	link_t driver_devices;
-	/** Unique device identifier */
-	devmap_handle_t handle;
-	/** Device namespace */
-	devmap_namespace_t *namespace;
-	/** Device name */
-	char *name;
-	/** Device driver handling this device */
-	devmap_driver_t *driver;
-	/** Use this interface when forwarding to driver. */
-	sysarg_t forward_interface;
-} devmap_device_t;
-
-LIST_INITIALIZE(devices_list);
-LIST_INITIALIZE(namespaces_list);
-LIST_INITIALIZE(drivers_list);
-
-/* Locking order:
- *  drivers_list_mutex
- *  devices_list_mutex
- *  (devmap_driver_t *)->devices_mutex
- *  create_handle_mutex
- **/
-
-static FIBRIL_MUTEX_INITIALIZE(devices_list_mutex);
-static FIBRIL_CONDVAR_INITIALIZE(devices_list_cv);
-static FIBRIL_MUTEX_INITIALIZE(drivers_list_mutex);
-static FIBRIL_MUTEX_INITIALIZE(create_handle_mutex);
-static FIBRIL_MUTEX_INITIALIZE(null_devices_mutex);
-
-static devmap_handle_t last_handle = 0;
-static devmap_device_t *null_devices[NULL_DEVICES];
-
-/*
- * Dummy list for null devices. This is necessary so that null devices can
- * be used just as any other devices, e.g. in devmap_device_unregister_core().
- */
-static LIST_INITIALIZE(dummy_null_driver_devices);
-
-static devmap_handle_t devmap_create_handle(void)
-{
-	/* TODO: allow reusing old handles after their unregistration
-	 * and implement some version of LRU algorithm, avoid overflow
-	 */
-	
-	fibril_mutex_lock(&create_handle_mutex);
-	last_handle++;
-	fibril_mutex_unlock(&create_handle_mutex);
-	
-	return last_handle;
-}
-
-/** Convert fully qualified device name to namespace and device name.
- *
- * A fully qualified device name can be either a plain device name
- * (then the namespace is considered to be an empty string) or consist
- * of two components separated by a slash. No more than one slash
- * is allowed.
- *
- */
-static bool devmap_fqdn_split(const char *fqdn, char **ns_name, char **name)
-{
-	size_t cnt = 0;
-	size_t slash_offset = 0;
-	size_t slash_after = 0;
-	
-	size_t offset = 0;
-	size_t offset_prev = 0;
-	wchar_t c;
-	
-	while ((c = str_decode(fqdn, &offset, STR_NO_LIMIT)) != 0) {
-		if (c == '/') {
-			cnt++;
-			slash_offset = offset_prev;
-			slash_after = offset;
-		}
-		offset_prev = offset;
-	}
-	
-	/* More than one slash */
-	if (cnt > 1)
-		return false;
-	
-	/* No slash -> namespace is empty */
-	if (cnt == 0) {
-		*ns_name = str_dup("");
-		if (*ns_name == NULL)
-			return false;
-		
-		*name = str_dup(fqdn);
-		if (*name == NULL) {
-			free(*ns_name);
-			return false;
-		}
-		
-		if (str_cmp(*name, "") == 0) {
-			free(*name);
-			free(*ns_name);
-			return false;
-		}
-		
-		return true;
-	}
-	
-	/* Exactly one slash */
-	*ns_name = str_ndup(fqdn, slash_offset);
-	if (*ns_name == NULL)
-		return false;
-	
-	*name = str_dup(fqdn + slash_after);
-	if (*name == NULL) {
-		free(*ns_name);
-		return false;
-	}
-	
-	if (str_cmp(*name, "") == 0) {
-		free(*name);
-		free(*ns_name);
-		return false;
-	}
-	
-	return true;
-}
-
-/** Find namespace with given name. */
-static devmap_namespace_t *devmap_namespace_find_name(const char *name)
-{
-	assert(fibril_mutex_is_locked(&devices_list_mutex));
-	
-	list_foreach(namespaces_list, item) {
-		devmap_namespace_t *namespace =
-		    list_get_instance(item, devmap_namespace_t, namespaces);
-		if (str_cmp(namespace->name, name) == 0)
-			return namespace;
-	}
-	
-	return NULL;
-}
-
-/** Find namespace with given handle.
- *
- * @todo: use hash table
- *
- */
-static devmap_namespace_t *devmap_namespace_find_handle(devmap_handle_t handle)
-{
-	assert(fibril_mutex_is_locked(&devices_list_mutex));
-	
-	list_foreach(namespaces_list, item) {
-		devmap_namespace_t *namespace =
-		    list_get_instance(item, devmap_namespace_t, namespaces);
-		if (namespace->handle == handle)
-			return namespace;
-	}
-	
-	return NULL;
-}
-
-/** Find device with given name. */
-static devmap_device_t *devmap_device_find_name(const char *ns_name,
-    const char *name)
-{
-	assert(fibril_mutex_is_locked(&devices_list_mutex));
-	
-	list_foreach(devices_list, item) {
-		devmap_device_t *device =
-		    list_get_instance(item, devmap_device_t, devices);
-		if ((str_cmp(device->namespace->name, ns_name) == 0)
-		    && (str_cmp(device->name, name) == 0))
-			return device;
-	}
-	
-	return NULL;
-}
-
-/** Find device with given handle.
- *
- * @todo: use hash table
- *
- */
-static devmap_device_t *devmap_device_find_handle(devmap_handle_t handle)
-{
-	assert(fibril_mutex_is_locked(&devices_list_mutex));
-	
-	list_foreach(devices_list, item) {
-		devmap_device_t *device =
-		    list_get_instance(item, devmap_device_t, devices);
-		if (device->handle == handle)
-			return device;
-	}
-	
-	return NULL;
-}
-
-/** Create a namespace (if not already present). */
-static devmap_namespace_t *devmap_namespace_create(const char *ns_name)
-{
-	devmap_namespace_t *namespace;
-	
-	assert(fibril_mutex_is_locked(&devices_list_mutex));
-	
-	namespace = devmap_namespace_find_name(ns_name);
-	if (namespace != NULL)
-		return namespace;
-	
-	namespace = (devmap_namespace_t *) malloc(sizeof(devmap_namespace_t));
-	if (namespace == NULL)
-		return NULL;
-	
-	namespace->name = str_dup(ns_name);
-	if (namespace->name == NULL) {
-		free(namespace);
-		return NULL;
-	}
-	
-	namespace->handle = devmap_create_handle();
-	namespace->refcnt = 0;
-	
-	/*
-	 * Insert new namespace into list of registered namespaces
-	 */
-	list_append(&(namespace->namespaces), &namespaces_list);
-	
-	return namespace;
-}
-
-/** Destroy a namespace (if it is no longer needed). */
-static void devmap_namespace_destroy(devmap_namespace_t *namespace)
-{
-	assert(fibril_mutex_is_locked(&devices_list_mutex));
-
-	if (namespace->refcnt == 0) {
-		list_remove(&(namespace->namespaces));
-		
-		free(namespace->name);
-		free(namespace);
-	}
-}
-
-/** Increase namespace reference count by including device. */
-static void devmap_namespace_addref(devmap_namespace_t *namespace,
-    devmap_device_t *device)
-{
-	assert(fibril_mutex_is_locked(&devices_list_mutex));
-
-	device->namespace = namespace;
-	namespace->refcnt++;
-}
-
-/** Decrease namespace reference count. */
-static void devmap_namespace_delref(devmap_namespace_t *namespace)
-{
-	assert(fibril_mutex_is_locked(&devices_list_mutex));
-
-	namespace->refcnt--;
-	devmap_namespace_destroy(namespace);
-}
-
-/** Unregister device and free it. */
-static void devmap_device_unregister_core(devmap_device_t *device)
-{
-	assert(fibril_mutex_is_locked(&devices_list_mutex));
-
-	devmap_namespace_delref(device->namespace);
-	list_remove(&(device->devices));
-	list_remove(&(device->driver_devices));
-	
-	free(device->name);
-	free(device);
-}
-
-/**
- * Read info about new driver and add it into linked list of registered
- * drivers.
- */
-static devmap_driver_t *devmap_driver_register(void)
-{
-	ipc_call_t icall;
-	ipc_callid_t iid = async_get_call(&icall);
-	
-	if (IPC_GET_IMETHOD(icall) != DEVMAP_DRIVER_REGISTER) {
-		async_answer_0(iid, EREFUSED);
-		return NULL;
-	}
-	
-	devmap_driver_t *driver =
-	    (devmap_driver_t *) malloc(sizeof(devmap_driver_t));
-	if (driver == NULL) {
-		async_answer_0(iid, ENOMEM);
-		return NULL;
-	}
-	
-	/*
-	 * Get driver name
-	 */
-	int rc = async_data_write_accept((void **) &driver->name, true, 0,
-	    DEVMAP_NAME_MAXLEN, 0, NULL);
-	if (rc != EOK) {
-		free(driver);
-		async_answer_0(iid, rc);
-		return NULL;
-	}
-	
-	/*
-	 * Create connection to the driver
-	 */
-	driver->sess = async_callback_receive(EXCHANGE_SERIALIZE);
-	if (!driver->sess) {
-		free(driver->name);
-		free(driver);
-		async_answer_0(iid, ENOTSUP);
-		return NULL;
-	}
-	
-	/*
-	 * Initialize mutex for list of devices
-	 * owned by this driver
-	 */
-	fibril_mutex_initialize(&driver->devices_mutex);
-	
-	/*
-	 * Initialize list of asociated devices
-	 */
-	list_initialize(&driver->devices);
-
-	link_initialize(&driver->drivers);
-	
-	fibril_mutex_lock(&drivers_list_mutex);
-	
-	/* TODO:
-	 * Check that no driver with name equal to
-	 * driver->name is registered
-	 */
-	
-	/*
-	 * Insert new driver into list of registered drivers
-	 */
-	list_append(&(driver->drivers), &drivers_list);
-	fibril_mutex_unlock(&drivers_list_mutex);
-	
-	async_answer_0(iid, EOK);
-	
-	return driver;
-}
-
-/**
- * Unregister device driver, unregister all its devices and free driver
- * structure.
- *
- */
-static int devmap_driver_unregister(devmap_driver_t *driver)
-{
-	if (driver == NULL)
-		return EEXISTS;
-	
-	fibril_mutex_lock(&drivers_list_mutex);
-	
-	if (driver->sess)
-		async_hangup(driver->sess);
-	
-	/* Remove it from list of drivers */
-	list_remove(&(driver->drivers));
-	
-	/* Unregister all its devices */
-	fibril_mutex_lock(&devices_list_mutex);
-	fibril_mutex_lock(&driver->devices_mutex);
-	
-	while (!list_empty(&driver->devices)) {
-		devmap_device_t *device = list_get_instance(
-		    list_first(&driver->devices), devmap_device_t,
-		    driver_devices);
-		devmap_device_unregister_core(device);
-	}
-	
-	fibril_mutex_unlock(&driver->devices_mutex);
-	fibril_mutex_unlock(&devices_list_mutex);
-	fibril_mutex_unlock(&drivers_list_mutex);
-	
-	/* Free name and driver */
-	if (driver->name != NULL)
-		free(driver->name);
-	
-	free(driver);
-	
-	return EOK;
-}
-
-/** Register instance of device
- *
- */
-static void devmap_device_register(ipc_callid_t iid, ipc_call_t *icall,
-    devmap_driver_t *driver)
-{
-	if (driver == NULL) {
-		async_answer_0(iid, EREFUSED);
-		return;
-	}
-	
-	/* Create new device entry */
-	devmap_device_t *device =
-	    (devmap_device_t *) malloc(sizeof(devmap_device_t));
-	if (device == NULL) {
-		async_answer_0(iid, ENOMEM);
-		return;
-	}
-	
-	/* Set the interface, if any. */
-	device->forward_interface = IPC_GET_ARG1(*icall);
-
-	/* Get fqdn */
-	char *fqdn;
-	int rc = async_data_write_accept((void **) &fqdn, true, 0,
-	    DEVMAP_NAME_MAXLEN, 0, NULL);
-	if (rc != EOK) {
-		free(device);
-		async_answer_0(iid, rc);
-		return;
-	}
-	
-	char *ns_name;
-	if (!devmap_fqdn_split(fqdn, &ns_name, &device->name)) {
-		free(fqdn);
-		free(device);
-		async_answer_0(iid, EINVAL);
-		return;
-	}
-	
-	free(fqdn);
-	
-	fibril_mutex_lock(&devices_list_mutex);
-	
-	devmap_namespace_t *namespace = devmap_namespace_create(ns_name);
-	free(ns_name);
-	if (namespace == NULL) {
-		fibril_mutex_unlock(&devices_list_mutex);
-		free(device->name);
-		free(device);
-		async_answer_0(iid, ENOMEM);
-		return;
-	}
-	
-	link_initialize(&device->devices);
-	link_initialize(&device->driver_devices);
-	
-	/* Check that device is not already registered */
-	if (devmap_device_find_name(namespace->name, device->name) != NULL) {
-		printf("%s: Device '%s/%s' already registered\n", NAME,
-		    namespace->name, device->name);
-		devmap_namespace_destroy(namespace);
-		fibril_mutex_unlock(&devices_list_mutex);
-		free(device->name);
-		free(device);
-		async_answer_0(iid, EEXISTS);
-		return;
-	}
-	
-	/* Get unique device handle */
-	device->handle = devmap_create_handle();
-
-	devmap_namespace_addref(namespace, device);
-	device->driver = driver;
-	
-	/* Insert device into list of all devices  */
-	list_append(&device->devices, &devices_list);
-	
-	/* Insert device into list of devices that belog to one driver */
-	fibril_mutex_lock(&device->driver->devices_mutex);
-	
-	list_append(&device->driver_devices, &device->driver->devices);
-	
-	fibril_mutex_unlock(&device->driver->devices_mutex);
-	fibril_condvar_broadcast(&devices_list_cv);
-	fibril_mutex_unlock(&devices_list_mutex);
-	
-	async_answer_1(iid, EOK, device->handle);
-}
-
-/**
- *
- */
-static int devmap_device_unregister(ipc_callid_t iid, ipc_call_t *icall, 
-    devmap_driver_t *driver)
-{
-	/* TODO */
-	return EOK;
-}
-
-/** Connect client to the device.
- *
- * Find device driver owning requested device and forward
- * the message to it.
- *
- */
-static void devmap_forward(ipc_callid_t callid, ipc_call_t *call)
-{
-	fibril_mutex_lock(&devices_list_mutex);
-	
-	/*
-	 * Get handle from request
-	 */
-	devmap_handle_t handle = IPC_GET_ARG2(*call);
-	devmap_device_t *dev = devmap_device_find_handle(handle);
-	
-	if ((dev == NULL) || (dev->driver == NULL) || (!dev->driver->sess)) {
-		fibril_mutex_unlock(&devices_list_mutex);
-		async_answer_0(callid, ENOENT);
-		return;
-	}
-	
-	async_exch_t *exch = async_exchange_begin(dev->driver->sess);
-	
-	if (dev->forward_interface == 0)
-		async_forward_fast(callid, exch, dev->handle, 0, 0, IPC_FF_NONE);
-	else
-		async_forward_fast(callid, exch, dev->forward_interface,
-		    dev->handle, 0, IPC_FF_NONE);
-	
-	async_exchange_end(exch);
-	
-	fibril_mutex_unlock(&devices_list_mutex);
-}
-
-/** Find handle for device instance identified by name.
- *
- * In answer will be send EOK and device handle in arg1 or a error
- * code from errno.h.
- *
- */
-static void devmap_device_get_handle(ipc_callid_t iid, ipc_call_t *icall)
-{
-	char *fqdn;
-	
-	/* Get fqdn */
-	int rc = async_data_write_accept((void **) &fqdn, true, 0,
-	    DEVMAP_NAME_MAXLEN, 0, NULL);
-	if (rc != EOK) {
-		async_answer_0(iid, rc);
-		return;
-	}
-	
-	char *ns_name;
-	char *name;
-	if (!devmap_fqdn_split(fqdn, &ns_name, &name)) {
-		free(fqdn);
-		async_answer_0(iid, EINVAL);
-		return;
-	}
-	
-	free(fqdn);
-	
-	fibril_mutex_lock(&devices_list_mutex);
-	const devmap_device_t *dev;
-	
-recheck:
-	
-	/*
-	 * Find device name in the list of known devices.
-	 */
-	dev = devmap_device_find_name(ns_name, name);
-	
-	/*
-	 * Device was not found.
-	 */
-	if (dev == NULL) {
-		if (IPC_GET_ARG1(*icall) & IPC_FLAG_BLOCKING) {
-			/* Blocking lookup */
-			fibril_condvar_wait(&devices_list_cv,
-			    &devices_list_mutex);
-			goto recheck;
-		}
-		
-		async_answer_0(iid, ENOENT);
-		free(ns_name);
-		free(name);
-		fibril_mutex_unlock(&devices_list_mutex);
-		return;
-	}
-	
-	async_answer_1(iid, EOK, dev->handle);
-	
-	fibril_mutex_unlock(&devices_list_mutex);
-	free(ns_name);
-	free(name);
-}
-
-/** Find handle for namespace identified by name.
- *
- * In answer will be send EOK and device handle in arg1 or a error
- * code from errno.h.
- *
- */
-static void devmap_namespace_get_handle(ipc_callid_t iid, ipc_call_t *icall)
-{
-	char *name;
-	
-	/* Get device name */
-	int rc = async_data_write_accept((void **) &name, true, 0,
-	    DEVMAP_NAME_MAXLEN, 0, NULL);
-	if (rc != EOK) {
-		async_answer_0(iid, rc);
-		return;
-	}
-	
-	fibril_mutex_lock(&devices_list_mutex);
-	const devmap_namespace_t *namespace;
-	
-recheck:
-	
-	/*
-	 * Find namespace name in the list of known namespaces.
-	 */
-	namespace = devmap_namespace_find_name(name);
-	
-	/*
-	 * Namespace was not found.
-	 */
-	if (namespace == NULL) {
-		if (IPC_GET_ARG1(*icall) & IPC_FLAG_BLOCKING) {
-			/* Blocking lookup */
-			fibril_condvar_wait(&devices_list_cv,
-			    &devices_list_mutex);
-			goto recheck;
-		}
-		
-		async_answer_0(iid, ENOENT);
-		free(name);
-		fibril_mutex_unlock(&devices_list_mutex);
-		return;
-	}
-	
-	async_answer_1(iid, EOK, namespace->handle);
-	
-	fibril_mutex_unlock(&devices_list_mutex);
-	free(name);
-}
-
-static void devmap_handle_probe(ipc_callid_t iid, ipc_call_t *icall)
-{
-	fibril_mutex_lock(&devices_list_mutex);
-	
-	devmap_namespace_t *namespace =
-	    devmap_namespace_find_handle(IPC_GET_ARG1(*icall));
-	if (namespace == NULL) {
-		devmap_device_t *dev =
-		    devmap_device_find_handle(IPC_GET_ARG1(*icall));
-		if (dev == NULL)
-			async_answer_1(iid, EOK, DEV_HANDLE_NONE);
-		else
-			async_answer_1(iid, EOK, DEV_HANDLE_DEVICE);
-	} else
-		async_answer_1(iid, EOK, DEV_HANDLE_NAMESPACE);
-	
-	fibril_mutex_unlock(&devices_list_mutex);
-}
-
-static void devmap_get_namespace_count(ipc_callid_t iid, ipc_call_t *icall)
-{
-	fibril_mutex_lock(&devices_list_mutex);
-	async_answer_1(iid, EOK, list_count(&namespaces_list));
-	fibril_mutex_unlock(&devices_list_mutex);
-}
-
-static void devmap_get_device_count(ipc_callid_t iid, ipc_call_t *icall)
-{
-	fibril_mutex_lock(&devices_list_mutex);
-	
-	devmap_namespace_t *namespace =
-	    devmap_namespace_find_handle(IPC_GET_ARG1(*icall));
-	if (namespace == NULL)
-		async_answer_0(iid, EEXISTS);
-	else
-		async_answer_1(iid, EOK, namespace->refcnt);
-	
-	fibril_mutex_unlock(&devices_list_mutex);
-}
-
-static void devmap_get_namespaces(ipc_callid_t iid, ipc_call_t *icall)
-{
-	ipc_callid_t callid;
-	size_t size;
-	if (!async_data_read_receive(&callid, &size)) {
-		async_answer_0(callid, EREFUSED);
-		async_answer_0(iid, EREFUSED);
-		return;
-	}
-	
-	if ((size % sizeof(dev_desc_t)) != 0) {
-		async_answer_0(callid, EINVAL);
-		async_answer_0(iid, EINVAL);
-		return;
-	}
-	
-	fibril_mutex_lock(&devices_list_mutex);
-	
-	size_t count = size / sizeof(dev_desc_t);
-	if (count != list_count(&namespaces_list)) {
-		fibril_mutex_unlock(&devices_list_mutex);
-		async_answer_0(callid, EOVERFLOW);
-		async_answer_0(iid, EOVERFLOW);
-		return;
-	}
-	
-	dev_desc_t *desc = (dev_desc_t *) malloc(size);
-	if (desc == NULL) {
-		fibril_mutex_unlock(&devices_list_mutex);
-		async_answer_0(callid, ENOMEM);
-		async_answer_0(iid, ENOMEM);
-		return;
-	}
-	
-	size_t pos = 0;
-	list_foreach(namespaces_list, item) {
-		devmap_namespace_t *namespace =
-		    list_get_instance(item, devmap_namespace_t, namespaces);
-		
-		desc[pos].handle = namespace->handle;
-		str_cpy(desc[pos].name, DEVMAP_NAME_MAXLEN, namespace->name);
-		pos++;
-	}
-	
-	sysarg_t retval = async_data_read_finalize(callid, desc, size);
-	
-	free(desc);
-	fibril_mutex_unlock(&devices_list_mutex);
-	
-	async_answer_0(iid, retval);
-}
-
-static void devmap_get_devices(ipc_callid_t iid, ipc_call_t *icall)
-{
-	/* FIXME: Use faster algorithm which can make better use
-	   of namespaces */
-	
-	ipc_callid_t callid;
-	size_t size;
-	if (!async_data_read_receive(&callid, &size)) {
-		async_answer_0(callid, EREFUSED);
-		async_answer_0(iid, EREFUSED);
-		return;
-	}
-	
-	if ((size % sizeof(dev_desc_t)) != 0) {
-		async_answer_0(callid, EINVAL);
-		async_answer_0(iid, EINVAL);
-		return;
-	}
-	
-	fibril_mutex_lock(&devices_list_mutex);
-	
-	devmap_namespace_t *namespace =
-	    devmap_namespace_find_handle(IPC_GET_ARG1(*icall));
-	if (namespace == NULL) {
-		fibril_mutex_unlock(&devices_list_mutex);
-		async_answer_0(callid, ENOENT);
-		async_answer_0(iid, ENOENT);
-		return;
-	}
-	
-	size_t count = size / sizeof(dev_desc_t);
-	if (count != namespace->refcnt) {
-		fibril_mutex_unlock(&devices_list_mutex);
-		async_answer_0(callid, EOVERFLOW);
-		async_answer_0(iid, EOVERFLOW);
-		return;
-	}
-	
-	dev_desc_t *desc = (dev_desc_t *) malloc(size);
-	if (desc == NULL) {
-		fibril_mutex_unlock(&devices_list_mutex);
-		async_answer_0(callid, ENOMEM);
-		async_answer_0(iid, EREFUSED);
-		return;
-	}
-	
-	size_t pos = 0;
-	list_foreach(devices_list, item) {
-		devmap_device_t *device =
-		    list_get_instance(item, devmap_device_t, devices);
-		
-		if (device->namespace == namespace) {
-			desc[pos].handle = device->handle;
-			str_cpy(desc[pos].name, DEVMAP_NAME_MAXLEN, device->name);
-			pos++;
-		}
-	}
-	
-	sysarg_t retval = async_data_read_finalize(callid, desc, size);
-	
-	free(desc);
-	fibril_mutex_unlock(&devices_list_mutex);
-	
-	async_answer_0(iid, retval);
-}
-
-static void devmap_null_create(ipc_callid_t iid, ipc_call_t *icall)
-{
-	fibril_mutex_lock(&null_devices_mutex);
-	
-	unsigned int i;
-	bool fnd = false;
-	
-	for (i = 0; i < NULL_DEVICES; i++) {
-		if (null_devices[i] == NULL) {
-			fnd = true;
-			break;
-		}
-	}
-	
-	if (!fnd) {
-		fibril_mutex_unlock(&null_devices_mutex);
-		async_answer_0(iid, ENOMEM);
-		return;
-	}
-	
-	char null[DEVMAP_NAME_MAXLEN];
-	snprintf(null, DEVMAP_NAME_MAXLEN, "%u", i);
-	
-	char *dev_name = str_dup(null);
-	if (dev_name == NULL) {
-		fibril_mutex_unlock(&null_devices_mutex);
-		async_answer_0(iid, ENOMEM);
-		return;
-	}
-	
-	devmap_device_t *device =
-	    (devmap_device_t *) malloc(sizeof(devmap_device_t));
-	if (device == NULL) {
-		fibril_mutex_unlock(&null_devices_mutex);
-		async_answer_0(iid, ENOMEM);
-		return;
-	}
-	
-	fibril_mutex_lock(&devices_list_mutex);
-	
-	devmap_namespace_t *namespace = devmap_namespace_create("null");
-	if (namespace == NULL) {
-		fibril_mutex_lock(&devices_list_mutex);
-		fibril_mutex_unlock(&null_devices_mutex);
-		async_answer_0(iid, ENOMEM);
-		return;
-	}
-	
-	link_initialize(&device->devices);
-	link_initialize(&device->driver_devices);
-	
-	/* Get unique device handle */
-	device->handle = devmap_create_handle();
-	device->driver = NULL;
-	
-	devmap_namespace_addref(namespace, device);
-	device->name = dev_name;
-	
-	/*
-	 * Insert device into list of all devices and into null devices array.
-	 * Insert device into a dummy list of null driver's devices so that it
-	 * can be safely removed later.
-	 */
-	list_append(&device->devices, &devices_list);
-	list_append(&device->driver_devices, &dummy_null_driver_devices);
-	null_devices[i] = device;
-	
-	fibril_mutex_unlock(&devices_list_mutex);
-	fibril_mutex_unlock(&null_devices_mutex);
-	
-	async_answer_1(iid, EOK, (sysarg_t) i);
-}
-
-static void devmap_null_destroy(ipc_callid_t iid, ipc_call_t *icall)
-{
-	sysarg_t i = IPC_GET_ARG1(*icall);
-	if (i >= NULL_DEVICES) {
-		async_answer_0(iid, ELIMIT);
-		return;
-	}
-	
-	fibril_mutex_lock(&null_devices_mutex);
-	
-	if (null_devices[i] == NULL) {
-		fibril_mutex_unlock(&null_devices_mutex);
-		async_answer_0(iid, ENOENT);
-		return;
-	}
-	
-	fibril_mutex_lock(&devices_list_mutex);
-	devmap_device_unregister_core(null_devices[i]);
-	fibril_mutex_unlock(&devices_list_mutex);
-	
-	null_devices[i] = NULL;
-	
-	fibril_mutex_unlock(&null_devices_mutex);
-	async_answer_0(iid, EOK);
-}
-
-/** Initialize device mapper.
- *
- *
- */
-static bool devmap_init(void)
-{
-	fibril_mutex_lock(&null_devices_mutex);
-	
-	unsigned int i;
-	for (i = 0; i < NULL_DEVICES; i++)
-		null_devices[i] = NULL;
-	
-	fibril_mutex_unlock(&null_devices_mutex);
-	
-	return true;
-}
-
-/** Handle connection with device driver.
- *
- */
-static void devmap_connection_driver(ipc_callid_t iid, ipc_call_t *icall)
-{
-	/* Accept connection */
-	async_answer_0(iid, EOK);
-	
-	devmap_driver_t *driver = devmap_driver_register();
-	if (driver == NULL)
-		return;
-	
-	while (true) {
-		ipc_call_t call;
-		ipc_callid_t callid = async_get_call(&call);
-		
-		if (!IPC_GET_IMETHOD(call))
-			break;
-		
-		switch (IPC_GET_IMETHOD(call)) {
-		case DEVMAP_DRIVER_UNREGISTER:
-			if (NULL == driver)
-				async_answer_0(callid, ENOENT);
-			else
-				async_answer_0(callid, EOK);
-			break;
-		case DEVMAP_DEVICE_REGISTER:
-			/* Register one instance of device */
-			devmap_device_register(callid, &call, driver);
-			break;
-		case DEVMAP_DEVICE_UNREGISTER:
-			/* Remove instance of device identified by handler */
-			devmap_device_unregister(callid, &call, driver);
-			break;
-		case DEVMAP_DEVICE_GET_HANDLE:
-			devmap_device_get_handle(callid, &call);
-			break;
-		case DEVMAP_NAMESPACE_GET_HANDLE:
-			devmap_namespace_get_handle(callid, &call);
-			break;
-		default:
-			async_answer_0(callid, ENOENT);
-		}
-	}
-	
-	if (driver != NULL) {
-		/*
-		 * Unregister the device driver and all its devices.
-		 */
-		devmap_driver_unregister(driver);
-		driver = NULL;
-	}
-}
-
-/** Handle connection with device client.
- *
- */
-static void devmap_connection_client(ipc_callid_t iid, ipc_call_t *icall)
-{
-	/* Accept connection */
-	async_answer_0(iid, EOK);
-	
-	while (true) {
-		ipc_call_t call;
-		ipc_callid_t callid = async_get_call(&call);
-		
-		if (!IPC_GET_IMETHOD(call))
-			break;
-		
-		switch (IPC_GET_IMETHOD(call)) {
-		case DEVMAP_DEVICE_GET_HANDLE:
-			devmap_device_get_handle(callid, &call);
-			break;
-		case DEVMAP_NAMESPACE_GET_HANDLE:
-			devmap_namespace_get_handle(callid, &call);
-			break;
-		case DEVMAP_HANDLE_PROBE:
-			devmap_handle_probe(callid, &call);
-			break;
-		case DEVMAP_NULL_CREATE:
-			devmap_null_create(callid, &call);
-			break;
-		case DEVMAP_NULL_DESTROY:
-			devmap_null_destroy(callid, &call);
-			break;
-		case DEVMAP_GET_NAMESPACE_COUNT:
-			devmap_get_namespace_count(callid, &call);
-			break;
-		case DEVMAP_GET_DEVICE_COUNT:
-			devmap_get_device_count(callid, &call);
-			break;
-		case DEVMAP_GET_NAMESPACES:
-			devmap_get_namespaces(callid, &call);
-			break;
-		case DEVMAP_GET_DEVICES:
-			devmap_get_devices(callid, &call);
-			break;
-		default:
-			async_answer_0(callid, ENOENT);
-		}
-	}
-}
-
-/** Function for handling connections to devmap
- *
- */
-static void devmap_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
-{
-	/* Select interface */
-	switch ((sysarg_t) (IPC_GET_ARG1(*icall))) {
-	case DEVMAP_DRIVER:
-		devmap_connection_driver(iid, icall);
-		break;
-	case DEVMAP_CLIENT:
-		devmap_connection_client(iid, icall);
-		break;
-	case DEVMAP_CONNECT_TO_DEVICE:
-		/* Connect client to selected device */
-		devmap_forward(iid, icall);
-		break;
-	default:
-		/* No such interface */
-		async_answer_0(iid, ENOENT);
-	}
-}
-
-/**
- *
- */
-int main(int argc, char *argv[])
-{
-	printf("%s: HelenOS Device Mapper\n", NAME);
-	
-	if (!devmap_init()) {
-		printf("%s: Error while initializing service\n", NAME);
-		return -1;
-	}
-	
-	/* Set a handler of incomming connections */
-	async_set_client_connection(devmap_connection);
-	
-	/* Register device mapper at naming service */
-	if (service_register(SERVICE_DEVMAP) != EOK)
-		return -1;
-	
-	printf("%s: Accepting connections\n", NAME);
-	async_manager();
-	
-	/* Never reached */
-	return 0;
-}
-
-/**
- * @}
- */
Index: pace/srv/fs/devfs/Makefile
===================================================================
--- uspace/srv/fs/devfs/Makefile	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ 	(revision )
@@ -1,40 +1,0 @@
-#
-# Copyright (c) 2005 Martin Decky
-# Copyright (c) 2007 Jakub Jermar
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# - Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in the
-#   documentation and/or other materials provided with the distribution.
-# - The name of the author may not be used to endorse or promote products
-#   derived from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-USPACE_PREFIX = ../../..
-LIBS = $(LIBFS_PREFIX)/libfs.a
-EXTRA_CFLAGS += -I$(LIBFS_PREFIX)
-BINARY = devfs
-STATIC_NEEDED = y
-
-SOURCES = \
-	devfs.c \
-	devfs_ops.c
-
-include $(USPACE_PREFIX)/Makefile.common
Index: pace/srv/fs/devfs/devfs.c
===================================================================
--- uspace/srv/fs/devfs/devfs.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ 	(revision )
@@ -1,153 +1,0 @@
-/*
- * Copyright (c) 2009 Martin Decky
- * 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 fs
- * @{
- */
-
-/**
- * @file devfs.c
- * @brief Devices file system.
- *
- * Every device registered to device mapper is represented as a file in this
- * file system.
- */
-
-#include <stdio.h>
-#include <ipc/services.h>
-#include <ns.h>
-#include <async.h>
-#include <errno.h>
-#include <task.h>
-#include <libfs.h>
-#include "devfs.h"
-#include "devfs_ops.h"
-
-#define NAME  "devfs"
-
-static vfs_info_t devfs_vfs_info = {
-	.name = NAME,
-	.concurrent_read_write = false,
-	.write_retains_size = false,
-};
-
-fs_reg_t devfs_reg;
-
-static void devfs_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
-{
-	if (iid)
-		async_answer_0(iid, EOK);
-	
-	while (true) {
-		ipc_call_t call;
-		ipc_callid_t callid = async_get_call(&call);
-		
-		if (!IPC_GET_IMETHOD(call))
-			return;
-		
-		switch (IPC_GET_IMETHOD(call)) {
-		case VFS_OUT_MOUNTED:
-			devfs_mounted(callid, &call);
-			break;
-		case VFS_OUT_MOUNT:
-			devfs_mount(callid, &call);
-			break;
-		case VFS_OUT_UNMOUNTED:
-			devfs_unmounted(callid, &call);
-			break;
-		case VFS_OUT_UNMOUNT:
-			devfs_unmount(callid, &call);
-			break;
-		case VFS_OUT_LOOKUP:
-			devfs_lookup(callid, &call);
-			break;
-		case VFS_OUT_OPEN_NODE:
-			devfs_open_node(callid, &call);
-			break;
-		case VFS_OUT_STAT:
-			devfs_stat(callid, &call);
-			break;
-		case VFS_OUT_READ:
-			devfs_read(callid, &call);
-			break;
-		case VFS_OUT_WRITE:
-			devfs_write(callid, &call);
-			break;
-		case VFS_OUT_TRUNCATE:
-			devfs_truncate(callid, &call);
-			break;
-		case VFS_OUT_CLOSE:
-			devfs_close(callid, &call);
-			break;
-		case VFS_OUT_SYNC:
-			devfs_sync(callid, &call);
-			break;
-		case VFS_OUT_DESTROY:
-			devfs_destroy(callid, &call);
-			break;
-		default:
-			async_answer_0(callid, ENOTSUP);
-			break;
-		}
-	}
-}
-
-int main(int argc, char *argv[])
-{
-	printf("%s: HelenOS Device Filesystem\n", NAME);
-	
-	if (!devfs_init()) {
-		printf("%s: failed to initialize devfs\n", NAME);
-		return -1;
-	}
-	
-	async_sess_t *vfs_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
-	    SERVICE_VFS, 0, 0);
-	if (!vfs_sess) {
-		printf("%s: Unable to connect to VFS\n", NAME);
-		return -1;
-	}
-	
-	int rc = fs_register(vfs_sess, &devfs_reg, &devfs_vfs_info,
-	    devfs_connection);
-	if (rc != EOK) {
-		printf("%s: Failed to register file system (%d)\n", NAME, rc);
-		return rc;
-	}
-	
-	printf("%s: Accepting connections\n", NAME);
-	task_retval(0);
-	async_manager();
-	
-	/* Not reached */
-	return 0;
-}
-
-/**
- * @}
- */
Index: pace/srv/fs/devfs/devfs.h
===================================================================
--- uspace/srv/fs/devfs/devfs.h	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ 	(revision )
@@ -1,44 +1,0 @@
-/*
- * Copyright (c) 2009 Martin Decky
- * 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 fs
- * @{
- */ 
-
-#ifndef DEVFS_DEVFS_H_
-#define DEVFS_DEVFS_H_
-
-#include <libfs.h>
-
-extern fs_reg_t devfs_reg;
-
-#endif
-
-/**
- * @}
- */
Index: pace/srv/fs/devfs/devfs_ops.c
===================================================================
--- uspace/srv/fs/devfs/devfs_ops.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ 	(revision )
@@ -1,836 +1,0 @@
-/*
- * Copyright (c) 2009 Martin Decky
- * 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 fs
- * @{
- */
-
-/**
- * @file devfs_ops.c
- * @brief Implementation of VFS operations for the devfs file system server.
- */
-
-#include <macros.h>
-#include <bool.h>
-#include <errno.h>
-#include <malloc.h>
-#include <str.h>
-#include <libfs.h>
-#include <fibril_synch.h>
-#include <adt/hash_table.h>
-#include <ipc/devmap.h>
-#include <sys/stat.h>
-#include <libfs.h>
-#include <assert.h>
-#include "devfs.h"
-#include "devfs_ops.h"
-
-typedef struct {
-	devmap_handle_type_t type;
-	devmap_handle_t handle;
-} devfs_node_t;
-
-/** Opened devices structure */
-typedef struct {
-	devmap_handle_t handle;
-	async_sess_t *sess;       /**< If NULL, the structure is incomplete. */
-	size_t refcount;
-	link_t link;
-	fibril_condvar_t cv;      /**< Broadcast when completed. */
-} device_t;
-
-/** Hash table of opened devices */
-static hash_table_t devices;
-
-/** Hash table mutex */
-static FIBRIL_MUTEX_INITIALIZE(devices_mutex);
-
-#define DEVICES_KEYS        1
-#define DEVICES_KEY_HANDLE  0
-#define DEVICES_BUCKETS     256
-
-/* Implementation of hash table interface for the nodes hash table. */
-static hash_index_t devices_hash(unsigned long key[])
-{
-	return key[DEVICES_KEY_HANDLE] % DEVICES_BUCKETS;
-}
-
-static int devices_compare(unsigned long key[], hash_count_t keys, link_t *item)
-{
-	device_t *dev = hash_table_get_instance(item, device_t, link);
-	return (dev->handle == (devmap_handle_t) key[DEVICES_KEY_HANDLE]);
-}
-
-static void devices_remove_callback(link_t *item)
-{
-	free(hash_table_get_instance(item, device_t, link));
-}
-
-static hash_table_operations_t devices_ops = {
-	.hash = devices_hash,
-	.compare = devices_compare,
-	.remove_callback = devices_remove_callback
-};
-
-static int devfs_node_get_internal(fs_node_t **rfn, devmap_handle_type_t type,
-    devmap_handle_t handle)
-{
-	devfs_node_t *node = (devfs_node_t *) malloc(sizeof(devfs_node_t));
-	if (node == NULL) {
-		*rfn = NULL;
-		return ENOMEM;
-	}
-	
-	*rfn = (fs_node_t *) malloc(sizeof(fs_node_t));
-	if (*rfn == NULL) {
-		free(node);
-		*rfn = NULL;
-		return ENOMEM;
-	}
-	
-	fs_node_initialize(*rfn);
-	node->type = type;
-	node->handle = handle;
-	
-	(*rfn)->data = node;
-	return EOK;
-}
-
-static int devfs_root_get(fs_node_t **rfn, devmap_handle_t devmap_handle)
-{
-	return devfs_node_get_internal(rfn, DEV_HANDLE_NONE, 0);
-}
-
-static int devfs_match(fs_node_t **rfn, fs_node_t *pfn, const char *component)
-{
-	devfs_node_t *node = (devfs_node_t *) pfn->data;
-	int ret;
-	
-	if (node->handle == 0) {
-		/* Root directory */
-		
-		dev_desc_t *devs;
-		size_t count = devmap_get_namespaces(&devs);
-		
-		if (count > 0) {
-			size_t pos;
-			for (pos = 0; pos < count; pos++) {
-				/* Ignore root namespace */
-				if (str_cmp(devs[pos].name, "") == 0)
-					continue;
-				
-				if (str_cmp(devs[pos].name, component) == 0) {
-					ret = devfs_node_get_internal(rfn, DEV_HANDLE_NAMESPACE, devs[pos].handle);
-					free(devs);
-					return ret;
-				}
-			}
-			
-			free(devs);
-		}
-		
-		/* Search root namespace */
-		devmap_handle_t namespace;
-		if (devmap_namespace_get_handle("", &namespace, 0) == EOK) {
-			count = devmap_get_devices(namespace, &devs);
-			
-			if (count > 0) {
-				size_t pos;
-				for (pos = 0; pos < count; pos++) {
-					if (str_cmp(devs[pos].name, component) == 0) {
-						ret = devfs_node_get_internal(rfn, DEV_HANDLE_DEVICE, devs[pos].handle);
-						free(devs);
-						return ret;
-					}
-				}
-				
-				free(devs);
-			}
-		}
-		
-		*rfn = NULL;
-		return EOK;
-	}
-	
-	if (node->type == DEV_HANDLE_NAMESPACE) {
-		/* Namespace directory */
-		
-		dev_desc_t *devs;
-		size_t count = devmap_get_devices(node->handle, &devs);
-		if (count > 0) {
-			size_t pos;
-			for (pos = 0; pos < count; pos++) {
-				if (str_cmp(devs[pos].name, component) == 0) {
-					ret = devfs_node_get_internal(rfn, DEV_HANDLE_DEVICE, devs[pos].handle);
-					free(devs);
-					return ret;
-				}
-			}
-			
-			free(devs);
-		}
-		
-		*rfn = NULL;
-		return EOK;
-	}
-	
-	*rfn = NULL;
-	return EOK;
-}
-
-static int devfs_node_get(fs_node_t **rfn, devmap_handle_t devmap_handle, fs_index_t index)
-{
-	return devfs_node_get_internal(rfn, devmap_handle_probe(index), index);
-}
-
-static int devfs_node_open(fs_node_t *fn)
-{
-	devfs_node_t *node = (devfs_node_t *) fn->data;
-	
-	if (node->handle == 0) {
-		/* Root directory */
-		return EOK;
-	}
-	
-	devmap_handle_type_t type = devmap_handle_probe(node->handle);
-	
-	if (type == DEV_HANDLE_NAMESPACE) {
-		/* Namespace directory */
-		return EOK;
-	}
-	
-	if (type == DEV_HANDLE_DEVICE) {
-		/* Device node */
-		
-		unsigned long key[] = {
-			[DEVICES_KEY_HANDLE] = (unsigned long) node->handle
-		};
-		link_t *lnk;
-		
-		fibril_mutex_lock(&devices_mutex);
-restart:
-		lnk = hash_table_find(&devices, key);
-		if (lnk == NULL) {
-			device_t *dev = (device_t *) malloc(sizeof(device_t));
-			if (dev == NULL) {
-				fibril_mutex_unlock(&devices_mutex);
-				return ENOMEM;
-			}
-			
-			dev->handle = node->handle;
-			
-			/* Mark as incomplete */
-			dev->sess = NULL;
-			dev->refcount = 1;
-			fibril_condvar_initialize(&dev->cv);
-			
-			/*
-			 * Insert the incomplete device structure so that other
-			 * fibrils will not race with us when we drop the mutex
-			 * below.
-			 */
-			hash_table_insert(&devices, key, &dev->link);
-			
-			/*
-			 * Drop the mutex to allow recursive devfs requests.
-			 */
-			fibril_mutex_unlock(&devices_mutex);
-			
-			async_sess_t *sess = devmap_device_connect(EXCHANGE_SERIALIZE,
-			    node->handle, 0);
-			
-			fibril_mutex_lock(&devices_mutex);
-			
-			/*
-			 * Notify possible waiters about this device structure
-			 * being completed (or destroyed).
-			 */
-			fibril_condvar_broadcast(&dev->cv);
-			
-			if (!sess) {
-				/*
-				 * Connecting failed, need to remove the
-				 * entry and free the device structure.
-				 */
-				hash_table_remove(&devices, key, DEVICES_KEYS);
-				fibril_mutex_unlock(&devices_mutex);
-				
-				return ENOENT;
-			}
-			
-			/* Set the correct session. */
-			dev->sess = sess;
-		} else {
-			device_t *dev = hash_table_get_instance(lnk, device_t, link);
-			
-			if (!dev->sess) {
-				/*
-				 * Wait until the device structure is completed
-				 * and start from the beginning as the device
-				 * structure might have entirely disappeared
-				 * while we were not holding the mutex in
-				 * fibril_condvar_wait().
-				 */
-				fibril_condvar_wait(&dev->cv, &devices_mutex);
-				goto restart;
-			}
-
-			dev->refcount++;
-		}
-		
-		fibril_mutex_unlock(&devices_mutex);
-		
-		return EOK;
-	}
-	
-	return ENOENT;
-}
-
-static int devfs_node_put(fs_node_t *fn)
-{
-	free(fn->data);
-	free(fn);
-	return EOK;
-}
-
-static int devfs_create_node(fs_node_t **rfn, devmap_handle_t devmap_handle, int lflag)
-{
-	assert((lflag & L_FILE) ^ (lflag & L_DIRECTORY));
-	
-	*rfn = NULL;
-	return ENOTSUP;
-}
-
-static int devfs_destroy_node(fs_node_t *fn)
-{
-	return ENOTSUP;
-}
-
-static int devfs_link_node(fs_node_t *pfn, fs_node_t *cfn, const char *nm)
-{
-	return ENOTSUP;
-}
-
-static int devfs_unlink_node(fs_node_t *pfn, fs_node_t *cfn, const char *nm)
-{
-	return ENOTSUP;
-}
-
-static int devfs_has_children(bool *has_children, fs_node_t *fn)
-{
-	devfs_node_t *node = (devfs_node_t *) fn->data;
-	
-	if (node->handle == 0) {
-		size_t count = devmap_count_namespaces();
-		if (count > 0) {
-			*has_children = true;
-			return EOK;
-		}
-		
-		/* Root namespace */
-		devmap_handle_t namespace;
-		if (devmap_namespace_get_handle("", &namespace, 0) == EOK) {
-			count = devmap_count_devices(namespace);
-			if (count > 0) {
-				*has_children = true;
-				return EOK;
-			}
-		}
-		
-		*has_children = false;
-		return EOK;
-	}
-	
-	if (node->type == DEV_HANDLE_NAMESPACE) {
-		size_t count = devmap_count_devices(node->handle);
-		if (count > 0) {
-			*has_children = true;
-			return EOK;
-		}
-		
-		*has_children = false;
-		return EOK;
-	}
-	
-	*has_children = false;
-	return EOK;
-}
-
-static fs_index_t devfs_index_get(fs_node_t *fn)
-{
-	devfs_node_t *node = (devfs_node_t *) fn->data;
-	return node->handle;
-}
-
-static aoff64_t devfs_size_get(fs_node_t *fn)
-{
-	return 0;
-}
-
-static unsigned int devfs_lnkcnt_get(fs_node_t *fn)
-{
-	devfs_node_t *node = (devfs_node_t *) fn->data;
-	
-	if (node->handle == 0)
-		return 0;
-	
-	return 1;
-}
-
-static char devfs_plb_get_char(unsigned pos)
-{
-	return devfs_reg.plb_ro[pos % PLB_SIZE];
-}
-
-static bool devfs_is_directory(fs_node_t *fn)
-{
-	devfs_node_t *node = (devfs_node_t *) fn->data;
-	
-	return ((node->type == DEV_HANDLE_NONE) || (node->type == DEV_HANDLE_NAMESPACE));
-}
-
-static bool devfs_is_file(fs_node_t *fn)
-{
-	devfs_node_t *node = (devfs_node_t *) fn->data;
-	
-	return (node->type == DEV_HANDLE_DEVICE);
-}
-
-static devmap_handle_t devfs_device_get(fs_node_t *fn)
-{
-	devfs_node_t *node = (devfs_node_t *) fn->data;
-	
-	if (node->type == DEV_HANDLE_DEVICE)
-		return node->handle;
-	
-	return 0;
-}
-
-/** libfs operations */
-libfs_ops_t devfs_libfs_ops = {
-	.root_get = devfs_root_get,
-	.match = devfs_match,
-	.node_get = devfs_node_get,
-	.node_open = devfs_node_open,
-	.node_put = devfs_node_put,
-	.create = devfs_create_node,
-	.destroy = devfs_destroy_node,
-	.link = devfs_link_node,
-	.unlink = devfs_unlink_node,
-	.has_children = devfs_has_children,
-	.index_get = devfs_index_get,
-	.size_get = devfs_size_get,
-	.lnkcnt_get = devfs_lnkcnt_get,
-	.plb_get_char = devfs_plb_get_char,
-	.is_directory = devfs_is_directory,
-	.is_file = devfs_is_file,
-	.device_get = devfs_device_get
-};
-
-bool devfs_init(void)
-{
-	if (!hash_table_create(&devices, DEVICES_BUCKETS,
-	    DEVICES_KEYS, &devices_ops))
-		return false;
-	
-	return true;
-}
-
-void devfs_mounted(ipc_callid_t rid, ipc_call_t *request)
-{
-	char *opts;
-	
-	/* Accept the mount options */
-	sysarg_t retval = async_data_write_accept((void **) &opts, true, 0, 0,
-	    0, NULL);
-	if (retval != EOK) {
-		async_answer_0(rid, retval);
-		return;
-	}
-	
-	free(opts);
-	async_answer_3(rid, EOK, 0, 0, 0);
-}
-
-void devfs_mount(ipc_callid_t rid, ipc_call_t *request)
-{
-	libfs_mount(&devfs_libfs_ops, devfs_reg.fs_handle, rid, request);
-}
-
-void devfs_unmounted(ipc_callid_t rid, ipc_call_t *request)
-{
-	async_answer_0(rid, ENOTSUP);
-}
-
-void devfs_unmount(ipc_callid_t rid, ipc_call_t *request)
-{
-	libfs_unmount(&devfs_libfs_ops, rid, request);
-}
-
-void devfs_lookup(ipc_callid_t rid, ipc_call_t *request)
-{
-	libfs_lookup(&devfs_libfs_ops, devfs_reg.fs_handle, rid, request);
-}
-
-void devfs_open_node(ipc_callid_t rid, ipc_call_t *request)
-{
-	libfs_open_node(&devfs_libfs_ops, devfs_reg.fs_handle, rid, request);
-}
-
-void devfs_stat(ipc_callid_t rid, ipc_call_t *request)
-{
-	libfs_stat(&devfs_libfs_ops, devfs_reg.fs_handle, rid, request);
-}
-
-void devfs_read(ipc_callid_t rid, ipc_call_t *request)
-{
-	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
-	aoff64_t pos =
-	    (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request));
-	
-	if (index == 0) {
-		ipc_callid_t callid;
-		size_t size;
-		if (!async_data_read_receive(&callid, &size)) {
-			async_answer_0(callid, EINVAL);
-			async_answer_0(rid, EINVAL);
-			return;
-		}
-		
-		dev_desc_t *desc;
-		size_t count = devmap_get_namespaces(&desc);
-		
-		/* Get rid of root namespace */
-		size_t i;
-		for (i = 0; i < count; i++) {
-			if (str_cmp(desc[i].name, "") == 0) {
-				if (pos >= i)
-					pos++;
-				
-				break;
-			}
-		}
-		
-		if (pos < count) {
-			async_data_read_finalize(callid, desc[pos].name, str_size(desc[pos].name) + 1);
-			free(desc);
-			async_answer_1(rid, EOK, 1);
-			return;
-		}
-		
-		free(desc);
-		pos -= count;
-		
-		/* Search root namespace */
-		devmap_handle_t namespace;
-		if (devmap_namespace_get_handle("", &namespace, 0) == EOK) {
-			count = devmap_get_devices(namespace, &desc);
-			
-			if (pos < count) {
-				async_data_read_finalize(callid, desc[pos].name, str_size(desc[pos].name) + 1);
-				free(desc);
-				async_answer_1(rid, EOK, 1);
-				return;
-			}
-			
-			free(desc);
-		}
-		
-		async_answer_0(callid, ENOENT);
-		async_answer_1(rid, ENOENT, 0);
-		return;
-	}
-	
-	devmap_handle_type_t type = devmap_handle_probe(index);
-	
-	if (type == DEV_HANDLE_NAMESPACE) {
-		/* Namespace directory */
-		ipc_callid_t callid;
-		size_t size;
-		if (!async_data_read_receive(&callid, &size)) {
-			async_answer_0(callid, EINVAL);
-			async_answer_0(rid, EINVAL);
-			return;
-		}
-		
-		dev_desc_t *desc;
-		size_t count = devmap_get_devices(index, &desc);
-		
-		if (pos < count) {
-			async_data_read_finalize(callid, desc[pos].name, str_size(desc[pos].name) + 1);
-			free(desc);
-			async_answer_1(rid, EOK, 1);
-			return;
-		}
-		
-		free(desc);
-		async_answer_0(callid, ENOENT);
-		async_answer_1(rid, ENOENT, 0);
-		return;
-	}
-	
-	if (type == DEV_HANDLE_DEVICE) {
-		/* Device node */
-		
-		unsigned long key[] = {
-			[DEVICES_KEY_HANDLE] = (unsigned long) index
-		};
-		
-		fibril_mutex_lock(&devices_mutex);
-		link_t *lnk = hash_table_find(&devices, key);
-		if (lnk == NULL) {
-			fibril_mutex_unlock(&devices_mutex);
-			async_answer_0(rid, ENOENT);
-			return;
-		}
-		
-		device_t *dev = hash_table_get_instance(lnk, device_t, link);
-		assert(dev->sess);
-		
-		ipc_callid_t callid;
-		if (!async_data_read_receive(&callid, NULL)) {
-			fibril_mutex_unlock(&devices_mutex);
-			async_answer_0(callid, EINVAL);
-			async_answer_0(rid, EINVAL);
-			return;
-		}
-		
-		/* Make a request at the driver */
-		async_exch_t *exch = async_exchange_begin(dev->sess);
-		
-		ipc_call_t answer;
-		aid_t msg = async_send_3(exch, IPC_GET_IMETHOD(*request),
-		    IPC_GET_ARG1(*request), IPC_GET_ARG2(*request),
-		    IPC_GET_ARG3(*request), &answer);
-		
-		/* Forward the IPC_M_DATA_READ request to the driver */
-		async_forward_fast(callid, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
-		
-		async_exchange_end(exch);
-		
-		fibril_mutex_unlock(&devices_mutex);
-		
-		/* Wait for reply from the driver. */
-		sysarg_t rc;
-		async_wait_for(msg, &rc);
-		size_t bytes = IPC_GET_ARG1(answer);
-		
-		/* Driver reply is the final result of the whole operation */
-		async_answer_1(rid, rc, bytes);
-		return;
-	}
-	
-	async_answer_0(rid, ENOENT);
-}
-
-void devfs_write(ipc_callid_t rid, ipc_call_t *request)
-{
-	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
-	if (index == 0) {
-		async_answer_0(rid, ENOTSUP);
-		return;
-	}
-	
-	devmap_handle_type_t type = devmap_handle_probe(index);
-	
-	if (type == DEV_HANDLE_NAMESPACE) {
-		/* Namespace directory */
-		async_answer_0(rid, ENOTSUP);
-		return;
-	}
-	
-	if (type == DEV_HANDLE_DEVICE) {
-		/* Device node */
-		unsigned long key[] = {
-			[DEVICES_KEY_HANDLE] = (unsigned long) index
-		};
-		
-		fibril_mutex_lock(&devices_mutex);
-		link_t *lnk = hash_table_find(&devices, key);
-		if (lnk == NULL) {
-			fibril_mutex_unlock(&devices_mutex);
-			async_answer_0(rid, ENOENT);
-			return;
-		}
-		
-		device_t *dev = hash_table_get_instance(lnk, device_t, link);
-		assert(dev->sess);
-		
-		ipc_callid_t callid;
-		if (!async_data_write_receive(&callid, NULL)) {
-			fibril_mutex_unlock(&devices_mutex);
-			async_answer_0(callid, EINVAL);
-			async_answer_0(rid, EINVAL);
-			return;
-		}
-		
-		/* Make a request at the driver */
-		async_exch_t *exch = async_exchange_begin(dev->sess);
-		
-		ipc_call_t answer;
-		aid_t msg = async_send_3(exch, IPC_GET_IMETHOD(*request),
-		    IPC_GET_ARG1(*request), IPC_GET_ARG2(*request),
-		    IPC_GET_ARG3(*request), &answer);
-		
-		/* Forward the IPC_M_DATA_WRITE request to the driver */
-		async_forward_fast(callid, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
-		
-		async_exchange_end(exch);
-		
-		fibril_mutex_unlock(&devices_mutex);
-		
-		/* Wait for reply from the driver. */
-		sysarg_t rc;
-		async_wait_for(msg, &rc);
-		size_t bytes = IPC_GET_ARG1(answer);
-		
-		/* Driver reply is the final result of the whole operation */
-		async_answer_1(rid, rc, bytes);
-		return;
-	}
-	
-	async_answer_0(rid, ENOENT);
-}
-
-void devfs_truncate(ipc_callid_t rid, ipc_call_t *request)
-{
-	async_answer_0(rid, ENOTSUP);
-}
-
-void devfs_close(ipc_callid_t rid, ipc_call_t *request)
-{
-	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
-	
-	if (index == 0) {
-		async_answer_0(rid, EOK);
-		return;
-	}
-	
-	devmap_handle_type_t type = devmap_handle_probe(index);
-	
-	if (type == DEV_HANDLE_NAMESPACE) {
-		/* Namespace directory */
-		async_answer_0(rid, EOK);
-		return;
-	}
-	
-	if (type == DEV_HANDLE_DEVICE) {
-		unsigned long key[] = {
-			[DEVICES_KEY_HANDLE] = (unsigned long) index
-		};
-		
-		fibril_mutex_lock(&devices_mutex);
-		link_t *lnk = hash_table_find(&devices, key);
-		if (lnk == NULL) {
-			fibril_mutex_unlock(&devices_mutex);
-			async_answer_0(rid, ENOENT);
-			return;
-		}
-		
-		device_t *dev = hash_table_get_instance(lnk, device_t, link);
-		assert(dev->sess);
-		dev->refcount--;
-		
-		if (dev->refcount == 0) {
-			async_hangup(dev->sess);
-			hash_table_remove(&devices, key, DEVICES_KEYS);
-		}
-		
-		fibril_mutex_unlock(&devices_mutex);
-		
-		async_answer_0(rid, EOK);
-		return;
-	}
-	
-	async_answer_0(rid, ENOENT);
-}
-
-void devfs_sync(ipc_callid_t rid, ipc_call_t *request)
-{
-	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
-	
-	if (index == 0) {
-		async_answer_0(rid, EOK);
-		return;
-	}
-	
-	devmap_handle_type_t type = devmap_handle_probe(index);
-	
-	if (type == DEV_HANDLE_NAMESPACE) {
-		/* Namespace directory */
-		async_answer_0(rid, EOK);
-		return;
-	}
-	
-	if (type == DEV_HANDLE_DEVICE) {
-		unsigned long key[] = {
-			[DEVICES_KEY_HANDLE] = (unsigned long) index
-		};
-		
-		fibril_mutex_lock(&devices_mutex);
-		link_t *lnk = hash_table_find(&devices, key);
-		if (lnk == NULL) {
-			fibril_mutex_unlock(&devices_mutex);
-			async_answer_0(rid, ENOENT);
-			return;
-		}
-		
-		device_t *dev = hash_table_get_instance(lnk, device_t, link);
-		assert(dev->sess);
-		
-		/* Make a request at the driver */
-		async_exch_t *exch = async_exchange_begin(dev->sess);
-		
-		ipc_call_t answer;
-		aid_t msg = async_send_2(exch, IPC_GET_IMETHOD(*request),
-		    IPC_GET_ARG1(*request), IPC_GET_ARG2(*request), &answer);
-		
-		async_exchange_end(exch);
-		
-		fibril_mutex_unlock(&devices_mutex);
-		
-		/* Wait for reply from the driver */
-		sysarg_t rc;
-		async_wait_for(msg, &rc);
-		
-		/* Driver reply is the final result of the whole operation */
-		async_answer_0(rid, rc);
-		return;
-	}
-	
-	async_answer_0(rid, ENOENT);
-}
-
-void devfs_destroy(ipc_callid_t rid, ipc_call_t *request)
-{
-	async_answer_0(rid, ENOTSUP);
-}
-
-/**
- * @}
- */
Index: pace/srv/fs/devfs/devfs_ops.h
===================================================================
--- uspace/srv/fs/devfs/devfs_ops.h	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ 	(revision )
@@ -1,59 +1,0 @@
-/*
- * Copyright (c) 2009 Martin Decky
- * 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 fs
- * @{
- */
-
-#ifndef DEVFS_DEVFS_OPS_H_
-#define DEVFS_DEVFS_OPS_H_
-
-#include <ipc/common.h>
-#include <bool.h>
-
-extern bool devfs_init(void);
-
-extern void devfs_mounted(ipc_callid_t, ipc_call_t *);
-extern void devfs_mount(ipc_callid_t, ipc_call_t *);
-extern void devfs_unmounted(ipc_callid_t, ipc_call_t *);
-extern void devfs_unmount(ipc_callid_t, ipc_call_t *);
-extern void devfs_lookup(ipc_callid_t, ipc_call_t *);
-extern void devfs_open_node(ipc_callid_t, ipc_call_t *);
-extern void devfs_stat(ipc_callid_t, ipc_call_t *);
-extern void devfs_sync(ipc_callid_t, ipc_call_t *);
-extern void devfs_read(ipc_callid_t, ipc_call_t *);
-extern void devfs_write(ipc_callid_t, ipc_call_t *);
-extern void devfs_truncate(ipc_callid_t, ipc_call_t *);
-extern void devfs_close(ipc_callid_t, ipc_call_t *);
-extern void devfs_destroy(ipc_callid_t, ipc_call_t *);
-
-#endif
-
-/**
- * @}
- */
Index: uspace/srv/fs/ext2fs/ext2fs_ops.c
===================================================================
--- uspace/srv/fs/ext2fs/ext2fs_ops.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/fs/ext2fs/ext2fs_ops.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -43,5 +43,5 @@
 #include <libext2.h>
 #include <ipc/services.h>
-#include <ipc/devmap.h>
+#include <ipc/loc.h>
 #include <macros.h>
 #include <async.h>
@@ -70,5 +70,5 @@
 typedef struct ext2fs_instance {
 	link_t link;
-	devmap_handle_t devmap_handle;
+	service_id_t service_id;
 	ext2_filesystem_t *filesystem;
 	unsigned int open_nodes_count;
@@ -86,5 +86,5 @@
  * Forward declarations of auxiliary functions
  */
-static int ext2fs_instance_get(devmap_handle_t, ext2fs_instance_t **);
+static int ext2fs_instance_get(service_id_t, ext2fs_instance_t **);
 static void ext2fs_read_directory(ipc_callid_t, ipc_callid_t, aoff64_t,
 	size_t, ext2fs_instance_t *, ext2_inode_ref_t *);
@@ -98,10 +98,10 @@
  * Forward declarations of EXT2 libfs operations.
  */
-static int ext2fs_root_get(fs_node_t **, devmap_handle_t);
+static int ext2fs_root_get(fs_node_t **, service_id_t);
 static int ext2fs_match(fs_node_t **, fs_node_t *, const char *);
-static int ext2fs_node_get(fs_node_t **, devmap_handle_t, fs_index_t);
+static int ext2fs_node_get(fs_node_t **, service_id_t, fs_index_t);
 static int ext2fs_node_open(fs_node_t *);
 static int ext2fs_node_put(fs_node_t *);
-static int ext2fs_create_node(fs_node_t **, devmap_handle_t, int);
+static int ext2fs_create_node(fs_node_t **, service_id_t, int);
 static int ext2fs_destroy_node(fs_node_t *);
 static int ext2fs_link(fs_node_t *, fs_node_t *, const char *);
@@ -114,5 +114,5 @@
 static bool ext2fs_is_directory(fs_node_t *);
 static bool ext2fs_is_file(fs_node_t *node);
-static devmap_handle_t ext2fs_device_get(fs_node_t *node);
+static service_id_t ext2fs_device_get(fs_node_t *node);
 
 /*
@@ -136,6 +136,6 @@
 	ext2fs_node_t *enode = hash_table_get_instance(item, ext2fs_node_t, link);
 	assert(keys > 0);
-	if (enode->instance->devmap_handle !=
-	    ((devmap_handle_t) key[OPEN_NODES_DEV_HANDLE_KEY])) {
+	if (enode->instance->service_id !=
+	    ((service_id_t) key[OPEN_NODES_DEV_HANDLE_KEY])) {
 		return false;
 	}
@@ -182,9 +182,9 @@
 
 /**
- * Find an instance of filesystem for the given devmap_handle
+ * Find an instance of filesystem for the given service_id
  */
-int ext2fs_instance_get(devmap_handle_t devmap_handle, ext2fs_instance_t **inst)
-{
-	EXT2FS_DBG("(%" PRIun ", -)", devmap_handle);
+int ext2fs_instance_get(service_id_t service_id, ext2fs_instance_t **inst)
+{
+	EXT2FS_DBG("(%" PRIun ", -)", service_id);
 	ext2fs_instance_t *tmp;
 	
@@ -200,5 +200,5 @@
 		tmp = list_get_instance(link, ext2fs_instance_t, link);
 		
-		if (tmp->devmap_handle == devmap_handle) {
+		if (tmp->service_id == service_id) {
 			*inst = tmp;
 			fibril_mutex_unlock(&instance_list_mutex);
@@ -215,8 +215,8 @@
 
 
-int ext2fs_root_get(fs_node_t **rfn, devmap_handle_t devmap_handle)
-{
-	EXT2FS_DBG("(-, %" PRIun ")", devmap_handle);
-	return ext2fs_node_get(rfn, devmap_handle, EXT2_INODE_ROOT_INDEX);
+int ext2fs_root_get(fs_node_t **rfn, service_id_t service_id)
+{
+	EXT2FS_DBG("(-, %" PRIun ")", service_id);
+	return ext2fs_node_get(rfn, service_id, EXT2_INODE_ROOT_INDEX);
 }
 
@@ -291,12 +291,12 @@
 
 /** Instantiate a EXT2 in-core node. */
-int ext2fs_node_get(fs_node_t **rfn, devmap_handle_t devmap_handle, fs_index_t index)
-{
-	EXT2FS_DBG("(-,%" PRIun ",%u)", devmap_handle, index);
+int ext2fs_node_get(fs_node_t **rfn, service_id_t service_id, fs_index_t index)
+{
+	EXT2FS_DBG("(-,%" PRIun ",%u)", service_id, index);
 	
 	ext2fs_instance_t *inst = NULL;
 	int rc;
 	
-	rc = ext2fs_instance_get(devmap_handle, &inst);
+	rc = ext2fs_instance_get(service_id, &inst);
 	if (rc != EOK) {
 		return rc;
@@ -319,5 +319,5 @@
 	/* Check if the node is not already open */
 	unsigned long key[] = {
-		[OPEN_NODES_DEV_HANDLE_KEY] = inst->devmap_handle,
+		[OPEN_NODES_DEV_HANDLE_KEY] = inst->service_id,
 		[OPEN_NODES_INODE_KEY] = index,
 	};
@@ -413,5 +413,5 @@
 
 	unsigned long key[] = {
-		[OPEN_NODES_DEV_HANDLE_KEY] = enode->instance->devmap_handle,
+		[OPEN_NODES_DEV_HANDLE_KEY] = enode->instance->service_id,
 		[OPEN_NODES_INODE_KEY] = enode->inode_ref->index,
 	};
@@ -431,5 +431,5 @@
 }
 
-int ext2fs_create_node(fs_node_t **rfn, devmap_handle_t devmap_handle, int flags)
+int ext2fs_create_node(fs_node_t **rfn, service_id_t service_id, int flags)
 {
 	EXT2FS_DBG("");
@@ -564,9 +564,9 @@
 }
 
-devmap_handle_t ext2fs_device_get(fs_node_t *fn)
+service_id_t ext2fs_device_get(fs_node_t *fn)
 {
 	EXT2FS_DBG("");
 	ext2fs_node_t *enode = EXT2FS_NODE(fn);
-	return enode->instance->devmap_handle;
+	return enode->instance->service_id;
 }
 
@@ -600,5 +600,5 @@
 	EXT2FS_DBG("");
 	int rc;
-	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
+	service_id_t service_id = (service_id_t) IPC_GET_ARG1(*request);
 	ext2_filesystem_t *fs;
 	ext2fs_instance_t *inst;
@@ -632,5 +632,5 @@
 	
 	/* Initialize the filesystem  */
-	rc = ext2_filesystem_init(fs, devmap_handle);
+	rc = ext2_filesystem_init(fs, service_id);
 	if (rc != EOK) {
 		free(fs);
@@ -662,5 +662,5 @@
 	/* Initialize instance */
 	link_initialize(&inst->link);
-	inst->devmap_handle = devmap_handle;
+	inst->service_id = service_id;
 	inst->filesystem = fs;
 	inst->open_nodes_count = 0;
@@ -700,9 +700,9 @@
 {
 	EXT2FS_DBG("");
-	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
+	service_id_t service_id = (service_id_t) IPC_GET_ARG1(*request);
 	ext2fs_instance_t *inst;
 	int rc;
 	
-	rc = ext2fs_instance_get(devmap_handle, &inst);
+	rc = ext2fs_instance_get(service_id, &inst);
 	
 	if (rc != EOK) {
@@ -747,5 +747,5 @@
 {
 	EXT2FS_DBG("");
-	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
+	service_id_t service_id = (service_id_t) IPC_GET_ARG1(*request);
 	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
 	aoff64_t pos =
@@ -767,5 +767,5 @@
 	}
 	
-	rc = ext2fs_instance_get(devmap_handle, &inst);
+	rc = ext2fs_instance_get(service_id, &inst);
 	if (rc != EOK) {
 		async_answer_0(callid, rc);
@@ -965,5 +965,5 @@
 	
 	/* Usual case - we need to read a block from device */
-	rc = block_get(&block, inst->devmap_handle, fs_block, BLOCK_FLAGS_NONE);
+	rc = block_get(&block, inst->service_id, fs_block, BLOCK_FLAGS_NONE);
 	if (rc != EOK) {
 		async_answer_0(callid, rc);
@@ -987,5 +987,5 @@
 {
 	EXT2FS_DBG("");
-//	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
+//	service_id_t service_id = (service_id_t) IPC_GET_ARG1(*request);
 //	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
 //	aoff64_t pos =
@@ -999,5 +999,5 @@
 {
 	EXT2FS_DBG("");
-//	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
+//	service_id_t service_id = (service_id_t) IPC_GET_ARG1(*request);
 //	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
 //	aoff64_t size =
@@ -1017,5 +1017,5 @@
 {
 	EXT2FS_DBG("");
-//	devmap_handle_t devmap_handle = (devmap_handle_t)IPC_GET_ARG1(*request);
+//	service_id_t service_id = (service_id_t)IPC_GET_ARG1(*request);
 //	fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
 	
@@ -1039,5 +1039,5 @@
 {
 	EXT2FS_DBG("");
-//	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
+//	service_id_t service_id = (service_id_t) IPC_GET_ARG1(*request);
 //	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
 	
Index: uspace/srv/fs/fat/fat.h
===================================================================
--- uspace/srv/fs/fat/fat.h	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/fs/fat/fat.h	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -175,5 +175,5 @@
 
 	fibril_mutex_t	lock;
-	devmap_handle_t	devmap_handle;
+	service_id_t	service_id;
 	fs_index_t	index;
 	/**
@@ -241,7 +241,7 @@
 extern void fat_sync(ipc_callid_t, ipc_call_t *);
 
-extern int fat_idx_get_new(fat_idx_t **, devmap_handle_t);
-extern fat_idx_t *fat_idx_get_by_pos(devmap_handle_t, fat_cluster_t, unsigned);
-extern fat_idx_t *fat_idx_get_by_index(devmap_handle_t, fs_index_t);
+extern int fat_idx_get_new(fat_idx_t **, service_id_t);
+extern fat_idx_t *fat_idx_get_by_pos(service_id_t, fat_cluster_t, unsigned);
+extern fat_idx_t *fat_idx_get_by_index(service_id_t, fs_index_t);
 extern void fat_idx_destroy(fat_idx_t *);
 extern void fat_idx_hashin(fat_idx_t *);
@@ -250,6 +250,6 @@
 extern int fat_idx_init(void);
 extern void fat_idx_fini(void);
-extern int fat_idx_init_by_devmap_handle(devmap_handle_t);
-extern void fat_idx_fini_by_devmap_handle(devmap_handle_t);
+extern int fat_idx_init_by_service_id(service_id_t);
+extern void fat_idx_fini_by_service_id(service_id_t);
 
 #endif
Index: uspace/srv/fs/fat/fat_fat.c
===================================================================
--- uspace/srv/fs/fat/fat_fat.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/fs/fat/fat_fat.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -71,5 +71,5 @@
  *
  * @param bs		Buffer holding the boot sector for the file.
- * @param devmap_handle	Device handle of the device with the file.
+ * @param service_id	Service ID of the device with the file.
  * @param firstc	First cluster to start the walk with.
  * @param lastc		If non-NULL, output argument hodling the last cluster
@@ -82,5 +82,5 @@
  */
 int 
-fat_cluster_walk(fat_bs_t *bs, devmap_handle_t devmap_handle, fat_cluster_t firstc,
+fat_cluster_walk(fat_bs_t *bs, service_id_t service_id, fat_cluster_t firstc,
     fat_cluster_t *lastc, uint16_t *numc, uint16_t max_clusters)
 {
@@ -109,5 +109,5 @@
 		fidx = clst % (BPS(bs) / sizeof(fat_cluster_t));
 		/* read FAT1 */
-		rc = block_get(&b, devmap_handle, RSCNT(bs) + fsec,
+		rc = block_get(&b, service_id, RSCNT(bs) + fsec,
 		    BLOCK_FLAGS_NONE);
 		if (rc != EOK)
@@ -160,5 +160,5 @@
 		 * when fortunately we have the last cluster number cached.
 		 */
-		return block_get(block, nodep->idx->devmap_handle,
+		return block_get(block, nodep->idx->service_id,
 		    CLBN2PBN(bs, nodep->lastc_cached_value, bn), flags);
 	}
@@ -174,5 +174,5 @@
 
 fall_through:
-	rc = _fat_block_get(block, bs, nodep->idx->devmap_handle, firstc,
+	rc = _fat_block_get(block, bs, nodep->idx->service_id, firstc,
 	    &currc, relbn, flags);
 	if (rc != EOK)
@@ -193,5 +193,5 @@
  * @param block		Pointer to a block pointer for storing result.
  * @param bs		Buffer holding the boot sector of the file system.
- * @param devmap_handle	Device handle of the file system.
+ * @param service_id	Service ID handle of the file system.
  * @param fcl		First cluster used by the file. Can be zero if the file
  *			is empty.
@@ -205,5 +205,5 @@
  */
 int
-_fat_block_get(block_t **block, fat_bs_t *bs, devmap_handle_t devmap_handle,
+_fat_block_get(block_t **block, fat_bs_t *bs, service_id_t service_id,
     fat_cluster_t fcl, fat_cluster_t *clp, aoff64_t bn, int flags)
 {
@@ -222,5 +222,5 @@
 		/* root directory special case */
 		assert(bn < RDS(bs));
-		rc = block_get(block, devmap_handle,
+		rc = block_get(block, service_id,
 		    RSCNT(bs) + FATCNT(bs) * SF(bs) + bn, flags);
 		return rc;
@@ -228,10 +228,10 @@
 
 	max_clusters = bn / SPC(bs);
-	rc = fat_cluster_walk(bs, devmap_handle, fcl, &c, &clusters, max_clusters);
+	rc = fat_cluster_walk(bs, service_id, fcl, &c, &clusters, max_clusters);
 	if (rc != EOK)
 		return rc;
 	assert(clusters == max_clusters);
 
-	rc = block_get(block, devmap_handle, CLBN2PBN(bs, c, bn), flags);
+	rc = block_get(block, service_id, CLBN2PBN(bs, c, bn), flags);
 
 	if (clp)
@@ -281,5 +281,5 @@
 	/* zero out the initial part of the new cluster chain */
 	for (o = boundary; o < pos; o += BPS(bs)) {
-		rc = _fat_block_get(&b, bs, nodep->idx->devmap_handle, mcl,
+		rc = _fat_block_get(&b, bs, nodep->idx->service_id, mcl,
 		    NULL, (o - boundary) / BPS(bs), BLOCK_FLAGS_NOREAD);
 		if (rc != EOK)
@@ -298,5 +298,5 @@
  *
  * @param bs		Buffer holding the boot sector for the file system.
- * @param devmap_handle	Device handle for the file system.
+ * @param service_id	Service ID for the file system.
  * @param clst		Cluster which to get.
  * @param value		Output argument holding the value of the cluster.
@@ -305,5 +305,5 @@
  */
 int
-fat_get_cluster(fat_bs_t *bs, devmap_handle_t devmap_handle, unsigned fatno,
+fat_get_cluster(fat_bs_t *bs, service_id_t service_id, unsigned fatno,
     fat_cluster_t clst, fat_cluster_t *value)
 {
@@ -312,5 +312,5 @@
 	int rc;
 
-	rc = block_get(&b, devmap_handle, RSCNT(bs) + SF(bs) * fatno +
+	rc = block_get(&b, service_id, RSCNT(bs) + SF(bs) * fatno +
 	    (clst * sizeof(fat_cluster_t)) / BPS(bs), BLOCK_FLAGS_NONE);
 	if (rc != EOK)
@@ -327,5 +327,5 @@
  *
  * @param bs		Buffer holding the boot sector for the file system.
- * @param devmap_handle	Device handle for the file system.
+ * @param service_id	Device service ID for the file system.
  * @param fatno		Number of the FAT instance where to make the change.
  * @param clst		Cluster which is to be set.
@@ -335,5 +335,5 @@
  */
 int
-fat_set_cluster(fat_bs_t *bs, devmap_handle_t devmap_handle, unsigned fatno,
+fat_set_cluster(fat_bs_t *bs, service_id_t service_id, unsigned fatno,
     fat_cluster_t clst, fat_cluster_t value)
 {
@@ -343,5 +343,5 @@
 
 	assert(fatno < FATCNT(bs));
-	rc = block_get(&b, devmap_handle, RSCNT(bs) + SF(bs) * fatno +
+	rc = block_get(&b, service_id, RSCNT(bs) + SF(bs) * fatno +
 	    (clst * sizeof(fat_cluster_t)) / BPS(bs), BLOCK_FLAGS_NONE);
 	if (rc != EOK)
@@ -358,5 +358,5 @@
  *
  * @param bs		Buffer holding the boot sector of the file system.
- * @param devmap_handle	Device handle of the file system.
+ * @param service_id	Service ID of the file system.
  * @param lifo		Chain of allocated clusters.
  * @param nclsts	Number of clusters in the lifo chain.
@@ -364,5 +364,5 @@
  * @return		EOK on success or a negative error code.
  */
-int fat_alloc_shadow_clusters(fat_bs_t *bs, devmap_handle_t devmap_handle,
+int fat_alloc_shadow_clusters(fat_bs_t *bs, service_id_t service_id,
     fat_cluster_t *lifo, unsigned nclsts)
 {
@@ -373,5 +373,5 @@
 	for (fatno = FAT1 + 1; fatno < bs->fatcnt; fatno++) {
 		for (c = 0; c < nclsts; c++) {
-			rc = fat_set_cluster(bs, devmap_handle, fatno, lifo[c],
+			rc = fat_set_cluster(bs, service_id, fatno, lifo[c],
 			    c == 0 ? FAT_CLST_LAST1 : lifo[c - 1]);
 			if (rc != EOK)
@@ -391,5 +391,5 @@
  *
  * @param bs		Buffer holding the boot sector of the file system.
- * @param devmap_handle	Device handle of the file system.
+ * @param service_id	Device service ID of the file system.
  * @param nclsts	Number of clusters to allocate.
  * @param mcl		Output parameter where the first cluster in the chain
@@ -401,5 +401,5 @@
  */
 int
-fat_alloc_clusters(fat_bs_t *bs, devmap_handle_t devmap_handle, unsigned nclsts,
+fat_alloc_clusters(fat_bs_t *bs, service_id_t service_id, unsigned nclsts,
     fat_cluster_t *mcl, fat_cluster_t *lcl)
 {
@@ -419,5 +419,5 @@
 	fibril_mutex_lock(&fat_alloc_lock);
 	for (b = 0, cl = 0; b < SF(bs); b++) {
-		rc = block_get(&blk, devmap_handle, RSCNT(bs) + b,
+		rc = block_get(&blk, service_id, RSCNT(bs) + b,
 		    BLOCK_FLAGS_NONE);
 		if (rc != EOK)
@@ -458,5 +458,5 @@
 					/* update the shadow copies of FAT */
 					rc = fat_alloc_shadow_clusters(bs,
-					    devmap_handle, lifo, nclsts);
+					    service_id, lifo, nclsts);
 					if (rc != EOK)
 						goto error;
@@ -485,5 +485,5 @@
 	 */
 	while (found--) {
-		rc = fat_set_cluster(bs, devmap_handle, FAT1, lifo[found],
+		rc = fat_set_cluster(bs, service_id, FAT1, lifo[found],
 		    FAT_CLST_RES0);
 		if (rc != EOK) {
@@ -500,5 +500,5 @@
  *
  * @param bs		Buffer hodling the boot sector of the file system.
- * @param devmap_handle	Device handle of the file system.
+ * @param service_id	Device service ID of the file system.
  * @param firstc	First cluster in the chain which is to be freed.
  *
@@ -506,5 +506,5 @@
  */
 int
-fat_free_clusters(fat_bs_t *bs, devmap_handle_t devmap_handle, fat_cluster_t firstc)
+fat_free_clusters(fat_bs_t *bs, service_id_t service_id, fat_cluster_t firstc)
 {
 	unsigned fatno;
@@ -515,9 +515,9 @@
 	while (firstc < FAT_CLST_LAST1) {
 		assert(firstc >= FAT_CLST_FIRST && firstc < FAT_CLST_BAD);
-		rc = fat_get_cluster(bs, devmap_handle, FAT1, firstc, &nextc);
+		rc = fat_get_cluster(bs, service_id, FAT1, firstc, &nextc);
 		if (rc != EOK)
 			return rc;
 		for (fatno = FAT1; fatno < bs->fatcnt; fatno++) {
-			rc = fat_set_cluster(bs, devmap_handle, fatno, firstc,
+			rc = fat_set_cluster(bs, service_id, fatno, firstc,
 			    FAT_CLST_RES0);
 			if (rc != EOK)
@@ -544,5 +544,5 @@
     fat_cluster_t lcl)
 {
-	devmap_handle_t devmap_handle = nodep->idx->devmap_handle;
+	service_id_t service_id = nodep->idx->service_id;
 	fat_cluster_t lastc;
 	uint8_t fatno;
@@ -558,5 +558,5 @@
 			nodep->lastc_cached_valid = false;
 		} else {
-			rc = fat_cluster_walk(bs, devmap_handle, nodep->firstc,
+			rc = fat_cluster_walk(bs, service_id, nodep->firstc,
 			    &lastc, NULL, (uint16_t) -1);
 			if (rc != EOK)
@@ -565,5 +565,5 @@
 
 		for (fatno = FAT1; fatno < bs->fatcnt; fatno++) {
-			rc = fat_set_cluster(bs, nodep->idx->devmap_handle, fatno,
+			rc = fat_set_cluster(bs, nodep->idx->service_id, fatno,
 			    lastc, mcl);
 			if (rc != EOK)
@@ -591,5 +591,5 @@
 {
 	int rc;
-	devmap_handle_t devmap_handle = nodep->idx->devmap_handle;
+	service_id_t service_id = nodep->idx->service_id;
 
 	/*
@@ -602,5 +602,5 @@
 	if (lcl == FAT_CLST_RES0) {
 		/* The node will have zero size and no clusters allocated. */
-		rc = fat_free_clusters(bs, devmap_handle, nodep->firstc);
+		rc = fat_free_clusters(bs, service_id, nodep->firstc);
 		if (rc != EOK)
 			return rc;
@@ -611,5 +611,5 @@
 		unsigned fatno;
 
-		rc = fat_get_cluster(bs, devmap_handle, FAT1, lcl, &nextc);
+		rc = fat_get_cluster(bs, service_id, FAT1, lcl, &nextc);
 		if (rc != EOK)
 			return rc;
@@ -617,5 +617,5 @@
 		/* Terminate the cluster chain in all copies of FAT. */
 		for (fatno = FAT1; fatno < bs->fatcnt; fatno++) {
-			rc = fat_set_cluster(bs, devmap_handle, fatno, lcl,
+			rc = fat_set_cluster(bs, service_id, fatno, lcl,
 			    FAT_CLST_LAST1);
 			if (rc != EOK)
@@ -624,5 +624,5 @@
 
 		/* Free all following clusters. */
-		rc = fat_free_clusters(bs, devmap_handle, nextc);
+		rc = fat_free_clusters(bs, service_id, nextc);
 		if (rc != EOK)
 			return rc;
@@ -639,5 +639,5 @@
 
 int
-fat_zero_cluster(struct fat_bs *bs, devmap_handle_t devmap_handle, fat_cluster_t c)
+fat_zero_cluster(struct fat_bs *bs, service_id_t service_id, fat_cluster_t c)
 {
 	int i;
@@ -646,5 +646,5 @@
 
 	for (i = 0; i < SPC(bs); i++) {
-		rc = _fat_block_get(&b, bs, devmap_handle, c, NULL, i,
+		rc = _fat_block_get(&b, bs, service_id, c, NULL, i,
 		    BLOCK_FLAGS_NOREAD);
 		if (rc != EOK)
@@ -666,5 +666,5 @@
  * does not contain a fat file system.
  */
-int fat_sanity_check(fat_bs_t *bs, devmap_handle_t devmap_handle)
+int fat_sanity_check(fat_bs_t *bs, service_id_t service_id)
 {
 	fat_cluster_t e0, e1;
@@ -707,9 +707,9 @@
 
 	for (fat_no = 0; fat_no < bs->fatcnt; fat_no++) {
-		rc = fat_get_cluster(bs, devmap_handle, fat_no, 0, &e0);
+		rc = fat_get_cluster(bs, service_id, fat_no, 0, &e0);
 		if (rc != EOK)
 			return EIO;
 
-		rc = fat_get_cluster(bs, devmap_handle, fat_no, 1, &e1);
+		rc = fat_get_cluster(bs, service_id, fat_no, 1, &e1);
 		if (rc != EOK)
 			return EIO;
Index: uspace/srv/fs/fat/fat_fat.h
===================================================================
--- uspace/srv/fs/fat/fat_fat.h	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/fs/fat/fat_fat.h	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -61,10 +61,10 @@
 #define fat_clusters_get(numc, bs, dh, fc) \
     fat_cluster_walk((bs), (dh), (fc), NULL, (numc), (uint16_t) -1)
-extern int fat_cluster_walk(struct fat_bs *, devmap_handle_t, fat_cluster_t,
+extern int fat_cluster_walk(struct fat_bs *, service_id_t, fat_cluster_t,
     fat_cluster_t *, uint16_t *, uint16_t);
 
 extern int fat_block_get(block_t **, struct fat_bs *, struct fat_node *,
     aoff64_t, int);
-extern int _fat_block_get(block_t **, struct fat_bs *, devmap_handle_t,
+extern int _fat_block_get(block_t **, struct fat_bs *, service_id_t,
     fat_cluster_t, fat_cluster_t *, aoff64_t, int);
 
@@ -73,17 +73,17 @@
 extern int fat_chop_clusters(struct fat_bs *, struct fat_node *,
     fat_cluster_t);
-extern int fat_alloc_clusters(struct fat_bs *, devmap_handle_t, unsigned,
+extern int fat_alloc_clusters(struct fat_bs *, service_id_t, unsigned,
     fat_cluster_t *, fat_cluster_t *);
-extern int fat_free_clusters(struct fat_bs *, devmap_handle_t, fat_cluster_t);
-extern int fat_alloc_shadow_clusters(struct fat_bs *, devmap_handle_t,
+extern int fat_free_clusters(struct fat_bs *, service_id_t, fat_cluster_t);
+extern int fat_alloc_shadow_clusters(struct fat_bs *, service_id_t,
     fat_cluster_t *, unsigned);
-extern int fat_get_cluster(struct fat_bs *, devmap_handle_t, unsigned,
+extern int fat_get_cluster(struct fat_bs *, service_id_t, unsigned,
     fat_cluster_t, fat_cluster_t *);
-extern int fat_set_cluster(struct fat_bs *, devmap_handle_t, unsigned,
+extern int fat_set_cluster(struct fat_bs *, service_id_t, unsigned,
     fat_cluster_t, fat_cluster_t);
 extern int fat_fill_gap(struct fat_bs *, struct fat_node *, fat_cluster_t,
     aoff64_t);
-extern int fat_zero_cluster(struct fat_bs *, devmap_handle_t, fat_cluster_t);
-extern int fat_sanity_check(struct fat_bs *, devmap_handle_t);
+extern int fat_zero_cluster(struct fat_bs *, service_id_t, fat_cluster_t);
+extern int fat_sanity_check(struct fat_bs *, service_id_t);
 
 #endif
Index: uspace/srv/fs/fat/fat_idx.c
===================================================================
--- uspace/srv/fs/fat/fat_idx.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/fs/fat/fat_idx.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -59,5 +59,5 @@
 typedef struct {
 	link_t		link;
-	devmap_handle_t devmap_handle;
+	service_id_t	service_id;
 
 	/** Next unassigned index. */
@@ -76,8 +76,8 @@
 static LIST_INITIALIZE(unused_list);
 
-static void unused_initialize(unused_t *u, devmap_handle_t devmap_handle)
+static void unused_initialize(unused_t *u, service_id_t service_id)
 {
 	link_initialize(&u->link);
-	u->devmap_handle = devmap_handle;
+	u->service_id = service_id;
 	u->next = 0;
 	u->remaining = ((uint64_t)((fs_index_t)-1)) + 1;
@@ -85,5 +85,5 @@
 }
 
-static unused_t *unused_find(devmap_handle_t devmap_handle, bool lock)
+static unused_t *unused_find(service_id_t service_id, bool lock)
 {
 	unused_t *u;
@@ -94,5 +94,5 @@
 	list_foreach(unused_list, l) {
 		u = list_get_instance(l, unused_t, link);
-		if (u->devmap_handle == devmap_handle) 
+		if (u->service_id == service_id) 
 			return u;
 	}
@@ -108,5 +108,5 @@
 /**
  * Global hash table of all used fat_idx_t structures.
- * The index structures are hashed by the devmap_handle, parent node's first
+ * The index structures are hashed by the service_id, parent node's first
  * cluster and index within the parent directory.
  */ 
@@ -122,5 +122,5 @@
 static hash_index_t pos_hash(unsigned long key[])
 {
-	devmap_handle_t devmap_handle = (devmap_handle_t)key[UPH_DH_KEY];
+	service_id_t service_id = (service_id_t)key[UPH_DH_KEY];
 	fat_cluster_t pfc = (fat_cluster_t)key[UPH_PFC_KEY];
 	unsigned pdi = (unsigned)key[UPH_PDI_KEY];
@@ -142,5 +142,5 @@
 	h |= (pdi & ((1 << (UPH_BUCKETS_LOG / 4)) - 1)) <<
 	    (UPH_BUCKETS_LOG / 2); 
-	h |= (devmap_handle & ((1 << (UPH_BUCKETS_LOG / 4)) - 1)) <<
+	h |= (service_id & ((1 << (UPH_BUCKETS_LOG / 4)) - 1)) <<
 	    (3 * (UPH_BUCKETS_LOG / 4));
 
@@ -150,5 +150,5 @@
 static int pos_compare(unsigned long key[], hash_count_t keys, link_t *item)
 {
-	devmap_handle_t devmap_handle = (devmap_handle_t)key[UPH_DH_KEY];
+	service_id_t service_id = (service_id_t)key[UPH_DH_KEY];
 	fat_cluster_t pfc;
 	unsigned pdi;
@@ -157,9 +157,9 @@
 	switch (keys) {
 	case 1:
-		return (devmap_handle == fidx->devmap_handle);
+		return (service_id == fidx->service_id);
 	case 3:
 		pfc = (fat_cluster_t) key[UPH_PFC_KEY];
 		pdi = (unsigned) key[UPH_PDI_KEY];
-		return (devmap_handle == fidx->devmap_handle) && (pfc == fidx->pfc) &&
+		return (service_id == fidx->service_id) && (pfc == fidx->pfc) &&
 		    (pdi == fidx->pdi);
 	default:
@@ -183,5 +183,5 @@
 /**
  * Global hash table of all used fat_idx_t structures.
- * The index structures are hashed by the devmap_handle and index.
+ * The index structures are hashed by the service_id and index.
  */
 static hash_table_t ui_hash;
@@ -195,10 +195,10 @@
 static hash_index_t idx_hash(unsigned long key[])
 {
-	devmap_handle_t devmap_handle = (devmap_handle_t)key[UIH_DH_KEY];
+	service_id_t service_id = (service_id_t)key[UIH_DH_KEY];
 	fs_index_t index = (fs_index_t)key[UIH_INDEX_KEY];
 
 	hash_index_t h;
 
-	h = devmap_handle & ((1 << (UIH_BUCKETS_LOG / 2)) - 1);
+	h = service_id & ((1 << (UIH_BUCKETS_LOG / 2)) - 1);
 	h |= (index & ((1 << (UIH_BUCKETS_LOG / 2)) - 1)) <<
 	    (UIH_BUCKETS_LOG / 2);
@@ -209,5 +209,5 @@
 static int idx_compare(unsigned long key[], hash_count_t keys, link_t *item)
 {
-	devmap_handle_t devmap_handle = (devmap_handle_t)key[UIH_DH_KEY];
+	service_id_t service_id = (service_id_t)key[UIH_DH_KEY];
 	fs_index_t index;
 	fat_idx_t *fidx = list_get_instance(item, fat_idx_t, uih_link);
@@ -215,8 +215,8 @@
 	switch (keys) {
 	case 1:
-		return (devmap_handle == fidx->devmap_handle);
+		return (service_id == fidx->service_id);
 	case 2:
 		index = (fs_index_t) key[UIH_INDEX_KEY];
-		return (devmap_handle == fidx->devmap_handle) &&
+		return (service_id == fidx->service_id) &&
 		    (index == fidx->index);
 	default:
@@ -241,10 +241,10 @@
 
 /** Allocate a VFS index which is not currently in use. */
-static bool fat_index_alloc(devmap_handle_t devmap_handle, fs_index_t *index)
+static bool fat_index_alloc(service_id_t service_id, fs_index_t *index)
 {
 	unused_t *u;
 	
 	assert(index);
-	u = unused_find(devmap_handle, true);
+	u = unused_find(service_id, true);
 	if (!u)
 		return false;	
@@ -303,9 +303,9 @@
 
 /** Free a VFS index, which is no longer in use. */
-static void fat_index_free(devmap_handle_t devmap_handle, fs_index_t index)
+static void fat_index_free(service_id_t service_id, fs_index_t index)
 {
 	unused_t *u;
 
-	u = unused_find(devmap_handle, true);
+	u = unused_find(service_id, true);
 	assert(u);
 
@@ -365,5 +365,5 @@
 }
 
-static int fat_idx_create(fat_idx_t **fidxp, devmap_handle_t devmap_handle)
+static int fat_idx_create(fat_idx_t **fidxp, service_id_t service_id)
 {
 	fat_idx_t *fidx;
@@ -372,5 +372,5 @@
 	if (!fidx) 
 		return ENOMEM;
-	if (!fat_index_alloc(devmap_handle, &fidx->index)) {
+	if (!fat_index_alloc(service_id, &fidx->index)) {
 		free(fidx);
 		return ENOSPC;
@@ -380,5 +380,5 @@
 	link_initialize(&fidx->uih_link);
 	fibril_mutex_initialize(&fidx->lock);
-	fidx->devmap_handle = devmap_handle;
+	fidx->service_id = service_id;
 	fidx->pfc = FAT_CLST_RES0;	/* no parent yet */
 	fidx->pdi = 0;
@@ -389,5 +389,5 @@
 }
 
-int fat_idx_get_new(fat_idx_t **fidxp, devmap_handle_t devmap_handle)
+int fat_idx_get_new(fat_idx_t **fidxp, service_id_t service_id)
 {
 	fat_idx_t *fidx;
@@ -395,5 +395,5 @@
 
 	fibril_mutex_lock(&used_lock);
-	rc = fat_idx_create(&fidx, devmap_handle);
+	rc = fat_idx_create(&fidx, service_id);
 	if (rc != EOK) {
 		fibril_mutex_unlock(&used_lock);
@@ -402,5 +402,5 @@
 		
 	unsigned long ikey[] = {
-		[UIH_DH_KEY] = devmap_handle,
+		[UIH_DH_KEY] = service_id,
 		[UIH_INDEX_KEY] = fidx->index,
 	};
@@ -415,10 +415,10 @@
 
 fat_idx_t *
-fat_idx_get_by_pos(devmap_handle_t devmap_handle, fat_cluster_t pfc, unsigned pdi)
+fat_idx_get_by_pos(service_id_t service_id, fat_cluster_t pfc, unsigned pdi)
 {
 	fat_idx_t *fidx;
 	link_t *l;
 	unsigned long pkey[] = {
-		[UPH_DH_KEY] = devmap_handle,
+		[UPH_DH_KEY] = service_id,
 		[UPH_PFC_KEY] = pfc,
 		[UPH_PDI_KEY] = pdi,
@@ -432,5 +432,5 @@
 		int rc;
 
-		rc = fat_idx_create(&fidx, devmap_handle);
+		rc = fat_idx_create(&fidx, service_id);
 		if (rc != EOK) {
 			fibril_mutex_unlock(&used_lock);
@@ -439,5 +439,5 @@
 		
 		unsigned long ikey[] = {
-			[UIH_DH_KEY] = devmap_handle,
+			[UIH_DH_KEY] = service_id,
 			[UIH_INDEX_KEY] = fidx->index,
 		};
@@ -458,5 +458,5 @@
 {
 	unsigned long pkey[] = {
-		[UPH_DH_KEY] = idx->devmap_handle,
+		[UPH_DH_KEY] = idx->service_id,
 		[UPH_PFC_KEY] = idx->pfc,
 		[UPH_PDI_KEY] = idx->pdi,
@@ -471,5 +471,5 @@
 {
 	unsigned long pkey[] = {
-		[UPH_DH_KEY] = idx->devmap_handle,
+		[UPH_DH_KEY] = idx->service_id,
 		[UPH_PFC_KEY] = idx->pfc,
 		[UPH_PDI_KEY] = idx->pdi,
@@ -482,10 +482,10 @@
 
 fat_idx_t *
-fat_idx_get_by_index(devmap_handle_t devmap_handle, fs_index_t index)
+fat_idx_get_by_index(service_id_t service_id, fs_index_t index)
 {
 	fat_idx_t *fidx = NULL;
 	link_t *l;
 	unsigned long ikey[] = {
-		[UIH_DH_KEY] = devmap_handle,
+		[UIH_DH_KEY] = service_id,
 		[UIH_INDEX_KEY] = index,
 	};
@@ -509,8 +509,8 @@
 {
 	unsigned long ikey[] = {
-		[UIH_DH_KEY] = idx->devmap_handle,
+		[UIH_DH_KEY] = idx->service_id,
 		[UIH_INDEX_KEY] = idx->index,
 	};
-	devmap_handle_t devmap_handle = idx->devmap_handle;
+	service_id_t service_id = idx->service_id;
 	fs_index_t index = idx->index;
 
@@ -526,5 +526,5 @@
 	fibril_mutex_unlock(&used_lock);
 	/* Release the VFS index. */
-	fat_index_free(devmap_handle, index);
+	fat_index_free(service_id, index);
 	/* The index structure itself is freed in idx_remove_callback(). */
 }
@@ -548,5 +548,5 @@
 }
 
-int fat_idx_init_by_devmap_handle(devmap_handle_t devmap_handle)
+int fat_idx_init_by_service_id(service_id_t service_id)
 {
 	unused_t *u;
@@ -556,7 +556,7 @@
 	if (!u)
 		return ENOMEM;
-	unused_initialize(u, devmap_handle);
+	unused_initialize(u, service_id);
 	fibril_mutex_lock(&unused_lock);
-	if (!unused_find(devmap_handle, false)) {
+	if (!unused_find(service_id, false)) {
 		list_append(&u->link, &unused_list);
 	} else {
@@ -568,11 +568,11 @@
 }
 
-void fat_idx_fini_by_devmap_handle(devmap_handle_t devmap_handle)
+void fat_idx_fini_by_service_id(service_id_t service_id)
 {
 	unsigned long ikey[] = {
-		[UIH_DH_KEY] = devmap_handle
+		[UIH_DH_KEY] = service_id
 	};
 	unsigned long pkey[] = {
-		[UPH_DH_KEY] = devmap_handle
+		[UPH_DH_KEY] = service_id
 	};
 
@@ -590,5 +590,5 @@
 	 * Free the unused and freed structures for this instance.
 	 */
-	unused_t *u = unused_find(devmap_handle, true);
+	unused_t *u = unused_find(service_id, true);
 	assert(u);
 	list_remove(&u->link);
Index: uspace/srv/fs/fat/fat_ops.c
===================================================================
--- uspace/srv/fs/fat/fat_ops.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/fs/fat/fat_ops.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -43,5 +43,5 @@
 #include <libblock.h>
 #include <ipc/services.h>
-#include <ipc/devmap.h>
+#include <ipc/loc.h>
 #include <macros.h>
 #include <async.h>
@@ -72,10 +72,10 @@
  * Forward declarations of FAT libfs operations.
  */
-static int fat_root_get(fs_node_t **, devmap_handle_t);
+static int fat_root_get(fs_node_t **, service_id_t);
 static int fat_match(fs_node_t **, fs_node_t *, const char *);
-static int fat_node_get(fs_node_t **, devmap_handle_t, fs_index_t);
+static int fat_node_get(fs_node_t **, service_id_t, fs_index_t);
 static int fat_node_open(fs_node_t *);
 static int fat_node_put(fs_node_t *);
-static int fat_create_node(fs_node_t **, devmap_handle_t, int);
+static int fat_create_node(fs_node_t **, service_id_t, int);
 static int fat_destroy_node(fs_node_t *);
 static int fat_link(fs_node_t *, fs_node_t *, const char *);
@@ -88,5 +88,5 @@
 static bool fat_is_directory(fs_node_t *);
 static bool fat_is_file(fs_node_t *node);
-static devmap_handle_t fat_device_get(fs_node_t *node);
+static service_id_t fat_device_get(fs_node_t *node);
 
 /*
@@ -120,8 +120,8 @@
 	assert(node->dirty);
 
-	bs = block_bb_get(node->idx->devmap_handle);
+	bs = block_bb_get(node->idx->service_id);
 	
 	/* Read the block that contains the dentry of interest. */
-	rc = _fat_block_get(&b, bs, node->idx->devmap_handle, node->idx->pfc,
+	rc = _fat_block_get(&b, bs, node->idx->service_id, node->idx->pfc,
 	    NULL, (node->idx->pdi * sizeof(fat_dentry_t)) / BPS(bs),
 	    BLOCK_FLAGS_NONE);
@@ -145,5 +145,5 @@
 }
 
-static int fat_node_fini_by_devmap_handle(devmap_handle_t devmap_handle)
+static int fat_node_fini_by_service_id(service_id_t service_id)
 {
 	fat_node_t *nodep;
@@ -169,5 +169,5 @@
 			goto restart;
 		}
-		if (nodep->idx->devmap_handle != devmap_handle) {
+		if (nodep->idx->service_id != service_id) {
 			fibril_mutex_unlock(&nodep->idx->lock);
 			fibril_mutex_unlock(&nodep->lock);
@@ -299,8 +299,8 @@
 		return rc;
 
-	bs = block_bb_get(idxp->devmap_handle);
+	bs = block_bb_get(idxp->service_id);
 
 	/* Read the block that contains the dentry of interest. */
-	rc = _fat_block_get(&b, bs, idxp->devmap_handle, idxp->pfc, NULL,
+	rc = _fat_block_get(&b, bs, idxp->service_id, idxp->pfc, NULL,
 	    (idxp->pdi * sizeof(fat_dentry_t)) / BPS(bs), BLOCK_FLAGS_NONE);
 	if (rc != EOK) {
@@ -323,5 +323,5 @@
 		 */
 		uint16_t clusters;
-		rc = fat_clusters_get(&clusters, bs, idxp->devmap_handle,
+		rc = fat_clusters_get(&clusters, bs, idxp->service_id,
 		    uint16_t_le2host(d->firstc));
 		if (rc != EOK) {
@@ -357,7 +357,7 @@
  */
 
-int fat_root_get(fs_node_t **rfn, devmap_handle_t devmap_handle)
-{
-	return fat_node_get(rfn, devmap_handle, 0);
+int fat_root_get(fs_node_t **rfn, service_id_t service_id)
+{
+	return fat_node_get(rfn, service_id, 0);
 }
 
@@ -370,13 +370,13 @@
 	unsigned blocks;
 	fat_dentry_t *d;
-	devmap_handle_t devmap_handle;
+	service_id_t service_id;
 	block_t *b;
 	int rc;
 
 	fibril_mutex_lock(&parentp->idx->lock);
-	devmap_handle = parentp->idx->devmap_handle;
+	service_id = parentp->idx->service_id;
 	fibril_mutex_unlock(&parentp->idx->lock);
 
-	bs = block_bb_get(devmap_handle);
+	bs = block_bb_get(service_id);
 	blocks = parentp->size / BPS(bs);
 	for (i = 0; i < blocks; i++) {
@@ -403,5 +403,5 @@
 				/* hit */
 				fat_node_t *nodep;
-				fat_idx_t *idx = fat_idx_get_by_pos(devmap_handle,
+				fat_idx_t *idx = fat_idx_get_by_pos(service_id,
 				    parentp->firstc, i * DPS(bs) + j);
 				if (!idx) {
@@ -436,5 +436,5 @@
 
 /** Instantiate a FAT in-core node. */
-int fat_node_get(fs_node_t **rfn, devmap_handle_t devmap_handle, fs_index_t index)
+int fat_node_get(fs_node_t **rfn, service_id_t service_id, fs_index_t index)
 {
 	fat_node_t *nodep;
@@ -442,5 +442,5 @@
 	int rc;
 
-	idxp = fat_idx_get_by_index(devmap_handle, index);
+	idxp = fat_idx_get_by_index(service_id, index);
 	if (!idxp) {
 		*rfn = NULL;
@@ -493,5 +493,5 @@
 }
 
-int fat_create_node(fs_node_t **rfn, devmap_handle_t devmap_handle, int flags)
+int fat_create_node(fs_node_t **rfn, service_id_t service_id, int flags)
 {
 	fat_idx_t *idxp;
@@ -501,14 +501,14 @@
 	int rc;
 
-	bs = block_bb_get(devmap_handle);
+	bs = block_bb_get(service_id);
 	if (flags & L_DIRECTORY) {
 		/* allocate a cluster */
-		rc = fat_alloc_clusters(bs, devmap_handle, 1, &mcl, &lcl);
+		rc = fat_alloc_clusters(bs, service_id, 1, &mcl, &lcl);
 		if (rc != EOK)
 			return rc;
 		/* populate the new cluster with unused dentries */
-		rc = fat_zero_cluster(bs, devmap_handle, mcl);
+		rc = fat_zero_cluster(bs, service_id, mcl);
 		if (rc != EOK) {
-			(void) fat_free_clusters(bs, devmap_handle, mcl);
+			(void) fat_free_clusters(bs, service_id, mcl);
 			return rc;
 		}
@@ -517,10 +517,10 @@
 	rc = fat_node_get_new(&nodep);
 	if (rc != EOK) {
-		(void) fat_free_clusters(bs, devmap_handle, mcl);
+		(void) fat_free_clusters(bs, service_id, mcl);
 		return rc;
 	}
-	rc = fat_idx_get_new(&idxp, devmap_handle);
-	if (rc != EOK) {
-		(void) fat_free_clusters(bs, devmap_handle, mcl);	
+	rc = fat_idx_get_new(&idxp, service_id);
+	if (rc != EOK) {
+		(void) fat_free_clusters(bs, service_id, mcl);	
 		(void) fat_node_put(FS_NODE(nodep));
 		return rc;
@@ -571,9 +571,9 @@
 	assert(!has_children);
 
-	bs = block_bb_get(nodep->idx->devmap_handle);
+	bs = block_bb_get(nodep->idx->service_id);
 	if (nodep->firstc != FAT_CLST_RES0) {
 		assert(nodep->size);
 		/* Free all clusters allocated to the node. */
-		rc = fat_free_clusters(bs, nodep->idx->devmap_handle,
+		rc = fat_free_clusters(bs, nodep->idx->service_id,
 		    nodep->firstc);
 	}
@@ -621,5 +621,5 @@
 	
 	fibril_mutex_lock(&parentp->idx->lock);
-	bs = block_bb_get(parentp->idx->devmap_handle);
+	bs = block_bb_get(parentp->idx->service_id);
 
 	blocks = parentp->size / BPS(bs);
@@ -660,12 +660,12 @@
 		return ENOSPC;
 	}
-	rc = fat_alloc_clusters(bs, parentp->idx->devmap_handle, 1, &mcl, &lcl);
+	rc = fat_alloc_clusters(bs, parentp->idx->service_id, 1, &mcl, &lcl);
 	if (rc != EOK) {
 		fibril_mutex_unlock(&parentp->idx->lock);
 		return rc;
 	}
-	rc = fat_zero_cluster(bs, parentp->idx->devmap_handle, mcl);
-	if (rc != EOK) {
-		(void) fat_free_clusters(bs, parentp->idx->devmap_handle, mcl);
+	rc = fat_zero_cluster(bs, parentp->idx->service_id, mcl);
+	if (rc != EOK) {
+		(void) fat_free_clusters(bs, parentp->idx->service_id, mcl);
 		fibril_mutex_unlock(&parentp->idx->lock);
 		return rc;
@@ -673,5 +673,5 @@
 	rc = fat_append_clusters(bs, parentp, mcl, lcl);
 	if (rc != EOK) {
-		(void) fat_free_clusters(bs, parentp->idx->devmap_handle, mcl);
+		(void) fat_free_clusters(bs, parentp->idx->service_id, mcl);
 		fibril_mutex_unlock(&parentp->idx->lock);
 		return rc;
@@ -790,7 +790,7 @@
 	assert(childp->lnkcnt == 1);
 	fibril_mutex_lock(&childp->idx->lock);
-	bs = block_bb_get(childp->idx->devmap_handle);
-
-	rc = _fat_block_get(&b, bs, childp->idx->devmap_handle, childp->idx->pfc,
+	bs = block_bb_get(childp->idx->service_id);
+
+	rc = _fat_block_get(&b, bs, childp->idx->service_id, childp->idx->pfc,
 	    NULL, (childp->idx->pdi * sizeof(fat_dentry_t)) / BPS(bs),
 	    BLOCK_FLAGS_NONE);
@@ -842,5 +842,5 @@
 	
 	fibril_mutex_lock(&nodep->idx->lock);
-	bs = block_bb_get(nodep->idx->devmap_handle);
+	bs = block_bb_get(nodep->idx->service_id);
 
 	blocks = nodep->size / BPS(bs);
@@ -916,5 +916,5 @@
 }
 
-devmap_handle_t fat_device_get(fs_node_t *node)
+service_id_t fat_device_get(fs_node_t *node)
 {
 	return 0;
@@ -948,5 +948,5 @@
 void fat_mounted(ipc_callid_t rid, ipc_call_t *request)
 {
-	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
+	service_id_t service_id = (service_id_t) IPC_GET_ARG1(*request);
 	enum cache_mode cmode;
 	fat_bs_t *bs;
@@ -970,5 +970,5 @@
 
 	/* initialize libblock */
-	rc = block_init(EXCHANGE_SERIALIZE, devmap_handle, BS_SIZE);
+	rc = block_init(EXCHANGE_SERIALIZE, service_id, BS_SIZE);
 	if (rc != EOK) {
 		async_answer_0(rid, rc);
@@ -977,7 +977,7 @@
 
 	/* prepare the boot block */
-	rc = block_bb_read(devmap_handle, BS_BLOCK);
-	if (rc != EOK) {
-		block_fini(devmap_handle);
+	rc = block_bb_read(service_id, BS_BLOCK);
+	if (rc != EOK) {
+		block_fini(service_id);
 		async_answer_0(rid, rc);
 		return;
@@ -985,8 +985,8 @@
 
 	/* get the buffer with the boot sector */
-	bs = block_bb_get(devmap_handle);
+	bs = block_bb_get(service_id);
 	
 	if (BPS(bs) != BS_SIZE) {
-		block_fini(devmap_handle);
+		block_fini(service_id);
 		async_answer_0(rid, ENOTSUP);
 		return;
@@ -994,7 +994,7 @@
 
 	/* Initialize the block cache */
-	rc = block_cache_init(devmap_handle, BPS(bs), 0 /* XXX */, cmode);
-	if (rc != EOK) {
-		block_fini(devmap_handle);
+	rc = block_cache_init(service_id, BPS(bs), 0 /* XXX */, cmode);
+	if (rc != EOK) {
+		block_fini(service_id);
 		async_answer_0(rid, rc);
 		return;
@@ -1002,16 +1002,16 @@
 
 	/* Do some simple sanity checks on the file system. */
-	rc = fat_sanity_check(bs, devmap_handle);
-	if (rc != EOK) {
-		(void) block_cache_fini(devmap_handle);
-		block_fini(devmap_handle);
+	rc = fat_sanity_check(bs, service_id);
+	if (rc != EOK) {
+		(void) block_cache_fini(service_id);
+		block_fini(service_id);
 		async_answer_0(rid, rc);
 		return;
 	}
 
-	rc = fat_idx_init_by_devmap_handle(devmap_handle);
-	if (rc != EOK) {
-		(void) block_cache_fini(devmap_handle);
-		block_fini(devmap_handle);
+	rc = fat_idx_init_by_service_id(service_id);
+	if (rc != EOK) {
+		(void) block_cache_fini(service_id);
+		block_fini(service_id);
 		async_answer_0(rid, rc);
 		return;
@@ -1021,7 +1021,7 @@
 	fs_node_t *rfn = (fs_node_t *)malloc(sizeof(fs_node_t));
 	if (!rfn) {
-		(void) block_cache_fini(devmap_handle);
-		block_fini(devmap_handle);
-		fat_idx_fini_by_devmap_handle(devmap_handle);
+		(void) block_cache_fini(service_id);
+		block_fini(service_id);
+		fat_idx_fini_by_service_id(service_id);
 		async_answer_0(rid, ENOMEM);
 		return;
@@ -1031,7 +1031,7 @@
 	if (!rootp) {
 		free(rfn);
-		(void) block_cache_fini(devmap_handle);
-		block_fini(devmap_handle);
-		fat_idx_fini_by_devmap_handle(devmap_handle);
+		(void) block_cache_fini(service_id);
+		block_fini(service_id);
+		fat_idx_fini_by_service_id(service_id);
 		async_answer_0(rid, ENOMEM);
 		return;
@@ -1039,11 +1039,11 @@
 	fat_node_initialize(rootp);
 
-	fat_idx_t *ridxp = fat_idx_get_by_pos(devmap_handle, FAT_CLST_ROOTPAR, 0);
+	fat_idx_t *ridxp = fat_idx_get_by_pos(service_id, FAT_CLST_ROOTPAR, 0);
 	if (!ridxp) {
 		free(rfn);
 		free(rootp);
-		(void) block_cache_fini(devmap_handle);
-		block_fini(devmap_handle);
-		fat_idx_fini_by_devmap_handle(devmap_handle);
+		(void) block_cache_fini(service_id);
+		block_fini(service_id);
+		fat_idx_fini_by_service_id(service_id);
 		async_answer_0(rid, ENOMEM);
 		return;
@@ -1074,10 +1074,10 @@
 void fat_unmounted(ipc_callid_t rid, ipc_call_t *request)
 {
-	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
+	service_id_t service_id = (service_id_t) IPC_GET_ARG1(*request);
 	fs_node_t *fn;
 	fat_node_t *nodep;
 	int rc;
 
-	rc = fat_root_get(&fn, devmap_handle);
+	rc = fat_root_get(&fn, service_id);
 	if (rc != EOK) {
 		async_answer_0(rid, rc);
@@ -1107,8 +1107,8 @@
 	 * stop using libblock for this instance.
 	 */
-	(void) fat_node_fini_by_devmap_handle(devmap_handle);
-	fat_idx_fini_by_devmap_handle(devmap_handle);
-	(void) block_cache_fini(devmap_handle);
-	block_fini(devmap_handle);
+	(void) fat_node_fini_by_service_id(service_id);
+	fat_idx_fini_by_service_id(service_id);
+	(void) block_cache_fini(service_id);
+	block_fini(service_id);
 
 	async_answer_0(rid, EOK);
@@ -1127,5 +1127,5 @@
 void fat_read(ipc_callid_t rid, ipc_call_t *request)
 {
-	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
+	service_id_t service_id = (service_id_t) IPC_GET_ARG1(*request);
 	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
 	aoff64_t pos =
@@ -1138,5 +1138,5 @@
 	int rc;
 
-	rc = fat_node_get(&fn, devmap_handle, index);
+	rc = fat_node_get(&fn, service_id, index);
 	if (rc != EOK) {
 		async_answer_0(rid, rc);
@@ -1158,5 +1158,5 @@
 	}
 
-	bs = block_bb_get(devmap_handle);
+	bs = block_bb_get(service_id);
 
 	if (nodep->type == FAT_FILE) {
@@ -1264,5 +1264,5 @@
 void fat_write(ipc_callid_t rid, ipc_call_t *request)
 {
-	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
+	service_id_t service_id = (service_id_t) IPC_GET_ARG1(*request);
 	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
 	aoff64_t pos =
@@ -1277,5 +1277,5 @@
 	int rc;
 	
-	rc = fat_node_get(&fn, devmap_handle, index);
+	rc = fat_node_get(&fn, service_id, index);
 	if (rc != EOK) {
 		async_answer_0(rid, rc);
@@ -1297,5 +1297,5 @@
 	}
 
-	bs = block_bb_get(devmap_handle);
+	bs = block_bb_get(service_id);
 
 	/*
@@ -1359,5 +1359,5 @@
 		nclsts = (ROUND_UP(pos + bytes, BPC(bs)) - boundary) / BPC(bs);
 		/* create an independent chain of nclsts clusters in all FATs */
-		rc = fat_alloc_clusters(bs, devmap_handle, nclsts, &mcl, &lcl);
+		rc = fat_alloc_clusters(bs, service_id, nclsts, &mcl, &lcl);
 		if (rc != EOK) {
 			/* could not allocate a chain of nclsts clusters */
@@ -1370,5 +1370,5 @@
 		rc = fat_fill_gap(bs, nodep, mcl, pos);
 		if (rc != EOK) {
-			(void) fat_free_clusters(bs, devmap_handle, mcl);
+			(void) fat_free_clusters(bs, service_id, mcl);
 			(void) fat_node_put(fn);
 			async_answer_0(callid, rc);
@@ -1376,8 +1376,8 @@
 			return;
 		}
-		rc = _fat_block_get(&b, bs, devmap_handle, lcl, NULL,
+		rc = _fat_block_get(&b, bs, service_id, lcl, NULL,
 		    (pos / BPS(bs)) % SPC(bs), flags);
 		if (rc != EOK) {
-			(void) fat_free_clusters(bs, devmap_handle, mcl);
+			(void) fat_free_clusters(bs, service_id, mcl);
 			(void) fat_node_put(fn);
 			async_answer_0(callid, rc);
@@ -1390,5 +1390,5 @@
 		rc = block_put(b);
 		if (rc != EOK) {
-			(void) fat_free_clusters(bs, devmap_handle, mcl);
+			(void) fat_free_clusters(bs, service_id, mcl);
 			(void) fat_node_put(fn);
 			async_answer_0(rid, rc);
@@ -1401,5 +1401,5 @@
 		rc = fat_append_clusters(bs, nodep, mcl, lcl);
 		if (rc != EOK) {
-			(void) fat_free_clusters(bs, devmap_handle, mcl);
+			(void) fat_free_clusters(bs, service_id, mcl);
 			(void) fat_node_put(fn);
 			async_answer_0(rid, rc);
@@ -1416,5 +1416,5 @@
 void fat_truncate(ipc_callid_t rid, ipc_call_t *request)
 {
-	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
+	service_id_t service_id = (service_id_t) IPC_GET_ARG1(*request);
 	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
 	aoff64_t size =
@@ -1425,5 +1425,5 @@
 	int rc;
 
-	rc = fat_node_get(&fn, devmap_handle, index);
+	rc = fat_node_get(&fn, service_id, index);
 	if (rc != EOK) {
 		async_answer_0(rid, rc);
@@ -1436,5 +1436,5 @@
 	nodep = FAT_NODE(fn);
 
-	bs = block_bb_get(devmap_handle);
+	bs = block_bb_get(service_id);
 
 	if (nodep->size == size) {
@@ -1463,5 +1463,5 @@
 		} else {
 			fat_cluster_t lastc;
-			rc = fat_cluster_walk(bs, devmap_handle, nodep->firstc,
+			rc = fat_cluster_walk(bs, service_id, nodep->firstc,
 			    &lastc, NULL, (size - 1) / BPC(bs));
 			if (rc != EOK)
@@ -1488,5 +1488,5 @@
 void fat_destroy(ipc_callid_t rid, ipc_call_t *request)
 {
-	devmap_handle_t devmap_handle = (devmap_handle_t)IPC_GET_ARG1(*request);
+	service_id_t service_id = (service_id_t)IPC_GET_ARG1(*request);
 	fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
 	fs_node_t *fn;
@@ -1494,5 +1494,5 @@
 	int rc;
 
-	rc = fat_node_get(&fn, devmap_handle, index);
+	rc = fat_node_get(&fn, service_id, index);
 	if (rc != EOK) {
 		async_answer_0(rid, rc);
@@ -1527,9 +1527,9 @@
 void fat_sync(ipc_callid_t rid, ipc_call_t *request)
 {
-	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
+	service_id_t service_id = (service_id_t) IPC_GET_ARG1(*request);
 	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
 	
 	fs_node_t *fn;
-	int rc = fat_node_get(&fn, devmap_handle, index);
+	int rc = fat_node_get(&fn, service_id, index);
 	if (rc != EOK) {
 		async_answer_0(rid, rc);
Index: uspace/srv/fs/locfs/Makefile
===================================================================
--- uspace/srv/fs/locfs/Makefile	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
+++ uspace/srv/fs/locfs/Makefile	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -0,0 +1,40 @@
+#
+# Copyright (c) 2005 Martin Decky
+# Copyright (c) 2007 Jakub Jermar
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+USPACE_PREFIX = ../../..
+LIBS = $(LIBFS_PREFIX)/libfs.a
+EXTRA_CFLAGS += -I$(LIBFS_PREFIX)
+BINARY = locfs
+STATIC_NEEDED = y
+
+SOURCES = \
+	locfs.c \
+	locfs_ops.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/srv/fs/locfs/locfs.c
===================================================================
--- uspace/srv/fs/locfs/locfs.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
+++ uspace/srv/fs/locfs/locfs.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2009 Martin Decky
+ * 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 fs
+ * @{
+ */
+
+/**
+ * @file locfs.c
+ * @brief Location-service file system.
+ *
+ * Every service registered with location service is represented as a file in this
+ * file system.
+ */
+
+#include <stdio.h>
+#include <ipc/services.h>
+#include <ns.h>
+#include <async.h>
+#include <errno.h>
+#include <task.h>
+#include <libfs.h>
+#include "locfs.h"
+#include "locfs_ops.h"
+
+#define NAME  "locfs"
+
+static vfs_info_t locfs_vfs_info = {
+	.name = NAME,
+	.concurrent_read_write = false,
+	.write_retains_size = false,
+};
+
+fs_reg_t locfs_reg;
+
+static void locfs_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
+{
+	if (iid)
+		async_answer_0(iid, EOK);
+	
+	while (true) {
+		ipc_call_t call;
+		ipc_callid_t callid = async_get_call(&call);
+		
+		if (!IPC_GET_IMETHOD(call))
+			return;
+		
+		switch (IPC_GET_IMETHOD(call)) {
+		case VFS_OUT_MOUNTED:
+			locfs_mounted(callid, &call);
+			break;
+		case VFS_OUT_MOUNT:
+			locfs_mount(callid, &call);
+			break;
+		case VFS_OUT_UNMOUNTED:
+			locfs_unmounted(callid, &call);
+			break;
+		case VFS_OUT_UNMOUNT:
+			locfs_unmount(callid, &call);
+			break;
+		case VFS_OUT_LOOKUP:
+			locfs_lookup(callid, &call);
+			break;
+		case VFS_OUT_OPEN_NODE:
+			locfs_open_node(callid, &call);
+			break;
+		case VFS_OUT_STAT:
+			locfs_stat(callid, &call);
+			break;
+		case VFS_OUT_READ:
+			locfs_read(callid, &call);
+			break;
+		case VFS_OUT_WRITE:
+			locfs_write(callid, &call);
+			break;
+		case VFS_OUT_TRUNCATE:
+			locfs_truncate(callid, &call);
+			break;
+		case VFS_OUT_CLOSE:
+			locfs_close(callid, &call);
+			break;
+		case VFS_OUT_SYNC:
+			locfs_sync(callid, &call);
+			break;
+		case VFS_OUT_DESTROY:
+			locfs_destroy(callid, &call);
+			break;
+		default:
+			async_answer_0(callid, ENOTSUP);
+			break;
+		}
+	}
+}
+
+int main(int argc, char *argv[])
+{
+	printf("%s: HelenOS Device Filesystem\n", NAME);
+	
+	if (!locfs_init()) {
+		printf("%s: failed to initialize locfs\n", NAME);
+		return -1;
+	}
+	
+	async_sess_t *vfs_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
+	    SERVICE_VFS, 0, 0);
+	if (!vfs_sess) {
+		printf("%s: Unable to connect to VFS\n", NAME);
+		return -1;
+	}
+	
+	int rc = fs_register(vfs_sess, &locfs_reg, &locfs_vfs_info,
+	    locfs_connection);
+	if (rc != EOK) {
+		printf("%s: Failed to register file system (%d)\n", NAME, rc);
+		return rc;
+	}
+	
+	printf("%s: Accepting connections\n", NAME);
+	task_retval(0);
+	async_manager();
+	
+	/* Not reached */
+	return 0;
+}
+
+/**
+ * @}
+ */
Index: uspace/srv/fs/locfs/locfs.h
===================================================================
--- uspace/srv/fs/locfs/locfs.h	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
+++ uspace/srv/fs/locfs/locfs.h	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2009 Martin Decky
+ * 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 fs
+ * @{
+ */ 
+
+#ifndef LOCFS_LOCFS_H_
+#define LOCFS_LOCFS_H_
+
+#include <libfs.h>
+
+extern fs_reg_t locfs_reg;
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/srv/fs/locfs/locfs_ops.c
===================================================================
--- uspace/srv/fs/locfs/locfs_ops.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
+++ uspace/srv/fs/locfs/locfs_ops.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -0,0 +1,837 @@
+/*
+ * Copyright (c) 2009 Martin Decky
+ * 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 fs
+ * @{
+ */
+
+/**
+ * @file locfs_ops.c
+ * @brief Implementation of VFS operations for the locfs file system server.
+ */
+
+#include <macros.h>
+#include <bool.h>
+#include <errno.h>
+#include <malloc.h>
+#include <str.h>
+#include <libfs.h>
+#include <fibril_synch.h>
+#include <adt/hash_table.h>
+#include <ipc/loc.h>
+#include <sys/stat.h>
+#include <libfs.h>
+#include <assert.h>
+#include "locfs.h"
+#include "locfs_ops.h"
+
+typedef struct {
+	loc_object_type_t type;
+	service_id_t service_id;
+} locfs_node_t;
+
+/** Opened services structure */
+typedef struct {
+	service_id_t service_id;
+	async_sess_t *sess;       /**< If NULL, the structure is incomplete. */
+	size_t refcount;
+	link_t link;
+	fibril_condvar_t cv;      /**< Broadcast when completed. */
+} service_t;
+
+/** Hash table of opened services */
+static hash_table_t services;
+
+/** Hash table mutex */
+static FIBRIL_MUTEX_INITIALIZE(services_mutex);
+
+#define SERVICES_KEYS        1
+#define SERVICES_KEY_HANDLE  0
+#define SERVICES_BUCKETS     256
+
+/* Implementation of hash table interface for the nodes hash table. */
+static hash_index_t services_hash(unsigned long key[])
+{
+	return key[SERVICES_KEY_HANDLE] % SERVICES_BUCKETS;
+}
+
+static int services_compare(unsigned long key[], hash_count_t keys, link_t *item)
+{
+	service_t *dev = hash_table_get_instance(item, service_t, link);
+	return (dev->service_id == (service_id_t) key[SERVICES_KEY_HANDLE]);
+}
+
+static void services_remove_callback(link_t *item)
+{
+	free(hash_table_get_instance(item, service_t, link));
+}
+
+static hash_table_operations_t services_ops = {
+	.hash = services_hash,
+	.compare = services_compare,
+	.remove_callback = services_remove_callback
+};
+
+static int locfs_node_get_internal(fs_node_t **rfn, loc_object_type_t type,
+    service_id_t service_id)
+{
+	locfs_node_t *node = (locfs_node_t *) malloc(sizeof(locfs_node_t));
+	if (node == NULL) {
+		*rfn = NULL;
+		return ENOMEM;
+	}
+	
+	*rfn = (fs_node_t *) malloc(sizeof(fs_node_t));
+	if (*rfn == NULL) {
+		free(node);
+		*rfn = NULL;
+		return ENOMEM;
+	}
+	
+	fs_node_initialize(*rfn);
+	node->type = type;
+	node->service_id = service_id;
+	
+	(*rfn)->data = node;
+	return EOK;
+}
+
+static int locfs_root_get(fs_node_t **rfn, service_id_t service_id)
+{
+	return locfs_node_get_internal(rfn, LOC_OBJECT_NONE, 0);
+}
+
+static int locfs_match(fs_node_t **rfn, fs_node_t *pfn, const char *component)
+{
+	locfs_node_t *node = (locfs_node_t *) pfn->data;
+	int ret;
+	
+	if (node->service_id == 0) {
+		/* Root directory */
+		
+		loc_sdesc_t *nspaces;
+		size_t count = loc_get_namespaces(&nspaces);
+		
+		if (count > 0) {
+			size_t pos;
+			for (pos = 0; pos < count; pos++) {
+				/* Ignore root namespace */
+				if (str_cmp(nspaces[pos].name, "") == 0)
+					continue;
+				
+				if (str_cmp(nspaces[pos].name, component) == 0) {
+					ret = locfs_node_get_internal(rfn, LOC_OBJECT_NAMESPACE, nspaces[pos].id);
+					free(nspaces);
+					return ret;
+				}
+			}
+			
+			free(nspaces);
+		}
+		
+		/* Search root namespace */
+		service_id_t namespace;
+		loc_sdesc_t *svcs;
+		if (loc_namespace_get_id("", &namespace, 0) == EOK) {
+			count = loc_get_services(namespace, &svcs);
+			
+			if (count > 0) {
+				size_t pos;
+				for (pos = 0; pos < count; pos++) {
+					if (str_cmp(svcs[pos].name, component) == 0) {
+						ret = locfs_node_get_internal(rfn, LOC_OBJECT_SERVICE, svcs[pos].id);
+						free(svcs);
+						return ret;
+					}
+				}
+				
+				free(svcs);
+			}
+		}
+		
+		*rfn = NULL;
+		return EOK;
+	}
+	
+	if (node->type == LOC_OBJECT_NAMESPACE) {
+		/* Namespace directory */
+		
+		loc_sdesc_t *svcs;
+		size_t count = loc_get_services(node->service_id, &svcs);
+		if (count > 0) {
+			size_t pos;
+			for (pos = 0; pos < count; pos++) {
+				if (str_cmp(svcs[pos].name, component) == 0) {
+					ret = locfs_node_get_internal(rfn, LOC_OBJECT_SERVICE, svcs[pos].id);
+					free(svcs);
+					return ret;
+				}
+			}
+			
+			free(svcs);
+		}
+		
+		*rfn = NULL;
+		return EOK;
+	}
+	
+	*rfn = NULL;
+	return EOK;
+}
+
+static int locfs_node_get(fs_node_t **rfn, service_id_t service_id, fs_index_t index)
+{
+	return locfs_node_get_internal(rfn, loc_id_probe(index), index);
+}
+
+static int locfs_node_open(fs_node_t *fn)
+{
+	locfs_node_t *node = (locfs_node_t *) fn->data;
+	
+	if (node->service_id == 0) {
+		/* Root directory */
+		return EOK;
+	}
+	
+	loc_object_type_t type = loc_id_probe(node->service_id);
+	
+	if (type == LOC_OBJECT_NAMESPACE) {
+		/* Namespace directory */
+		return EOK;
+	}
+	
+	if (type == LOC_OBJECT_SERVICE) {
+		/* Device node */
+		
+		unsigned long key[] = {
+			[SERVICES_KEY_HANDLE] = (unsigned long) node->service_id
+		};
+		link_t *lnk;
+		
+		fibril_mutex_lock(&services_mutex);
+restart:
+		lnk = hash_table_find(&services, key);
+		if (lnk == NULL) {
+			service_t *dev = (service_t *) malloc(sizeof(service_t));
+			if (dev == NULL) {
+				fibril_mutex_unlock(&services_mutex);
+				return ENOMEM;
+			}
+			
+			dev->service_id = node->service_id;
+			
+			/* Mark as incomplete */
+			dev->sess = NULL;
+			dev->refcount = 1;
+			fibril_condvar_initialize(&dev->cv);
+			
+			/*
+			 * Insert the incomplete device structure so that other
+			 * fibrils will not race with us when we drop the mutex
+			 * below.
+			 */
+			hash_table_insert(&services, key, &dev->link);
+			
+			/*
+			 * Drop the mutex to allow recursive locfs requests.
+			 */
+			fibril_mutex_unlock(&services_mutex);
+			
+			async_sess_t *sess = loc_service_connect(
+			    EXCHANGE_SERIALIZE, node->service_id, 0);
+			
+			fibril_mutex_lock(&services_mutex);
+			
+			/*
+			 * Notify possible waiters about this device structure
+			 * being completed (or destroyed).
+			 */
+			fibril_condvar_broadcast(&dev->cv);
+			
+			if (!sess) {
+				/*
+				 * Connecting failed, need to remove the
+				 * entry and free the device structure.
+				 */
+				hash_table_remove(&services, key, SERVICES_KEYS);
+				fibril_mutex_unlock(&services_mutex);
+				
+				return ENOENT;
+			}
+			
+			/* Set the correct session. */
+			dev->sess = sess;
+		} else {
+			service_t *dev = hash_table_get_instance(lnk, service_t, link);
+			
+			if (!dev->sess) {
+				/*
+				 * Wait until the device structure is completed
+				 * and start from the beginning as the device
+				 * structure might have entirely disappeared
+				 * while we were not holding the mutex in
+				 * fibril_condvar_wait().
+				 */
+				fibril_condvar_wait(&dev->cv, &services_mutex);
+				goto restart;
+			}
+
+			dev->refcount++;
+		}
+		
+		fibril_mutex_unlock(&services_mutex);
+		
+		return EOK;
+	}
+	
+	return ENOENT;
+}
+
+static int locfs_node_put(fs_node_t *fn)
+{
+	free(fn->data);
+	free(fn);
+	return EOK;
+}
+
+static int locfs_create_node(fs_node_t **rfn, service_id_t service_id, int lflag)
+{
+	assert((lflag & L_FILE) ^ (lflag & L_DIRECTORY));
+	
+	*rfn = NULL;
+	return ENOTSUP;
+}
+
+static int locfs_destroy_node(fs_node_t *fn)
+{
+	return ENOTSUP;
+}
+
+static int locfs_link_node(fs_node_t *pfn, fs_node_t *cfn, const char *nm)
+{
+	return ENOTSUP;
+}
+
+static int locfs_unlink_node(fs_node_t *pfn, fs_node_t *cfn, const char *nm)
+{
+	return ENOTSUP;
+}
+
+static int locfs_has_children(bool *has_children, fs_node_t *fn)
+{
+	locfs_node_t *node = (locfs_node_t *) fn->data;
+	
+	if (node->service_id == 0) {
+		size_t count = loc_count_namespaces();
+		if (count > 0) {
+			*has_children = true;
+			return EOK;
+		}
+		
+		/* Root namespace */
+		service_id_t namespace;
+		if (loc_namespace_get_id("", &namespace, 0) == EOK) {
+			count = loc_count_services(namespace);
+			if (count > 0) {
+				*has_children = true;
+				return EOK;
+			}
+		}
+		
+		*has_children = false;
+		return EOK;
+	}
+	
+	if (node->type == LOC_OBJECT_NAMESPACE) {
+		size_t count = loc_count_services(node->service_id);
+		if (count > 0) {
+			*has_children = true;
+			return EOK;
+		}
+		
+		*has_children = false;
+		return EOK;
+	}
+	
+	*has_children = false;
+	return EOK;
+}
+
+static fs_index_t locfs_index_get(fs_node_t *fn)
+{
+	locfs_node_t *node = (locfs_node_t *) fn->data;
+	return node->service_id;
+}
+
+static aoff64_t locfs_size_get(fs_node_t *fn)
+{
+	return 0;
+}
+
+static unsigned int locfs_lnkcnt_get(fs_node_t *fn)
+{
+	locfs_node_t *node = (locfs_node_t *) fn->data;
+	
+	if (node->service_id == 0)
+		return 0;
+	
+	return 1;
+}
+
+static char locfs_plb_get_char(unsigned pos)
+{
+	return locfs_reg.plb_ro[pos % PLB_SIZE];
+}
+
+static bool locfs_is_directory(fs_node_t *fn)
+{
+	locfs_node_t *node = (locfs_node_t *) fn->data;
+	
+	return ((node->type == LOC_OBJECT_NONE) || (node->type == LOC_OBJECT_NAMESPACE));
+}
+
+static bool locfs_is_file(fs_node_t *fn)
+{
+	locfs_node_t *node = (locfs_node_t *) fn->data;
+	
+	return (node->type == LOC_OBJECT_SERVICE);
+}
+
+static service_id_t locfs_device_get(fs_node_t *fn)
+{
+	locfs_node_t *node = (locfs_node_t *) fn->data;
+	
+	if (node->type == LOC_OBJECT_SERVICE)
+		return node->service_id;
+	
+	return 0;
+}
+
+/** libfs operations */
+libfs_ops_t locfs_libfs_ops = {
+	.root_get = locfs_root_get,
+	.match = locfs_match,
+	.node_get = locfs_node_get,
+	.node_open = locfs_node_open,
+	.node_put = locfs_node_put,
+	.create = locfs_create_node,
+	.destroy = locfs_destroy_node,
+	.link = locfs_link_node,
+	.unlink = locfs_unlink_node,
+	.has_children = locfs_has_children,
+	.index_get = locfs_index_get,
+	.size_get = locfs_size_get,
+	.lnkcnt_get = locfs_lnkcnt_get,
+	.plb_get_char = locfs_plb_get_char,
+	.is_directory = locfs_is_directory,
+	.is_file = locfs_is_file,
+	.device_get = locfs_device_get
+};
+
+bool locfs_init(void)
+{
+	if (!hash_table_create(&services, SERVICES_BUCKETS,
+	    SERVICES_KEYS, &services_ops))
+		return false;
+	
+	return true;
+}
+
+void locfs_mounted(ipc_callid_t rid, ipc_call_t *request)
+{
+	char *opts;
+	
+	/* Accept the mount options */
+	sysarg_t retval = async_data_write_accept((void **) &opts, true, 0, 0,
+	    0, NULL);
+	if (retval != EOK) {
+		async_answer_0(rid, retval);
+		return;
+	}
+	
+	free(opts);
+	async_answer_3(rid, EOK, 0, 0, 0);
+}
+
+void locfs_mount(ipc_callid_t rid, ipc_call_t *request)
+{
+	libfs_mount(&locfs_libfs_ops, locfs_reg.fs_handle, rid, request);
+}
+
+void locfs_unmounted(ipc_callid_t rid, ipc_call_t *request)
+{
+	async_answer_0(rid, ENOTSUP);
+}
+
+void locfs_unmount(ipc_callid_t rid, ipc_call_t *request)
+{
+	libfs_unmount(&locfs_libfs_ops, rid, request);
+}
+
+void locfs_lookup(ipc_callid_t rid, ipc_call_t *request)
+{
+	libfs_lookup(&locfs_libfs_ops, locfs_reg.fs_handle, rid, request);
+}
+
+void locfs_open_node(ipc_callid_t rid, ipc_call_t *request)
+{
+	libfs_open_node(&locfs_libfs_ops, locfs_reg.fs_handle, rid, request);
+}
+
+void locfs_stat(ipc_callid_t rid, ipc_call_t *request)
+{
+	libfs_stat(&locfs_libfs_ops, locfs_reg.fs_handle, rid, request);
+}
+
+void locfs_read(ipc_callid_t rid, ipc_call_t *request)
+{
+	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
+	aoff64_t pos =
+	    (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request));
+	
+	if (index == 0) {
+		ipc_callid_t callid;
+		size_t size;
+		if (!async_data_read_receive(&callid, &size)) {
+			async_answer_0(callid, EINVAL);
+			async_answer_0(rid, EINVAL);
+			return;
+		}
+		
+		loc_sdesc_t *desc;
+		size_t count = loc_get_namespaces(&desc);
+		
+		/* Get rid of root namespace */
+		size_t i;
+		for (i = 0; i < count; i++) {
+			if (str_cmp(desc[i].name, "") == 0) {
+				if (pos >= i)
+					pos++;
+				
+				break;
+			}
+		}
+		
+		if (pos < count) {
+			async_data_read_finalize(callid, desc[pos].name, str_size(desc[pos].name) + 1);
+			free(desc);
+			async_answer_1(rid, EOK, 1);
+			return;
+		}
+		
+		free(desc);
+		pos -= count;
+		
+		/* Search root namespace */
+		service_id_t namespace;
+		if (loc_namespace_get_id("", &namespace, 0) == EOK) {
+			count = loc_get_services(namespace, &desc);
+			
+			if (pos < count) {
+				async_data_read_finalize(callid, desc[pos].name, str_size(desc[pos].name) + 1);
+				free(desc);
+				async_answer_1(rid, EOK, 1);
+				return;
+			}
+			
+			free(desc);
+		}
+		
+		async_answer_0(callid, ENOENT);
+		async_answer_1(rid, ENOENT, 0);
+		return;
+	}
+	
+	loc_object_type_t type = loc_id_probe(index);
+	
+	if (type == LOC_OBJECT_NAMESPACE) {
+		/* Namespace directory */
+		ipc_callid_t callid;
+		size_t size;
+		if (!async_data_read_receive(&callid, &size)) {
+			async_answer_0(callid, EINVAL);
+			async_answer_0(rid, EINVAL);
+			return;
+		}
+		
+		loc_sdesc_t *desc;
+		size_t count = loc_get_services(index, &desc);
+		
+		if (pos < count) {
+			async_data_read_finalize(callid, desc[pos].name, str_size(desc[pos].name) + 1);
+			free(desc);
+			async_answer_1(rid, EOK, 1);
+			return;
+		}
+		
+		free(desc);
+		async_answer_0(callid, ENOENT);
+		async_answer_1(rid, ENOENT, 0);
+		return;
+	}
+	
+	if (type == LOC_OBJECT_SERVICE) {
+		/* Device node */
+		
+		unsigned long key[] = {
+			[SERVICES_KEY_HANDLE] = (unsigned long) index
+		};
+		
+		fibril_mutex_lock(&services_mutex);
+		link_t *lnk = hash_table_find(&services, key);
+		if (lnk == NULL) {
+			fibril_mutex_unlock(&services_mutex);
+			async_answer_0(rid, ENOENT);
+			return;
+		}
+		
+		service_t *dev = hash_table_get_instance(lnk, service_t, link);
+		assert(dev->sess);
+		
+		ipc_callid_t callid;
+		if (!async_data_read_receive(&callid, NULL)) {
+			fibril_mutex_unlock(&services_mutex);
+			async_answer_0(callid, EINVAL);
+			async_answer_0(rid, EINVAL);
+			return;
+		}
+		
+		/* Make a request at the driver */
+		async_exch_t *exch = async_exchange_begin(dev->sess);
+		
+		ipc_call_t answer;
+		aid_t msg = async_send_3(exch, IPC_GET_IMETHOD(*request),
+		    IPC_GET_ARG1(*request), IPC_GET_ARG2(*request),
+		    IPC_GET_ARG3(*request), &answer);
+		
+		/* Forward the IPC_M_DATA_READ request to the driver */
+		async_forward_fast(callid, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
+		
+		async_exchange_end(exch);
+		
+		fibril_mutex_unlock(&services_mutex);
+		
+		/* Wait for reply from the driver. */
+		sysarg_t rc;
+		async_wait_for(msg, &rc);
+		size_t bytes = IPC_GET_ARG1(answer);
+		
+		/* Driver reply is the final result of the whole operation */
+		async_answer_1(rid, rc, bytes);
+		return;
+	}
+	
+	async_answer_0(rid, ENOENT);
+}
+
+void locfs_write(ipc_callid_t rid, ipc_call_t *request)
+{
+	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
+	if (index == 0) {
+		async_answer_0(rid, ENOTSUP);
+		return;
+	}
+	
+	loc_object_type_t type = loc_id_probe(index);
+	
+	if (type == LOC_OBJECT_NAMESPACE) {
+		/* Namespace directory */
+		async_answer_0(rid, ENOTSUP);
+		return;
+	}
+	
+	if (type == LOC_OBJECT_SERVICE) {
+		/* Device node */
+		unsigned long key[] = {
+			[SERVICES_KEY_HANDLE] = (unsigned long) index
+		};
+		
+		fibril_mutex_lock(&services_mutex);
+		link_t *lnk = hash_table_find(&services, key);
+		if (lnk == NULL) {
+			fibril_mutex_unlock(&services_mutex);
+			async_answer_0(rid, ENOENT);
+			return;
+		}
+		
+		service_t *dev = hash_table_get_instance(lnk, service_t, link);
+		assert(dev->sess);
+		
+		ipc_callid_t callid;
+		if (!async_data_write_receive(&callid, NULL)) {
+			fibril_mutex_unlock(&services_mutex);
+			async_answer_0(callid, EINVAL);
+			async_answer_0(rid, EINVAL);
+			return;
+		}
+		
+		/* Make a request at the driver */
+		async_exch_t *exch = async_exchange_begin(dev->sess);
+		
+		ipc_call_t answer;
+		aid_t msg = async_send_3(exch, IPC_GET_IMETHOD(*request),
+		    IPC_GET_ARG1(*request), IPC_GET_ARG2(*request),
+		    IPC_GET_ARG3(*request), &answer);
+		
+		/* Forward the IPC_M_DATA_WRITE request to the driver */
+		async_forward_fast(callid, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
+		
+		async_exchange_end(exch);
+		
+		fibril_mutex_unlock(&services_mutex);
+		
+		/* Wait for reply from the driver. */
+		sysarg_t rc;
+		async_wait_for(msg, &rc);
+		size_t bytes = IPC_GET_ARG1(answer);
+		
+		/* Driver reply is the final result of the whole operation */
+		async_answer_1(rid, rc, bytes);
+		return;
+	}
+	
+	async_answer_0(rid, ENOENT);
+}
+
+void locfs_truncate(ipc_callid_t rid, ipc_call_t *request)
+{
+	async_answer_0(rid, ENOTSUP);
+}
+
+void locfs_close(ipc_callid_t rid, ipc_call_t *request)
+{
+	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
+	
+	if (index == 0) {
+		async_answer_0(rid, EOK);
+		return;
+	}
+	
+	loc_object_type_t type = loc_id_probe(index);
+	
+	if (type == LOC_OBJECT_NAMESPACE) {
+		/* Namespace directory */
+		async_answer_0(rid, EOK);
+		return;
+	}
+	
+	if (type == LOC_OBJECT_SERVICE) {
+		unsigned long key[] = {
+			[SERVICES_KEY_HANDLE] = (unsigned long) index
+		};
+		
+		fibril_mutex_lock(&services_mutex);
+		link_t *lnk = hash_table_find(&services, key);
+		if (lnk == NULL) {
+			fibril_mutex_unlock(&services_mutex);
+			async_answer_0(rid, ENOENT);
+			return;
+		}
+		
+		service_t *dev = hash_table_get_instance(lnk, service_t, link);
+		assert(dev->sess);
+		dev->refcount--;
+		
+		if (dev->refcount == 0) {
+			async_hangup(dev->sess);
+			hash_table_remove(&services, key, SERVICES_KEYS);
+		}
+		
+		fibril_mutex_unlock(&services_mutex);
+		
+		async_answer_0(rid, EOK);
+		return;
+	}
+	
+	async_answer_0(rid, ENOENT);
+}
+
+void locfs_sync(ipc_callid_t rid, ipc_call_t *request)
+{
+	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
+	
+	if (index == 0) {
+		async_answer_0(rid, EOK);
+		return;
+	}
+	
+	loc_object_type_t type = loc_id_probe(index);
+	
+	if (type == LOC_OBJECT_NAMESPACE) {
+		/* Namespace directory */
+		async_answer_0(rid, EOK);
+		return;
+	}
+	
+	if (type == LOC_OBJECT_SERVICE) {
+		unsigned long key[] = {
+			[SERVICES_KEY_HANDLE] = (unsigned long) index
+		};
+		
+		fibril_mutex_lock(&services_mutex);
+		link_t *lnk = hash_table_find(&services, key);
+		if (lnk == NULL) {
+			fibril_mutex_unlock(&services_mutex);
+			async_answer_0(rid, ENOENT);
+			return;
+		}
+		
+		service_t *dev = hash_table_get_instance(lnk, service_t, link);
+		assert(dev->sess);
+		
+		/* Make a request at the driver */
+		async_exch_t *exch = async_exchange_begin(dev->sess);
+		
+		ipc_call_t answer;
+		aid_t msg = async_send_2(exch, IPC_GET_IMETHOD(*request),
+		    IPC_GET_ARG1(*request), IPC_GET_ARG2(*request), &answer);
+		
+		async_exchange_end(exch);
+		
+		fibril_mutex_unlock(&services_mutex);
+		
+		/* Wait for reply from the driver */
+		sysarg_t rc;
+		async_wait_for(msg, &rc);
+		
+		/* Driver reply is the final result of the whole operation */
+		async_answer_0(rid, rc);
+		return;
+	}
+	
+	async_answer_0(rid, ENOENT);
+}
+
+void locfs_destroy(ipc_callid_t rid, ipc_call_t *request)
+{
+	async_answer_0(rid, ENOTSUP);
+}
+
+/**
+ * @}
+ */
Index: uspace/srv/fs/locfs/locfs_ops.h
===================================================================
--- uspace/srv/fs/locfs/locfs_ops.h	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
+++ uspace/srv/fs/locfs/locfs_ops.h	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2009 Martin Decky
+ * 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 fs
+ * @{
+ */
+
+#ifndef LOCFS_LOCFS_OPS_H_
+#define LOCFS_LOCFS_OPS_H_
+
+#include <ipc/common.h>
+#include <bool.h>
+
+extern bool locfs_init(void);
+
+extern void locfs_mounted(ipc_callid_t, ipc_call_t *);
+extern void locfs_mount(ipc_callid_t, ipc_call_t *);
+extern void locfs_unmounted(ipc_callid_t, ipc_call_t *);
+extern void locfs_unmount(ipc_callid_t, ipc_call_t *);
+extern void locfs_lookup(ipc_callid_t, ipc_call_t *);
+extern void locfs_open_node(ipc_callid_t, ipc_call_t *);
+extern void locfs_stat(ipc_callid_t, ipc_call_t *);
+extern void locfs_sync(ipc_callid_t, ipc_call_t *);
+extern void locfs_read(ipc_callid_t, ipc_call_t *);
+extern void locfs_write(ipc_callid_t, ipc_call_t *);
+extern void locfs_truncate(ipc_callid_t, ipc_call_t *);
+extern void locfs_close(ipc_callid_t, ipc_call_t *);
+extern void locfs_destroy(ipc_callid_t, ipc_call_t *);
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/srv/fs/tmpfs/tmpfs.h
===================================================================
--- uspace/srv/fs/tmpfs/tmpfs.h	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/fs/tmpfs/tmpfs.h	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -61,5 +61,5 @@
 	fs_node_t *bp;		/**< Back pointer to the FS node. */
 	fs_index_t index;	/**< TMPFS node index. */
-	devmap_handle_t devmap_handle;/**< Device handle. */
+	service_id_t service_id;/**< Service ID of block device. */
 	link_t nh_link;		/**< Nodes hash table link. */
 	tmpfs_dentry_type_t type;
@@ -90,5 +90,5 @@
 extern void tmpfs_sync(ipc_callid_t, ipc_call_t *);
 
-extern bool tmpfs_restore(devmap_handle_t);
+extern bool tmpfs_restore(service_id_t);
 
 #endif
Index: uspace/srv/fs/tmpfs/tmpfs_dump.c
===================================================================
--- uspace/srv/fs/tmpfs/tmpfs_dump.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/fs/tmpfs/tmpfs_dump.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -55,5 +55,5 @@
 
 static bool
-tmpfs_restore_recursion(devmap_handle_t dev, size_t *bufpos, size_t *buflen,
+tmpfs_restore_recursion(service_id_t dsid, size_t *bufpos, size_t *buflen,
     aoff64_t *pos, fs_node_t *pfn)
 {
@@ -68,5 +68,5 @@
 		uint32_t size;
 		
-		if (block_seqread(dev, bufpos, buflen, pos, &entry,
+		if (block_seqread(dsid, bufpos, buflen, pos, &entry,
 		    sizeof(entry)) != EOK)
 			return false;
@@ -82,5 +82,5 @@
 				return false;
 			
-			rc = ops->create(&fn, dev, L_FILE);
+			rc = ops->create(&fn, dsid, L_FILE);
 			if (rc != EOK || fn == NULL) {
 				free(fname);
@@ -88,5 +88,5 @@
 			}
 			
-			if (block_seqread(dev, bufpos, buflen, pos, fname,
+			if (block_seqread(dsid, bufpos, buflen, pos, fname,
 			    entry.len) != EOK) {
 				(void) ops->destroy(fn);
@@ -104,5 +104,5 @@
 			free(fname);
 			
-			if (block_seqread(dev, bufpos, buflen, pos, &size,
+			if (block_seqread(dsid, bufpos, buflen, pos, &size,
 			    sizeof(size)) != EOK)
 				return false;
@@ -116,5 +116,5 @@
 			
 			nodep->size = size;
-			if (block_seqread(dev, bufpos, buflen, pos, nodep->data,
+			if (block_seqread(dsid, bufpos, buflen, pos, nodep->data,
 			    size) != EOK)
 				return false;
@@ -126,5 +126,5 @@
 				return false;
 			
-			rc = ops->create(&fn, dev, L_DIRECTORY);
+			rc = ops->create(&fn, dsid, L_DIRECTORY);
 			if (rc != EOK || fn == NULL) {
 				free(fname);
@@ -132,5 +132,5 @@
 			}
 			
-			if (block_seqread(dev, bufpos, buflen, pos, fname,
+			if (block_seqread(dsid, bufpos, buflen, pos, fname,
 			    entry.len) != EOK) {
 				(void) ops->destroy(fn);
@@ -148,5 +148,5 @@
 			free(fname);
 			
-			if (!tmpfs_restore_recursion(dev, bufpos, buflen, pos,
+			if (!tmpfs_restore_recursion(dsid, bufpos, buflen, pos,
 			    fn))
 				return false;
@@ -161,5 +161,5 @@
 }
 
-bool tmpfs_restore(devmap_handle_t dev)
+bool tmpfs_restore(service_id_t dsid)
 {
 	libfs_ops_t *ops = &tmpfs_libfs_ops;
@@ -167,5 +167,5 @@
 	int rc;
 
-	rc = block_init(EXCHANGE_SERIALIZE, dev, TMPFS_COMM_SIZE);
+	rc = block_init(EXCHANGE_SERIALIZE, dsid, TMPFS_COMM_SIZE);
 	if (rc != EOK)
 		return false; 
@@ -176,5 +176,5 @@
 	
 	char tag[6];
-	if (block_seqread(dev, &bufpos, &buflen, &pos, tag, 5) != EOK)
+	if (block_seqread(dsid, &bufpos, &buflen, &pos, tag, 5) != EOK)
 		goto error;
 	
@@ -183,16 +183,16 @@
 		goto error;
 	
-	rc = ops->root_get(&fn, dev);
+	rc = ops->root_get(&fn, dsid);
 	if (rc != EOK)
 		goto error;
 
-	if (!tmpfs_restore_recursion(dev, &bufpos, &buflen, &pos, fn))
-		goto error;
-		
-	block_fini(dev);
+	if (!tmpfs_restore_recursion(dsid, &bufpos, &buflen, &pos, fn))
+		goto error;
+		
+	block_fini(dsid);
 	return true;
 	
 error:
-	block_fini(dev);
+	block_fini(dsid);
 	return false;
 }
Index: uspace/srv/fs/tmpfs/tmpfs_ops.c
===================================================================
--- uspace/srv/fs/tmpfs/tmpfs_ops.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/fs/tmpfs/tmpfs_ops.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -69,8 +69,8 @@
 /* Forward declarations of static functions. */
 static int tmpfs_match(fs_node_t **, fs_node_t *, const char *);
-static int tmpfs_node_get(fs_node_t **, devmap_handle_t, fs_index_t);
+static int tmpfs_node_get(fs_node_t **, service_id_t, fs_index_t);
 static int tmpfs_node_open(fs_node_t *);
 static int tmpfs_node_put(fs_node_t *);
-static int tmpfs_create_node(fs_node_t **, devmap_handle_t, int);
+static int tmpfs_create_node(fs_node_t **, service_id_t, int);
 static int tmpfs_destroy_node(fs_node_t *);
 static int tmpfs_link_node(fs_node_t *, fs_node_t *, const char *);
@@ -78,7 +78,7 @@
 
 /* Implementation of helper functions. */
-static int tmpfs_root_get(fs_node_t **rfn, devmap_handle_t devmap_handle)
-{
-	return tmpfs_node_get(rfn, devmap_handle, TMPFS_SOME_ROOT); 
+static int tmpfs_root_get(fs_node_t **rfn, service_id_t service_id)
+{
+	return tmpfs_node_get(rfn, service_id, TMPFS_SOME_ROOT); 
 }
 
@@ -119,5 +119,5 @@
 }
 
-static devmap_handle_t tmpfs_device_get(fs_node_t *fn)
+static service_id_t tmpfs_device_get(fs_node_t *fn)
 {
 	return 0;
@@ -164,7 +164,7 @@
 	switch (keys) {
 	case 1:
-		return (nodep->devmap_handle == key[NODES_KEY_DEV]);
+		return (nodep->service_id == key[NODES_KEY_DEV]);
 	case 2:	
-		return ((nodep->devmap_handle == key[NODES_KEY_DEV]) &&
+		return ((nodep->service_id == key[NODES_KEY_DEV]) &&
 		    (nodep->index == key[NODES_KEY_INDEX]));
 	default:
@@ -208,5 +208,5 @@
 	nodep->bp = NULL;
 	nodep->index = 0;
-	nodep->devmap_handle = 0;
+	nodep->service_id = 0;
 	nodep->type = TMPFS_NONE;
 	nodep->lnkcnt = 0;
@@ -232,10 +232,10 @@
 }
 
-static bool tmpfs_instance_init(devmap_handle_t devmap_handle)
+static bool tmpfs_instance_init(service_id_t service_id)
 {
 	fs_node_t *rfn;
 	int rc;
 	
-	rc = tmpfs_create_node(&rfn, devmap_handle, L_DIRECTORY);
+	rc = tmpfs_create_node(&rfn, service_id, L_DIRECTORY);
 	if (rc != EOK || !rfn)
 		return false;
@@ -244,8 +244,8 @@
 }
 
-static void tmpfs_instance_done(devmap_handle_t devmap_handle)
+static void tmpfs_instance_done(service_id_t service_id)
 {
 	unsigned long key[] = {
-		[NODES_KEY_DEV] = devmap_handle
+		[NODES_KEY_DEV] = service_id
 	};
 	/*
@@ -276,8 +276,8 @@
 }
 
-int tmpfs_node_get(fs_node_t **rfn, devmap_handle_t devmap_handle, fs_index_t index)
+int tmpfs_node_get(fs_node_t **rfn, service_id_t service_id, fs_index_t index)
 {
 	unsigned long key[] = {
-		[NODES_KEY_DEV] = devmap_handle,
+		[NODES_KEY_DEV] = service_id,
 		[NODES_KEY_INDEX] = index
 	};
@@ -305,5 +305,5 @@
 }
 
-int tmpfs_create_node(fs_node_t **rfn, devmap_handle_t devmap_handle, int lflag)
+int tmpfs_create_node(fs_node_t **rfn, service_id_t service_id, int lflag)
 {
 	fs_node_t *rootfn;
@@ -324,5 +324,5 @@
 	nodep->bp->data = nodep;	/* link the FS and TMPFS nodes */
 
-	rc = tmpfs_root_get(&rootfn, devmap_handle);
+	rc = tmpfs_root_get(&rootfn, service_id);
 	assert(rc == EOK);
 	if (!rootfn)
@@ -330,5 +330,5 @@
 	else
 		nodep->index = tmpfs_next_index++;
-	nodep->devmap_handle = devmap_handle;
+	nodep->service_id = service_id;
 	if (lflag & L_DIRECTORY) 
 		nodep->type = TMPFS_DIRECTORY;
@@ -338,5 +338,5 @@
 	/* Insert the new node into the nodes hash table. */
 	unsigned long key[] = {
-		[NODES_KEY_DEV] = nodep->devmap_handle,
+		[NODES_KEY_DEV] = nodep->service_id,
 		[NODES_KEY_INDEX] = nodep->index
 	};
@@ -354,5 +354,5 @@
 
 	unsigned long key[] = {
-		[NODES_KEY_DEV] = nodep->devmap_handle,
+		[NODES_KEY_DEV] = nodep->service_id,
 		[NODES_KEY_INDEX] = nodep->index
 	};
@@ -435,5 +435,5 @@
 void tmpfs_mounted(ipc_callid_t rid, ipc_call_t *request)
 {
-	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
+	service_id_t service_id = (service_id_t) IPC_GET_ARG1(*request);
 	fs_node_t *rootfn;
 	int rc;
@@ -448,5 +448,5 @@
 
 	/* Check if this device is not already mounted. */
-	rc = tmpfs_root_get(&rootfn, devmap_handle);
+	rc = tmpfs_root_get(&rootfn, service_id);
 	if ((rc == EOK) && (rootfn)) {
 		(void) tmpfs_node_put(rootfn);
@@ -457,5 +457,5 @@
 
 	/* Initialize TMPFS instance. */
-	if (!tmpfs_instance_init(devmap_handle)) {
+	if (!tmpfs_instance_init(service_id)) {
 		free(opts);
 		async_answer_0(rid, ENOMEM);
@@ -463,9 +463,9 @@
 	}
 
-	rc = tmpfs_root_get(&rootfn, devmap_handle);
+	rc = tmpfs_root_get(&rootfn, service_id);
 	assert(rc == EOK);
 	tmpfs_node_t *rootp = TMPFS_NODE(rootfn);
 	if (str_cmp(opts, "restore") == 0) {
-		if (tmpfs_restore(devmap_handle))
+		if (tmpfs_restore(service_id))
 			async_answer_3(rid, EOK, rootp->index, rootp->size,
 			    rootp->lnkcnt);
@@ -486,7 +486,7 @@
 void tmpfs_unmounted(ipc_callid_t rid, ipc_call_t *request)
 {
-	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
-
-	tmpfs_instance_done(devmap_handle);
+	service_id_t service_id = (service_id_t) IPC_GET_ARG1(*request);
+
+	tmpfs_instance_done(service_id);
 	async_answer_0(rid, EOK);
 }
@@ -504,5 +504,5 @@
 void tmpfs_read(ipc_callid_t rid, ipc_call_t *request)
 {
-	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
+	service_id_t service_id = (service_id_t) IPC_GET_ARG1(*request);
 	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
 	aoff64_t pos =
@@ -514,5 +514,5 @@
 	link_t *hlp;
 	unsigned long key[] = {
-		[NODES_KEY_DEV] = devmap_handle,
+		[NODES_KEY_DEV] = service_id,
 		[NODES_KEY_INDEX] = index
 	};
@@ -575,5 +575,5 @@
 void tmpfs_write(ipc_callid_t rid, ipc_call_t *request)
 {
-	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
+	service_id_t service_id = (service_id_t) IPC_GET_ARG1(*request);
 	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
 	aoff64_t pos =
@@ -585,5 +585,5 @@
 	link_t *hlp;
 	unsigned long key[] = {
-		[NODES_KEY_DEV] = devmap_handle,
+		[NODES_KEY_DEV] = service_id,
 		[NODES_KEY_INDEX] = index
 	};
@@ -640,5 +640,5 @@
 void tmpfs_truncate(ipc_callid_t rid, ipc_call_t *request)
 {
-	devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
+	service_id_t service_id = (service_id_t) IPC_GET_ARG1(*request);
 	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
 	aoff64_t size =
@@ -649,5 +649,5 @@
 	 */
 	unsigned long key[] = {
-		[NODES_KEY_DEV] = devmap_handle,
+		[NODES_KEY_DEV] = service_id,
 		[NODES_KEY_INDEX] = index
 	};
@@ -693,5 +693,5 @@
 void tmpfs_destroy(ipc_callid_t rid, ipc_call_t *request)
 {
-	devmap_handle_t devmap_handle = (devmap_handle_t)IPC_GET_ARG1(*request);
+	service_id_t service_id = (service_id_t)IPC_GET_ARG1(*request);
 	fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
 	int rc;
@@ -699,5 +699,5 @@
 	link_t *hlp;
 	unsigned long key[] = {
-		[NODES_KEY_DEV] = devmap_handle,
+		[NODES_KEY_DEV] = service_id,
 		[NODES_KEY_INDEX] = index
 	};
Index: uspace/srv/hid/console/console.c
===================================================================
--- uspace/srv/hid/console/console.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/hid/console/console.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -53,5 +53,5 @@
 #include <sysinfo.h>
 #include <event.h>
-#include <devmap.h>
+#include <loc.h>
 #include <fcntl.h>
 #include <vfs/vfs.h>
@@ -81,5 +81,5 @@
 	size_t index;             /**< Console index */
 	size_t refcount;          /**< Connection reference count */
-	devmap_handle_t devmap_handle;  /**< Device handle */
+	service_id_t service_id;  /**< Service ID */
 	keybuffer_t keybuffer;    /**< Buffer for incoming keys. */
 	screenbuffer_t scr;       /**< Screenbuffer for saving screen
@@ -582,5 +582,5 @@
 			continue;
 		
-		if (consoles[i].devmap_handle == (devmap_handle_t) IPC_GET_ARG1(*icall)) {
+		if (consoles[i].service_id == (service_id_t) IPC_GET_ARG1(*icall)) {
 			cons = &consoles[i];
 			break;
@@ -724,13 +724,13 @@
 }
 
-static async_sess_t *connect_input(const char *dev_path)
+static async_sess_t *connect_input(const char *svc_path)
 {
 	async_sess_t *sess;
 	async_exch_t *exch;
-	devmap_handle_t handle;
-	
-	int rc = devmap_device_get_handle(dev_path, &handle, 0);
+	service_id_t service_id;
+	
+	int rc = loc_service_get_id(svc_path, &service_id, 0);
 	if (rc == EOK) {
-		sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 0);
+		sess = loc_service_connect(EXCHANGE_ATOMIC, service_id, 0);
 		if (sess == NULL) {
 			printf("%s: Failed to connect to input server\n", NAME);
@@ -776,8 +776,8 @@
 	}
 	
-	/* Register driver */
-	int rc = devmap_driver_register(NAME, client_connection);
+	/* Register server */
+	int rc = loc_server_register(NAME, client_connection);
 	if (rc < 0) {
-		printf("%s: Unable to register driver (%d)\n", NAME, rc);
+		printf("%s: Unable to register server (%d)\n", NAME, rc);
 		return false;
 	}
@@ -823,9 +823,9 @@
 			consoles[i].refcount = 0;
 			
-			char vc[DEVMAP_NAME_MAXLEN + 1];
-			snprintf(vc, DEVMAP_NAME_MAXLEN, "%s/vc%zu", NAMESPACE, i);
+			char vc[LOC_NAME_MAXLEN + 1];
+			snprintf(vc, LOC_NAME_MAXLEN, "%s/vc%zu", NAMESPACE, i);
 			
-			if (devmap_device_register(vc, &consoles[i].devmap_handle) != EOK) {
-				printf("%s: Unable to register device %s\n", NAME, vc);
+			if (loc_service_register(vc, &consoles[i].service_id) != EOK) {
+				printf("%s: Unable to register service %s\n", NAME, vc);
 				return false;
 			}
Index: uspace/srv/hid/input/generic/input.c
===================================================================
--- uspace/srv/hid/input/generic/input.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/hid/input/generic/input.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -53,5 +53,5 @@
 #include <io/console.h>
 #include <io/keycode.h>
-#include <devmap.h>
+#include <loc.h>
 #include <input.h>
 #include <kbd.h>
@@ -324,5 +324,5 @@
 /** Add new kbdev device.
  *
- * @param dev_path Filesystem path to the device (/dev/class/...)
+ * @param dev_path Filesystem path to the device (/loc/class/...)
  *
  */
@@ -352,5 +352,5 @@
 /** Add new mousedev device.
  *
- * @param dev_path Filesystem path to the device (/dev/class/...)
+ * @param dev_path Filesystem path to the device (/loc/class/...)
  *
  */
@@ -486,5 +486,5 @@
 /** Periodically check for new input devices.
  *
- * Looks under /dev/class/keyboard and /dev/class/mouse.
+ * Looks under /loc/class/keyboard and /loc/class/mouse.
  *
  * @param arg Ignored
@@ -504,5 +504,5 @@
 		 * Check for new keyboard device
 		 */
-		rc = asprintf(&dev_path, "/dev/class/keyboard\\%zu", kbd_id);
+		rc = asprintf(&dev_path, "/loc/class/keyboard\\%zu", kbd_id);
 		if (rc < 0)
 			continue;
@@ -521,5 +521,5 @@
 		 * Check for new mouse device
 		 */
-		rc = asprintf(&dev_path, "/dev/class/mouse\\%zu", mouse_id);
+		rc = asprintf(&dev_path, "/loc/class/mouse\\%zu", mouse_id);
 		if (rc < 0)
 			continue;
@@ -573,21 +573,21 @@
 	/* Add legacy keyboard devices. */
 	kbd_add_legacy_devs();
-	
+
 	/* Add legacy mouse devices. */
 	mouse_add_legacy_devs();
 	
 	/* Register driver */
-	int rc = devmap_driver_register(NAME, client_connection);
+	int rc = loc_server_register(NAME, client_connection);
 	if (rc < 0) {
-		printf("%s: Unable to register driver (%d)\n", NAME, rc);
+		printf("%s: Unable to register server (%d)\n", NAME, rc);
 		return -1;
 	}
 	
-	char kbd[DEVMAP_NAME_MAXLEN + 1];
-	snprintf(kbd, DEVMAP_NAME_MAXLEN, "%s/%s", NAMESPACE, NAME);
-	
-	devmap_handle_t devmap_handle;
-	if (devmap_device_register(kbd, &devmap_handle) != EOK) {
-		printf("%s: Unable to register device %s\n", NAME, kbd);
+	char kbd[LOC_NAME_MAXLEN + 1];
+	snprintf(kbd, LOC_NAME_MAXLEN, "%s/%s", NAMESPACE, NAME);
+	
+	service_id_t service_id;
+	if (loc_service_register(kbd, &service_id) != EOK) {
+		printf("%s: Unable to register service %s\n", NAME, kbd);
 		return -1;
 	}
Index: uspace/srv/hid/input/port/adb.c
===================================================================
--- uspace/srv/hid/input/port/adb.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/hid/input/port/adb.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -43,5 +43,5 @@
 #include <fcntl.h>
 #include <errno.h>
-#include <devmap.h>
+#include <loc.h>
 
 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg);
@@ -66,5 +66,5 @@
 {
 	const char *dev = "adb/kbd";
-	devmap_handle_t handle;
+	service_id_t service_id;
 	async_exch_t *exch;
 	int rc;
@@ -72,9 +72,9 @@
 	kbd_dev = kdev;
 	
-	rc = devmap_device_get_handle(dev, &handle, 0);
+	rc = loc_service_get_id(dev, &service_id, 0);
 	if (rc != EOK)
 		return rc;
 	
-	dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 0);
+	dev_sess = loc_service_connect(EXCHANGE_ATOMIC, service_id, 0);
 	if (dev_sess == NULL) {
 		printf("%s: Failed to connect to device\n", NAME);
Index: uspace/srv/hid/input/port/adb_mouse.c
===================================================================
--- uspace/srv/hid/input/port/adb_mouse.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/hid/input/port/adb_mouse.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -41,5 +41,5 @@
 #include <mouse.h>
 #include <errno.h>
-#include <devmap.h>
+#include <loc.h>
 
 static mouse_dev_t *mouse_dev;
@@ -78,10 +78,10 @@
 	mouse_dev = mdev;
 	
-	devmap_handle_t handle;
-	int rc = devmap_device_get_handle(dev, &handle, 0);
+	service_id_t service_id;
+	int rc = loc_service_get_id(dev, &service_id, 0);
 	if (rc != EOK)
 		return rc;
 	
-	dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 0);
+	dev_sess = loc_service_connect(EXCHANGE_ATOMIC, service_id, 0);
 	if (dev_sess == NULL) {
 		printf("%s: Failed to connect to device\n", NAME);
Index: uspace/srv/hid/input/port/chardev.c
===================================================================
--- uspace/srv/hid/input/port/chardev.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/hid/input/port/chardev.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -40,5 +40,5 @@
 #include <kbd_port.h>
 #include <kbd.h>
-#include <devmap.h>
+#include <loc.h>
 #include <errno.h>
 #include <stdio.h>
@@ -71,5 +71,5 @@
 static int chardev_port_init(kbd_dev_t *kdev)
 {
-	devmap_handle_t handle;
+	service_id_t service_id;
 	async_exch_t *exch;
 	unsigned int i;
@@ -79,5 +79,5 @@
 	
 	for (i = 0; i < num_devs; i++) {
-		rc = devmap_device_get_handle(in_devs[i], &handle, 0);
+		rc = loc_service_get_id(in_devs[i], &service_id, 0);
 		if (rc == EOK)
 			break;
@@ -89,5 +89,5 @@
 	}
 	
-	dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle,
+	dev_sess = loc_service_connect(EXCHANGE_ATOMIC, service_id,
 	    IPC_FLAG_BLOCKING);
 	if (dev_sess == NULL) {
Index: uspace/srv/hid/input/port/chardev_mouse.c
===================================================================
--- uspace/srv/hid/input/port/chardev_mouse.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/hid/input/port/chardev_mouse.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -39,5 +39,5 @@
 #include <async.h>
 #include <errno.h>
-#include <devmap.h>
+#include <loc.h>
 #include <input.h>
 #include <mouse_port.h>
@@ -82,5 +82,5 @@
 static int chardev_port_init(mouse_dev_t *mdev)
 {
-	devmap_handle_t handle;
+	service_id_t service_id;
 	unsigned int i;
 	int rc;
@@ -89,5 +89,5 @@
 	
 	for (i = 0; i < num_devs; i++) {
-		rc = devmap_device_get_handle(in_devs[i], &handle, 0);
+		rc = loc_service_get_id(in_devs[i], &service_id, 0);
 		if (rc == EOK)
 			break;
@@ -99,5 +99,5 @@
 	}
 	
-	dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle,
+	dev_sess = loc_service_connect(EXCHANGE_ATOMIC, service_id,
 	    IPC_FLAG_BLOCKING);
 	if (dev_sess == NULL) {
Index: uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c
===================================================================
--- uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -39,5 +39,5 @@
 #include <ddi.h>
 #include <libarch/ddi.h>
-#include <devmap.h>
+#include <loc.h>
 #include <io/console.h>
 #include <vfs/vfs.h>
@@ -90,5 +90,5 @@
 	printf(NAME ": S3C24xx touchscreen driver\n");
 
-	rc = devmap_driver_register(NAME, s3c24xx_ts_connection);
+	rc = loc_server_register(NAME, s3c24xx_ts_connection);
 	if (rc < 0) {
 		printf(NAME ": Unable to register driver.\n");
@@ -103,5 +103,5 @@
 		return -1;
 
-	rc = devmap_device_register(NAMESPACE "/mouse", &ts->devmap_handle);
+	rc = loc_service_register(NAMESPACE "/mouse", &ts->service_id);
 	if (rc != EOK) {
 		printf(NAME ": Unable to register device %s.\n",
Index: uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.h
===================================================================
--- uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.h	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.h	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -124,6 +124,6 @@
 	int client_phone;
 
-	/** Device handle */
-	devmap_handle_t devmap_handle;
+	/** Service ID */
+	service_id_t service_id;
 
 	/** Device/driver state */
Index: uspace/srv/hw/bus/cuda_adb/cuda_adb.c
===================================================================
--- uspace/srv/hw/bus/cuda_adb/cuda_adb.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/hw/bus/cuda_adb/cuda_adb.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -43,5 +43,5 @@
 #include <ddi.h>
 #include <libarch/ddi.h>
-#include <devmap.h>
+#include <loc.h>
 #include <sysinfo.h>
 #include <errno.h>
@@ -147,5 +147,5 @@
 int main(int argc, char *argv[])
 {
-	devmap_handle_t devmap_handle;
+	service_id_t service_id;
 	int rc;
 	int i;
@@ -155,29 +155,29 @@
 	for (i = 0; i < ADB_MAX_ADDR; ++i) {
 		adb_dev[i].client_phone = -1;
-		adb_dev[i].devmap_handle = 0;
-	}
-
-	rc = devmap_driver_register(NAME, cuda_connection);
+		adb_dev[i].service_id = 0;
+	}
+
+	rc = loc_server_register(NAME, cuda_connection);
 	if (rc < 0) {
-		printf(NAME ": Unable to register driver.\n");
+		printf(NAME ": Unable to register server.\n");
 		return rc;
 	}
 
-	rc = devmap_device_register("adb/kbd", &devmap_handle);
+	rc = loc_service_register("adb/kbd", &service_id);
 	if (rc != EOK) {
-		printf(NAME ": Unable to register device %s.\n", "adb/kdb");
+		printf(NAME ": Unable to register service %s.\n", "adb/kdb");
 		return rc;
 	}
 
-	adb_dev[2].devmap_handle = devmap_handle;
-	adb_dev[8].devmap_handle = devmap_handle;
-
-	rc = devmap_device_register("adb/mouse", &devmap_handle);
+	adb_dev[2].service_id = service_id;
+	adb_dev[8].service_id = service_id;
+
+	rc = loc_service_register("adb/mouse", &service_id);
 	if (rc != EOK) {
-		printf(NAME ": Unable to register device %s.\n", "adb/mouse");
+		printf(NAME ": Unable to register servise %s.\n", "adb/mouse");
 		return rc;
 	}
 
-	adb_dev[9].devmap_handle = devmap_handle;
+	adb_dev[9].service_id = service_id;
 
 	if (cuda_init() < 0) {
@@ -198,15 +198,15 @@
 	ipc_call_t call;
 	sysarg_t method;
-	devmap_handle_t dh;
+	service_id_t dsid;
 	int retval;
 	int dev_addr, i;
 
 	/* Get the device handle. */
-	dh = IPC_GET_ARG1(*icall);
+	dsid = IPC_GET_ARG1(*icall);
 
 	/* Determine which disk device is the client connecting to. */
 	dev_addr = -1;
 	for (i = 0; i < ADB_MAX_ADDR; i++) {
-		if (adb_dev[i].devmap_handle == dh)
+		if (adb_dev[i].service_id == dsid)
 			dev_addr = i;
 	}
@@ -242,5 +242,5 @@
 			 */
 			for (i = 0; i < ADB_MAX_ADDR; ++i) {
-				if (adb_dev[i].devmap_handle == dh) {
+				if (adb_dev[i].service_id == dsid) {
 					adb_dev[i].client_phone = IPC_GET_ARG5(call);
 				}
Index: uspace/srv/hw/bus/cuda_adb/cuda_adb.h
===================================================================
--- uspace/srv/hw/bus/cuda_adb/cuda_adb.h	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/hw/bus/cuda_adb/cuda_adb.h	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -38,5 +38,5 @@
 
 #include <sys/types.h>
-#include <ipc/devmap.h>
+#include <ipc/loc.h>
 #include <fibril_synch.h>
 
@@ -104,5 +104,5 @@
 
 typedef struct {
-	devmap_handle_t devmap_handle;
+	service_id_t service_id;
 	int client_phone;
 } adb_dev_t;
Index: uspace/srv/hw/char/i8042/i8042.c
===================================================================
--- uspace/srv/hw/char/i8042/i8042.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/hw/char/i8042/i8042.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -39,5 +39,5 @@
 #include <ddi.h>
 #include <libarch/ddi.h>
-#include <devmap.h>
+#include <loc.h>
 #include <async.h>
 #include <async_obsolete.h>
@@ -135,7 +135,7 @@
 	printf(NAME ": i8042 PS/2 port driver\n");
 
-	rc = devmap_driver_register(NAME, i8042_connection);
+	rc = loc_server_register(NAME, i8042_connection);
 	if (rc < 0) {
-		printf(NAME ": Unable to register driver.\n");
+		printf(NAME ": Unable to register server.\n");
 		return rc;
 	}
@@ -148,5 +148,5 @@
 
 		snprintf(name, 16, "%s/ps2%c", NAMESPACE, dchar[i]);
-		rc = devmap_device_register(name, &i8042_port[i].devmap_handle);
+		rc = loc_service_register(name, &i8042_port[i].service_id);
 		if (rc != EOK) {
 			printf(NAME ": Unable to register device %s.\n", name);
@@ -221,5 +221,5 @@
 	ipc_call_t call;
 	sysarg_t method;
-	devmap_handle_t dh;
+	service_id_t dsid;
 	int retval;
 	int dev_id, i;
@@ -228,10 +228,10 @@
 
 	/* Get the device handle. */
-	dh = IPC_GET_ARG1(*icall);
+	dsid = IPC_GET_ARG1(*icall);
 
 	/* Determine which disk device is the client connecting to. */
 	dev_id = -1;
 	for (i = 0; i < MAX_DEVS; i++) {
-		if (i8042_port[i].devmap_handle == dh)
+		if (i8042_port[i].service_id == dsid)
 			dev_id = i;
 	}
Index: uspace/srv/hw/char/i8042/i8042.h
===================================================================
--- uspace/srv/hw/char/i8042/i8042.h	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/hw/char/i8042/i8042.h	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -52,5 +52,5 @@
 /** Softstate structure, one for each serial port (primary and aux). */
 typedef struct {
-	devmap_handle_t devmap_handle;
+	service_id_t service_id;
 	int client_phone;
 } i8042_port_t;
Index: uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c
===================================================================
--- uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -39,5 +39,5 @@
 #include <ddi.h>
 #include <libarch/ddi.h>
-#include <devmap.h>
+#include <loc.h>
 #include <ipc/char.h>
 #include <async.h>
@@ -83,7 +83,7 @@
 	printf(NAME ": S3C24xx on-chip UART driver\n");
 
-	rc = devmap_driver_register(NAME, s3c24xx_uart_connection);
+	rc = loc_server_register(NAME, s3c24xx_uart_connection);
 	if (rc < 0) {
-		printf(NAME ": Unable to register driver.\n");
+		printf(NAME ": Unable to register server.\n");
 		return -1;
 	}
@@ -96,5 +96,5 @@
 		return -1;
 
-	rc = devmap_device_register(NAMESPACE "/" NAME, &uart->devmap_handle);
+	rc = loc_service_register(NAMESPACE "/" NAME, &uart->service_id);
 	if (rc != EOK) {
 		printf(NAME ": Unable to register device %s.\n",
Index: uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.h
===================================================================
--- uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.h	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.h	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -87,6 +87,6 @@
 	int client_phone;
 
-	/** Device handle */
-	devmap_handle_t devmap_handle;
+	/** Service ID */
+	service_id_t service_id;
 } s3c24xx_uart_t;
 
Index: uspace/srv/hw/irc/apic/apic.c
===================================================================
--- uspace/srv/hw/irc/apic/apic.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/hw/irc/apic/apic.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -50,5 +50,5 @@
 #include <async.h>
 #include <stdio.h>
-#include <ipc/devmap.h>
+#include <ipc/loc.h>
 
 #define NAME  "apic"
Index: uspace/srv/hw/irc/fhc/fhc.c
===================================================================
--- uspace/srv/hw/irc/fhc/fhc.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/hw/irc/fhc/fhc.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -49,5 +49,5 @@
 #include <async.h>
 #include <stdio.h>
-#include <ipc/devmap.h>
+#include <ipc/loc.h>
 
 #define NAME "fhc"
Index: uspace/srv/hw/irc/i8259/i8259.c
===================================================================
--- uspace/srv/hw/irc/i8259/i8259.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/hw/irc/i8259/i8259.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -50,5 +50,5 @@
 #include <async.h>
 #include <stdio.h>
-#include <ipc/devmap.h>
+#include <ipc/loc.h>
 
 #define NAME  "i8259"
Index: uspace/srv/hw/irc/obio/obio.c
===================================================================
--- uspace/srv/hw/irc/obio/obio.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/hw/irc/obio/obio.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -55,5 +55,5 @@
 #include <async.h>
 #include <stdio.h>
-#include <ipc/devmap.h>
+#include <ipc/loc.h>
 
 #define NAME "obio"
Index: uspace/srv/loc/Makefile
===================================================================
--- uspace/srv/loc/Makefile	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
+++ uspace/srv/loc/Makefile	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -0,0 +1,37 @@
+#
+# 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 = loc
+STATIC_NEEDED = y
+
+SOURCES = \
+	loc.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/srv/loc/loc.c
===================================================================
--- uspace/srv/loc/loc.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
+++ uspace/srv/loc/loc.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -0,0 +1,1164 @@
+/*
+ * Copyright (c) 2007 Josef Cejka
+ * 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.
+ */
+
+/**
+ * @defgroup loc Location Service.
+ * @brief HelenOS location service.
+ * @{
+ */
+
+/** @file
+ */
+
+#include <ipc/services.h>
+#include <ns.h>
+#include <async.h>
+#include <stdio.h>
+#include <errno.h>
+#include <bool.h>
+#include <fibril_synch.h>
+#include <stdlib.h>
+#include <str.h>
+#include <ipc/loc.h>
+#include <assert.h>
+
+#define NAME          "loc"
+#define NULL_SERVICES  256
+
+/** Representation of server (supplier).
+ *
+ * Each server supplies a set of services.
+ *
+ */
+typedef struct {
+	/** Link to servers_list */
+	link_t servers;
+	
+	/** List of services supplied by this server */
+	list_t services;
+	
+	/** Session asociated with this server */
+	async_sess_t *sess;
+	
+	/** Server name */
+	char *name;
+	
+	/** Fibril mutex for list of services owned by this server */
+	fibril_mutex_t services_mutex;
+} loc_server_t;
+
+/** Info about registered namespaces
+ *
+ */
+typedef struct {
+	/** Link to namespaces_list */
+	link_t namespaces;
+	
+	/** Unique namespace identifier */
+	service_id_t id;
+	
+	/** Namespace name */
+	char *name;
+	
+	/** Reference count */
+	size_t refcnt;
+} loc_namespace_t;
+
+/** Info about registered service
+ *
+ */
+typedef struct {
+	/** Link to global list of services (services_list) */
+	link_t services;
+	/** Link to server list of services (loc_server_t.services) */
+	link_t server_services;
+	/** Unique service identifier */
+	service_id_t id;
+	/** Service namespace */
+	loc_namespace_t *namespace;
+	/** Service name */
+	char *name;
+	/** Supplier of this service */
+	loc_server_t *server;
+	/** Use this interface when forwarding to server. */
+	sysarg_t forward_interface;
+} loc_service_t;
+
+LIST_INITIALIZE(services_list);
+LIST_INITIALIZE(namespaces_list);
+LIST_INITIALIZE(servers_list);
+
+/* Locking order:
+ *  servers_list_mutex
+ *  services_list_mutex
+ *  (loc_server_t *)->services_mutex
+ *  create_id_mutex
+ **/
+
+static FIBRIL_MUTEX_INITIALIZE(services_list_mutex);
+static FIBRIL_CONDVAR_INITIALIZE(services_list_cv);
+static FIBRIL_MUTEX_INITIALIZE(servers_list_mutex);
+static FIBRIL_MUTEX_INITIALIZE(create_id_mutex);
+static FIBRIL_MUTEX_INITIALIZE(null_services_mutex);
+
+static service_id_t last_id = 0;
+static loc_service_t *null_services[NULL_SERVICES];
+
+/*
+ * Dummy list for null services. This is necessary so that null services can
+ * be used just as any other services, e.g. in loc_service_unregister_core().
+ */
+static LIST_INITIALIZE(dummy_null_services);
+
+static service_id_t loc_create_id(void)
+{
+	/* TODO: allow reusing old ids after their unregistration
+	 * and implement some version of LRU algorithm, avoid overflow
+	 */
+	
+	fibril_mutex_lock(&create_id_mutex);
+	last_id++;
+	fibril_mutex_unlock(&create_id_mutex);
+	
+	return last_id;
+}
+
+/** Convert fully qualified service name to namespace and service name.
+ *
+ * A fully qualified service name can be either a plain service name
+ * (then the namespace is considered to be an empty string) or consist
+ * of two components separated by a slash. No more than one slash
+ * is allowed.
+ *
+ */
+static bool loc_fqsn_split(const char *fqsn, char **ns_name, char **name)
+{
+	size_t cnt = 0;
+	size_t slash_offset = 0;
+	size_t slash_after = 0;
+	
+	size_t offset = 0;
+	size_t offset_prev = 0;
+	wchar_t c;
+	
+	while ((c = str_decode(fqsn, &offset, STR_NO_LIMIT)) != 0) {
+		if (c == '/') {
+			cnt++;
+			slash_offset = offset_prev;
+			slash_after = offset;
+		}
+		offset_prev = offset;
+	}
+	
+	/* More than one slash */
+	if (cnt > 1)
+		return false;
+	
+	/* No slash -> namespace is empty */
+	if (cnt == 0) {
+		*ns_name = str_dup("");
+		if (*ns_name == NULL)
+			return false;
+		
+		*name = str_dup(fqsn);
+		if (*name == NULL) {
+			free(*ns_name);
+			return false;
+		}
+		
+		if (str_cmp(*name, "") == 0) {
+			free(*name);
+			free(*ns_name);
+			return false;
+		}
+		
+		return true;
+	}
+	
+	/* Exactly one slash */
+	*ns_name = str_ndup(fqsn, slash_offset);
+	if (*ns_name == NULL)
+		return false;
+	
+	*name = str_dup(fqsn + slash_after);
+	if (*name == NULL) {
+		free(*ns_name);
+		return false;
+	}
+	
+	if (str_cmp(*name, "") == 0) {
+		free(*name);
+		free(*ns_name);
+		return false;
+	}
+	
+	return true;
+}
+
+/** Find namespace with given name. */
+static loc_namespace_t *loc_namespace_find_name(const char *name)
+{
+	assert(fibril_mutex_is_locked(&services_list_mutex));
+	
+	list_foreach(namespaces_list, item) {
+		loc_namespace_t *namespace =
+		    list_get_instance(item, loc_namespace_t, namespaces);
+		if (str_cmp(namespace->name, name) == 0)
+			return namespace;
+	}
+	
+	return NULL;
+}
+
+/** Find namespace with given ID.
+ *
+ * @todo: use hash table
+ *
+ */
+static loc_namespace_t *loc_namespace_find_id(service_id_t id)
+{
+	assert(fibril_mutex_is_locked(&services_list_mutex));
+	
+	list_foreach(namespaces_list, item) {
+		loc_namespace_t *namespace =
+		    list_get_instance(item, loc_namespace_t, namespaces);
+		if (namespace->id == id)
+			return namespace;
+	}
+	
+	return NULL;
+}
+
+/** Find service with given name. */
+static loc_service_t *loc_service_find_name(const char *ns_name,
+    const char *name)
+{
+	assert(fibril_mutex_is_locked(&services_list_mutex));
+	
+	list_foreach(services_list, item) {
+		loc_service_t *service =
+		    list_get_instance(item, loc_service_t, services);
+		if ((str_cmp(service->namespace->name, ns_name) == 0)
+		    && (str_cmp(service->name, name) == 0))
+			return service;
+	}
+	
+	return NULL;
+}
+
+/** Find service with given ID.
+ *
+ * @todo: use hash table
+ *
+ */
+static loc_service_t *loc_service_find_id(service_id_t id)
+{
+	assert(fibril_mutex_is_locked(&services_list_mutex));
+	
+	list_foreach(services_list, item) {
+		loc_service_t *service =
+		    list_get_instance(item, loc_service_t, services);
+		if (service->id == id)
+			return service;
+	}
+	
+	return NULL;
+}
+
+/** Create a namespace (if not already present). */
+static loc_namespace_t *loc_namespace_create(const char *ns_name)
+{
+	loc_namespace_t *namespace;
+	
+	assert(fibril_mutex_is_locked(&services_list_mutex));
+	
+	namespace = loc_namespace_find_name(ns_name);
+	if (namespace != NULL)
+		return namespace;
+	
+	namespace = (loc_namespace_t *) malloc(sizeof(loc_namespace_t));
+	if (namespace == NULL)
+		return NULL;
+	
+	namespace->name = str_dup(ns_name);
+	if (namespace->name == NULL) {
+		free(namespace);
+		return NULL;
+	}
+	
+	namespace->id = loc_create_id();
+	namespace->refcnt = 0;
+	
+	/*
+	 * Insert new namespace into list of registered namespaces
+	 */
+	list_append(&(namespace->namespaces), &namespaces_list);
+	
+	return namespace;
+}
+
+/** Destroy a namespace (if it is no longer needed). */
+static void loc_namespace_destroy(loc_namespace_t *namespace)
+{
+	assert(fibril_mutex_is_locked(&services_list_mutex));
+
+	if (namespace->refcnt == 0) {
+		list_remove(&(namespace->namespaces));
+		
+		free(namespace->name);
+		free(namespace);
+	}
+}
+
+/** Increase namespace reference count by including service. */
+static void loc_namespace_addref(loc_namespace_t *namespace,
+    loc_service_t *service)
+{
+	assert(fibril_mutex_is_locked(&services_list_mutex));
+
+	service->namespace = namespace;
+	namespace->refcnt++;
+}
+
+/** Decrease namespace reference count. */
+static void loc_namespace_delref(loc_namespace_t *namespace)
+{
+	assert(fibril_mutex_is_locked(&services_list_mutex));
+
+	namespace->refcnt--;
+	loc_namespace_destroy(namespace);
+}
+
+/** Unregister service and free it. */
+static void loc_service_unregister_core(loc_service_t *service)
+{
+	assert(fibril_mutex_is_locked(&services_list_mutex));
+
+	loc_namespace_delref(service->namespace);
+	list_remove(&(service->services));
+	list_remove(&(service->server_services));
+	
+	free(service->name);
+	free(service);
+}
+
+/**
+ * Read info about new server and add it into linked list of registered
+ * servers.
+ */
+static loc_server_t *loc_server_register(void)
+{
+	ipc_call_t icall;
+	ipc_callid_t iid = async_get_call(&icall);
+	
+	if (IPC_GET_IMETHOD(icall) != LOC_SERVER_REGISTER) {
+		async_answer_0(iid, EREFUSED);
+		return NULL;
+	}
+	
+	loc_server_t *server =
+	    (loc_server_t *) malloc(sizeof(loc_server_t));
+	if (server == NULL) {
+		async_answer_0(iid, ENOMEM);
+		return NULL;
+	}
+	
+	/*
+	 * Get server name
+	 */
+	int rc = async_data_write_accept((void **) &server->name, true, 0,
+	    LOC_NAME_MAXLEN, 0, NULL);
+	if (rc != EOK) {
+		free(server);
+		async_answer_0(iid, rc);
+		return NULL;
+	}
+	
+	/*
+	 * Create connection to the server
+	 */
+	server->sess = async_callback_receive(EXCHANGE_SERIALIZE);
+	if (!server->sess) {
+		free(server->name);
+		free(server);
+		async_answer_0(iid, ENOTSUP);
+		return NULL;
+	}
+	
+	/*
+	 * Initialize mutex for list of services
+	 * supplied by this server
+	 */
+	fibril_mutex_initialize(&server->services_mutex);
+	
+	/*
+	 * Initialize list of supplied services
+	 */
+	list_initialize(&server->services);
+
+	link_initialize(&server->servers);
+	
+	fibril_mutex_lock(&servers_list_mutex);
+	
+	/* TODO:
+	 * Check that no server with name equal to
+	 * server->name is registered
+	 */
+	
+	/*
+	 * Insert new server into list of registered servers
+	 */
+	list_append(&(server->servers), &servers_list);
+	fibril_mutex_unlock(&servers_list_mutex);
+	
+	async_answer_0(iid, EOK);
+	
+	return server;
+}
+
+/**
+ * Unregister server, unregister all its services and free server
+ * structure.
+ *
+ */
+static int loc_server_unregister(loc_server_t *server)
+{
+	if (server == NULL)
+		return EEXISTS;
+	
+	fibril_mutex_lock(&servers_list_mutex);
+	
+	if (server->sess)
+		async_hangup(server->sess);
+	
+	/* Remove it from list of servers */
+	list_remove(&(server->servers));
+	
+	/* Unregister all its services */
+	fibril_mutex_lock(&services_list_mutex);
+	fibril_mutex_lock(&server->services_mutex);
+	
+	while (!list_empty(&server->services)) {
+		loc_service_t *service = list_get_instance(
+		    list_first(&server->services), loc_service_t,
+		    server_services);
+		loc_service_unregister_core(service);
+	}
+	
+	fibril_mutex_unlock(&server->services_mutex);
+	fibril_mutex_unlock(&services_list_mutex);
+	fibril_mutex_unlock(&servers_list_mutex);
+	
+	/* Free name and server */
+	if (server->name != NULL)
+		free(server->name);
+	
+	free(server);
+	
+	return EOK;
+}
+
+/** Register service
+ *
+ */
+static void loc_service_register(ipc_callid_t iid, ipc_call_t *icall,
+    loc_server_t *server)
+{
+	if (server == NULL) {
+		async_answer_0(iid, EREFUSED);
+		return;
+	}
+	
+	/* Create new service entry */
+	loc_service_t *service =
+	    (loc_service_t *) malloc(sizeof(loc_service_t));
+	if (service == NULL) {
+		async_answer_0(iid, ENOMEM);
+		return;
+	}
+	
+	/* Set the interface, if any. */
+	service->forward_interface = IPC_GET_ARG1(*icall);
+
+	/* Get fqsn */
+	char *fqsn;
+	int rc = async_data_write_accept((void **) &fqsn, true, 0,
+	    LOC_NAME_MAXLEN, 0, NULL);
+	if (rc != EOK) {
+		free(service);
+		async_answer_0(iid, rc);
+		return;
+	}
+	
+	char *ns_name;
+	if (!loc_fqsn_split(fqsn, &ns_name, &service->name)) {
+		free(fqsn);
+		free(service);
+		async_answer_0(iid, EINVAL);
+		return;
+	}
+	
+	free(fqsn);
+	
+	fibril_mutex_lock(&services_list_mutex);
+	
+	loc_namespace_t *namespace = loc_namespace_create(ns_name);
+	free(ns_name);
+	if (namespace == NULL) {
+		fibril_mutex_unlock(&services_list_mutex);
+		free(service->name);
+		free(service);
+		async_answer_0(iid, ENOMEM);
+		return;
+	}
+	
+	link_initialize(&service->services);
+	link_initialize(&service->server_services);
+	
+	/* Check that service is not already registered */
+	if (loc_service_find_name(namespace->name, service->name) != NULL) {
+		printf("%s: Service '%s/%s' already registered\n", NAME,
+		    namespace->name, service->name);
+		loc_namespace_destroy(namespace);
+		fibril_mutex_unlock(&services_list_mutex);
+		free(service->name);
+		free(service);
+		async_answer_0(iid, EEXISTS);
+		return;
+	}
+	
+	/* Get unique service ID */
+	service->id = loc_create_id();
+
+	loc_namespace_addref(namespace, service);
+	service->server = server;
+	
+	/* Insert service into list of all services  */
+	list_append(&service->services, &services_list);
+	
+	/* Insert service into list of services supplied by one server */
+	fibril_mutex_lock(&service->server->services_mutex);
+	
+	list_append(&service->server_services, &service->server->services);
+	
+	fibril_mutex_unlock(&service->server->services_mutex);
+	fibril_condvar_broadcast(&services_list_cv);
+	fibril_mutex_unlock(&services_list_mutex);
+	
+	async_answer_1(iid, EOK, service->id);
+}
+
+/**
+ *
+ */
+static int loc_service_unregister(ipc_callid_t iid, ipc_call_t *icall, 
+    loc_server_t *server)
+{
+	/* TODO */
+	return EOK;
+}
+
+/** Connect client to the service.
+ *
+ * Find server supplying requested service and forward
+ * the message to it.
+ *
+ */
+static void loc_forward(ipc_callid_t callid, ipc_call_t *call)
+{
+	fibril_mutex_lock(&services_list_mutex);
+	
+	/*
+	 * Get ID from request
+	 */
+	service_id_t id = IPC_GET_ARG2(*call);
+	loc_service_t *svc = loc_service_find_id(id);
+	
+	if ((svc == NULL) || (svc->server == NULL) || (!svc->server->sess)) {
+		fibril_mutex_unlock(&services_list_mutex);
+		async_answer_0(callid, ENOENT);
+		return;
+	}
+	
+	async_exch_t *exch = async_exchange_begin(svc->server->sess);
+	
+	if (svc->forward_interface == 0)
+		async_forward_fast(callid, exch, svc->id, 0, 0, IPC_FF_NONE);
+	else
+		async_forward_fast(callid, exch, svc->forward_interface,
+		    svc->id, 0, IPC_FF_NONE);
+	
+	async_exchange_end(exch);
+	
+	fibril_mutex_unlock(&services_list_mutex);
+}
+
+/** Find ID for service identified by name.
+ *
+ * In answer will be send EOK and service ID in arg1 or a error
+ * code from errno.h.
+ *
+ */
+static void loc_service_get_id(ipc_callid_t iid, ipc_call_t *icall)
+{
+	char *fqsn;
+	
+	/* Get fqsn */
+	int rc = async_data_write_accept((void **) &fqsn, true, 0,
+	    LOC_NAME_MAXLEN, 0, NULL);
+	if (rc != EOK) {
+		async_answer_0(iid, rc);
+		return;
+	}
+	
+	char *ns_name;
+	char *name;
+	if (!loc_fqsn_split(fqsn, &ns_name, &name)) {
+		free(fqsn);
+		async_answer_0(iid, EINVAL);
+		return;
+	}
+	
+	free(fqsn);
+	
+	fibril_mutex_lock(&services_list_mutex);
+	const loc_service_t *svc;
+	
+recheck:
+	
+	/*
+	 * Find service name in the list of known services.
+	 */
+	svc = loc_service_find_name(ns_name, name);
+	
+	/*
+	 * Device was not found.
+	 */
+	if (svc == NULL) {
+		if (IPC_GET_ARG1(*icall) & IPC_FLAG_BLOCKING) {
+			/* Blocking lookup */
+			fibril_condvar_wait(&services_list_cv,
+			    &services_list_mutex);
+			goto recheck;
+		}
+		
+		async_answer_0(iid, ENOENT);
+		free(ns_name);
+		free(name);
+		fibril_mutex_unlock(&services_list_mutex);
+		return;
+	}
+	
+	async_answer_1(iid, EOK, svc->id);
+	
+	fibril_mutex_unlock(&services_list_mutex);
+	free(ns_name);
+	free(name);
+}
+
+/** Find ID for namespace identified by name.
+ *
+ * In answer will be send EOK and service ID in arg1 or a error
+ * code from errno.h.
+ *
+ */
+static void loc_namespace_get_id(ipc_callid_t iid, ipc_call_t *icall)
+{
+	char *name;
+	
+	/* Get service name */
+	int rc = async_data_write_accept((void **) &name, true, 0,
+	    LOC_NAME_MAXLEN, 0, NULL);
+	if (rc != EOK) {
+		async_answer_0(iid, rc);
+		return;
+	}
+	
+	fibril_mutex_lock(&services_list_mutex);
+	const loc_namespace_t *namespace;
+	
+recheck:
+	
+	/*
+	 * Find namespace name in the list of known namespaces.
+	 */
+	namespace = loc_namespace_find_name(name);
+	
+	/*
+	 * Namespace was not found.
+	 */
+	if (namespace == NULL) {
+		if (IPC_GET_ARG1(*icall) & IPC_FLAG_BLOCKING) {
+			/* Blocking lookup */
+			fibril_condvar_wait(&services_list_cv,
+			    &services_list_mutex);
+			goto recheck;
+		}
+		
+		async_answer_0(iid, ENOENT);
+		free(name);
+		fibril_mutex_unlock(&services_list_mutex);
+		return;
+	}
+	
+	async_answer_1(iid, EOK, namespace->id);
+	
+	fibril_mutex_unlock(&services_list_mutex);
+	free(name);
+}
+
+static void loc_id_probe(ipc_callid_t iid, ipc_call_t *icall)
+{
+	fibril_mutex_lock(&services_list_mutex);
+	
+	loc_namespace_t *namespace =
+	    loc_namespace_find_id(IPC_GET_ARG1(*icall));
+	if (namespace == NULL) {
+		loc_service_t *svc =
+		    loc_service_find_id(IPC_GET_ARG1(*icall));
+		if (svc == NULL)
+			async_answer_1(iid, EOK, LOC_OBJECT_NONE);
+		else
+			async_answer_1(iid, EOK, LOC_OBJECT_SERVICE);
+	} else
+		async_answer_1(iid, EOK, LOC_OBJECT_NAMESPACE);
+	
+	fibril_mutex_unlock(&services_list_mutex);
+}
+
+static void loc_get_namespace_count(ipc_callid_t iid, ipc_call_t *icall)
+{
+	fibril_mutex_lock(&services_list_mutex);
+	async_answer_1(iid, EOK, list_count(&namespaces_list));
+	fibril_mutex_unlock(&services_list_mutex);
+}
+
+static void loc_get_service_count(ipc_callid_t iid, ipc_call_t *icall)
+{
+	fibril_mutex_lock(&services_list_mutex);
+	
+	loc_namespace_t *namespace =
+	    loc_namespace_find_id(IPC_GET_ARG1(*icall));
+	if (namespace == NULL)
+		async_answer_0(iid, EEXISTS);
+	else
+		async_answer_1(iid, EOK, namespace->refcnt);
+	
+	fibril_mutex_unlock(&services_list_mutex);
+}
+
+static void loc_get_namespaces(ipc_callid_t iid, ipc_call_t *icall)
+{
+	ipc_callid_t callid;
+	size_t size;
+	if (!async_data_read_receive(&callid, &size)) {
+		async_answer_0(callid, EREFUSED);
+		async_answer_0(iid, EREFUSED);
+		return;
+	}
+	
+	if ((size % sizeof(loc_sdesc_t)) != 0) {
+		async_answer_0(callid, EINVAL);
+		async_answer_0(iid, EINVAL);
+		return;
+	}
+	
+	fibril_mutex_lock(&services_list_mutex);
+	
+	size_t count = size / sizeof(loc_sdesc_t);
+	if (count != list_count(&namespaces_list)) {
+		fibril_mutex_unlock(&services_list_mutex);
+		async_answer_0(callid, EOVERFLOW);
+		async_answer_0(iid, EOVERFLOW);
+		return;
+	}
+	
+	loc_sdesc_t *desc = (loc_sdesc_t *) malloc(size);
+	if (desc == NULL) {
+		fibril_mutex_unlock(&services_list_mutex);
+		async_answer_0(callid, ENOMEM);
+		async_answer_0(iid, ENOMEM);
+		return;
+	}
+	
+	size_t pos = 0;
+	list_foreach(namespaces_list, item) {
+		loc_namespace_t *namespace =
+		    list_get_instance(item, loc_namespace_t, namespaces);
+		
+		desc[pos].id = namespace->id;
+		str_cpy(desc[pos].name, LOC_NAME_MAXLEN, namespace->name);
+		pos++;
+	}
+	
+	sysarg_t retval = async_data_read_finalize(callid, desc, size);
+	
+	free(desc);
+	fibril_mutex_unlock(&services_list_mutex);
+	
+	async_answer_0(iid, retval);
+}
+
+static void loc_get_services(ipc_callid_t iid, ipc_call_t *icall)
+{
+	/* FIXME: Use faster algorithm which can make better use
+	   of namespaces */
+	
+	ipc_callid_t callid;
+	size_t size;
+	if (!async_data_read_receive(&callid, &size)) {
+		async_answer_0(callid, EREFUSED);
+		async_answer_0(iid, EREFUSED);
+		return;
+	}
+	
+	if ((size % sizeof(loc_sdesc_t)) != 0) {
+		async_answer_0(callid, EINVAL);
+		async_answer_0(iid, EINVAL);
+		return;
+	}
+	
+	fibril_mutex_lock(&services_list_mutex);
+	
+	loc_namespace_t *namespace =
+	    loc_namespace_find_id(IPC_GET_ARG1(*icall));
+	if (namespace == NULL) {
+		fibril_mutex_unlock(&services_list_mutex);
+		async_answer_0(callid, ENOENT);
+		async_answer_0(iid, ENOENT);
+		return;
+	}
+	
+	size_t count = size / sizeof(loc_sdesc_t);
+	if (count != namespace->refcnt) {
+		fibril_mutex_unlock(&services_list_mutex);
+		async_answer_0(callid, EOVERFLOW);
+		async_answer_0(iid, EOVERFLOW);
+		return;
+	}
+	
+	loc_sdesc_t *desc = (loc_sdesc_t *) malloc(size);
+	if (desc == NULL) {
+		fibril_mutex_unlock(&services_list_mutex);
+		async_answer_0(callid, ENOMEM);
+		async_answer_0(iid, EREFUSED);
+		return;
+	}
+	
+	size_t pos = 0;
+	list_foreach(services_list, item) {
+		loc_service_t *service =
+		    list_get_instance(item, loc_service_t, services);
+		
+		if (service->namespace == namespace) {
+			desc[pos].id = service->id;
+			str_cpy(desc[pos].name, LOC_NAME_MAXLEN, service->name);
+			pos++;
+		}
+	}
+	
+	sysarg_t retval = async_data_read_finalize(callid, desc, size);
+	
+	free(desc);
+	fibril_mutex_unlock(&services_list_mutex);
+	
+	async_answer_0(iid, retval);
+}
+
+static void loc_null_create(ipc_callid_t iid, ipc_call_t *icall)
+{
+	fibril_mutex_lock(&null_services_mutex);
+	
+	unsigned int i;
+	bool fnd = false;
+	
+	for (i = 0; i < NULL_SERVICES; i++) {
+		if (null_services[i] == NULL) {
+			fnd = true;
+			break;
+		}
+	}
+	
+	if (!fnd) {
+		fibril_mutex_unlock(&null_services_mutex);
+		async_answer_0(iid, ENOMEM);
+		return;
+	}
+	
+	char null[LOC_NAME_MAXLEN];
+	snprintf(null, LOC_NAME_MAXLEN, "%u", i);
+	
+	char *dev_name = str_dup(null);
+	if (dev_name == NULL) {
+		fibril_mutex_unlock(&null_services_mutex);
+		async_answer_0(iid, ENOMEM);
+		return;
+	}
+	
+	loc_service_t *service =
+	    (loc_service_t *) malloc(sizeof(loc_service_t));
+	if (service == NULL) {
+		fibril_mutex_unlock(&null_services_mutex);
+		async_answer_0(iid, ENOMEM);
+		return;
+	}
+	
+	fibril_mutex_lock(&services_list_mutex);
+	
+	loc_namespace_t *namespace = loc_namespace_create("null");
+	if (namespace == NULL) {
+		fibril_mutex_lock(&services_list_mutex);
+		fibril_mutex_unlock(&null_services_mutex);
+		async_answer_0(iid, ENOMEM);
+		return;
+	}
+	
+	link_initialize(&service->services);
+	link_initialize(&service->server_services);
+	
+	/* Get unique service ID */
+	service->id = loc_create_id();
+	service->server = NULL;
+	
+	loc_namespace_addref(namespace, service);
+	service->name = dev_name;
+	
+	/*
+	 * Insert service into list of all services and into null services array.
+	 * Insert service into a dummy list of null server's services so that it
+	 * can be safely removed later.
+	 */
+	list_append(&service->services, &services_list);
+	list_append(&service->server_services, &dummy_null_services);
+	null_services[i] = service;
+	
+	fibril_mutex_unlock(&services_list_mutex);
+	fibril_mutex_unlock(&null_services_mutex);
+	
+	async_answer_1(iid, EOK, (sysarg_t) i);
+}
+
+static void loc_null_destroy(ipc_callid_t iid, ipc_call_t *icall)
+{
+	sysarg_t i = IPC_GET_ARG1(*icall);
+	if (i >= NULL_SERVICES) {
+		async_answer_0(iid, ELIMIT);
+		return;
+	}
+	
+	fibril_mutex_lock(&null_services_mutex);
+	
+	if (null_services[i] == NULL) {
+		fibril_mutex_unlock(&null_services_mutex);
+		async_answer_0(iid, ENOENT);
+		return;
+	}
+	
+	fibril_mutex_lock(&services_list_mutex);
+	loc_service_unregister_core(null_services[i]);
+	fibril_mutex_unlock(&services_list_mutex);
+	
+	null_services[i] = NULL;
+	
+	fibril_mutex_unlock(&null_services_mutex);
+	async_answer_0(iid, EOK);
+}
+
+/** Initialize location service.
+ *
+ *
+ */
+static bool loc_init(void)
+{
+	fibril_mutex_lock(&null_services_mutex);
+	
+	unsigned int i;
+	for (i = 0; i < NULL_SERVICES; i++)
+		null_services[i] = NULL;
+	
+	fibril_mutex_unlock(&null_services_mutex);
+	
+	return true;
+}
+
+/** Handle connection on supplier port.
+ *
+ */
+static void loc_connection_supplier(ipc_callid_t iid, ipc_call_t *icall)
+{
+	/* Accept connection */
+	async_answer_0(iid, EOK);
+	
+	loc_server_t *server = loc_server_register();
+	if (server == NULL)
+		return;
+	
+	while (true) {
+		ipc_call_t call;
+		ipc_callid_t callid = async_get_call(&call);
+		
+		if (!IPC_GET_IMETHOD(call))
+			break;
+		
+		switch (IPC_GET_IMETHOD(call)) {
+		case LOC_SERVER_UNREGISTER:
+			if (server == NULL)
+				async_answer_0(callid, ENOENT);
+			else
+				async_answer_0(callid, EOK);
+			break;
+		case LOC_SERVICE_REGISTER:
+			/* Register one service */
+			loc_service_register(callid, &call, server);
+			break;
+		case LOC_SERVICE_UNREGISTER:
+			/* Remove one service */
+			loc_service_unregister(callid, &call, server);
+			break;
+		case LOC_SERVICE_GET_ID:
+			loc_service_get_id(callid, &call);
+			break;
+		case LOC_NAMESPACE_GET_ID:
+			loc_namespace_get_id(callid, &call);
+			break;
+		default:
+			async_answer_0(callid, ENOENT);
+		}
+	}
+	
+	if (server != NULL) {
+		/*
+		 * Unregister the server and all its services.
+		 */
+		loc_server_unregister(server);
+		server = NULL;
+	}
+}
+
+/** Handle connection on consumer port.
+ *
+ */
+static void loc_connection_consumer(ipc_callid_t iid, ipc_call_t *icall)
+{
+	/* Accept connection */
+	async_answer_0(iid, EOK);
+	
+	while (true) {
+		ipc_call_t call;
+		ipc_callid_t callid = async_get_call(&call);
+		
+		if (!IPC_GET_IMETHOD(call))
+			break;
+		
+		switch (IPC_GET_IMETHOD(call)) {
+		case LOC_SERVICE_GET_ID:
+			loc_service_get_id(callid, &call);
+			break;
+		case LOC_NAMESPACE_GET_ID:
+			loc_namespace_get_id(callid, &call);
+			break;
+		case LOC_ID_PROBE:
+			loc_id_probe(callid, &call);
+			break;
+		case LOC_NULL_CREATE:
+			loc_null_create(callid, &call);
+			break;
+		case LOC_NULL_DESTROY:
+			loc_null_destroy(callid, &call);
+			break;
+		case LOC_GET_NAMESPACE_COUNT:
+			loc_get_namespace_count(callid, &call);
+			break;
+		case LOC_GET_SERVICE_COUNT:
+			loc_get_service_count(callid, &call);
+			break;
+		case LOC_GET_NAMESPACES:
+			loc_get_namespaces(callid, &call);
+			break;
+		case LOC_GET_SERVICES:
+			loc_get_services(callid, &call);
+			break;
+		default:
+			async_answer_0(callid, ENOENT);
+		}
+	}
+}
+
+/** Function for handling connections to location service
+ *
+ */
+static void loc_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
+{
+	/* Select interface */
+	switch ((sysarg_t) (IPC_GET_ARG1(*icall))) {
+	case LOC_PORT_SUPPLIER:
+		loc_connection_supplier(iid, icall);
+		break;
+	case LOC_PORT_CONSUMER:
+		loc_connection_consumer(iid, icall);
+		break;
+	case LOC_CONNECT_TO_SERVICE:
+		/* Connect client to selected service */
+		loc_forward(iid, icall);
+		break;
+	default:
+		/* No such interface */
+		async_answer_0(iid, ENOENT);
+	}
+}
+
+/**
+ *
+ */
+int main(int argc, char *argv[])
+{
+	printf("%s: HelenOS Location Service\n", NAME);
+	
+	if (!loc_init()) {
+		printf("%s: Error while initializing service\n", NAME);
+		return -1;
+	}
+	
+	/* Set a handler of incomming connections */
+	async_set_client_connection(loc_connection);
+	
+	/* Register location service at naming service */
+	if (service_register(SERVICE_LOC) != EOK)
+		return -1;
+	
+	printf("%s: Accepting connections\n", NAME);
+	async_manager();
+	
+	/* Never reached */
+	return 0;
+}
+
+/**
+ * @}
+ */
Index: uspace/srv/vfs/vfs.h
===================================================================
--- uspace/srv/vfs/vfs.h	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/vfs/vfs.h	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -38,5 +38,5 @@
 #include <fibril_synch.h>
 #include <sys/types.h>
-#include <devmap.h>
+#include <loc.h>
 #include <bool.h>
 #include <ipc/vfs.h>
@@ -61,5 +61,5 @@
 #define VFS_PAIR \
 	fs_handle_t fs_handle; \
-	devmap_handle_t devmap_handle;
+	service_id_t service_id;
 
 /**
@@ -67,5 +67,5 @@
  * doesn't contain any state. For a stateful structure, see vfs_node_t.
  *
- * @note	fs_handle, devmap_handle and index are meant to be returned in one
+ * @note	fs_handle, service_id and index are meant to be returned in one
  *		IPC reply.
  */
@@ -181,5 +181,5 @@
 extern void vfs_node_put(vfs_node_t *);
 extern void vfs_node_forget(vfs_node_t *);
-extern unsigned vfs_nodes_refcount_sum_get(fs_handle_t, devmap_handle_t);
+extern unsigned vfs_nodes_refcount_sum_get(fs_handle_t, service_id_t);
 
 
Index: uspace/srv/vfs/vfs_file.c
===================================================================
--- uspace/srv/vfs/vfs_file.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/vfs/vfs_file.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -115,5 +115,5 @@
 	
 	ipc_call_t answer;
-	aid_t msg = async_send_2(exch, VFS_OUT_CLOSE, file->node->devmap_handle,
+	aid_t msg = async_send_2(exch, VFS_OUT_CLOSE, file->node->service_id,
 	    file->node->index, &answer);
 	
Index: uspace/srv/vfs/vfs_lookup.c
===================================================================
--- uspace/srv/vfs/vfs_lookup.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/vfs/vfs_lookup.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -162,5 +162,5 @@
 	aid_t req = async_send_5(exch, VFS_OUT_LOOKUP, (sysarg_t) first,
 	    (sysarg_t) (first + len - 1) % PLB_SIZE,
-	    (sysarg_t) root->devmap_handle, (sysarg_t) lflag, (sysarg_t) index,
+	    (sysarg_t) root->service_id, (sysarg_t) lflag, (sysarg_t) index,
 	    &answer);
 	
@@ -185,5 +185,5 @@
 	
 	result->triplet.fs_handle = (fs_handle_t) rc;
-	result->triplet.devmap_handle = (devmap_handle_t) IPC_GET_ARG1(answer);
+	result->triplet.service_id = (service_id_t) IPC_GET_ARG1(answer);
 	result->triplet.index = (fs_index_t) IPC_GET_ARG2(answer);
 	result->size =
@@ -212,5 +212,5 @@
 	ipc_call_t answer;
 	aid_t req = async_send_2(exch, VFS_OUT_OPEN_NODE,
-	    (sysarg_t) result->triplet.devmap_handle,
+	    (sysarg_t) result->triplet.service_id,
 	    (sysarg_t) result->triplet.index, &answer);
 	
Index: uspace/srv/vfs/vfs_node.c
===================================================================
--- uspace/srv/vfs/vfs_node.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/vfs/vfs_node.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -116,5 +116,5 @@
 		unsigned long key[] = {
 			[KEY_FS_HANDLE] = node->fs_handle,
-			[KEY_DEV_HANDLE] = node->devmap_handle,
+			[KEY_DEV_HANDLE] = node->service_id,
 			[KEY_INDEX] = node->index
 		};
@@ -138,5 +138,5 @@
 		async_exch_t *exch = vfs_exchange_grab(node->fs_handle);
 		sysarg_t rc = async_req_2_0(exch, VFS_OUT_DESTROY,
-		    (sysarg_t) node->devmap_handle, (sysarg_t)node->index);
+		    (sysarg_t) node->service_id, (sysarg_t)node->index);
 		
 		assert(rc == EOK);
@@ -160,5 +160,5 @@
 	unsigned long key[] = {
 		[KEY_FS_HANDLE] = node->fs_handle,
-		[KEY_DEV_HANDLE] = node->devmap_handle,
+		[KEY_DEV_HANDLE] = node->service_id,
 		[KEY_INDEX] = node->index
 	};
@@ -184,5 +184,5 @@
 	unsigned long key[] = {
 		[KEY_FS_HANDLE] = result->triplet.fs_handle,
-		[KEY_DEV_HANDLE] = result->triplet.devmap_handle,
+		[KEY_DEV_HANDLE] = result->triplet.service_id,
 		[KEY_INDEX] = result->triplet.index
 	};
@@ -200,5 +200,5 @@
 		memset(node, 0, sizeof(vfs_node_t));
 		node->fs_handle = result->triplet.fs_handle;
-		node->devmap_handle = result->triplet.devmap_handle;
+		node->service_id = result->triplet.service_id;
 		node->index = result->triplet.index;
 		node->size = result->size;
@@ -252,5 +252,5 @@
 	vfs_node_t *node = hash_table_get_instance(item, vfs_node_t, nh_link);
 	return (node->fs_handle == (fs_handle_t) key[KEY_FS_HANDLE]) &&
-	    (node->devmap_handle == key[KEY_DEV_HANDLE]) &&
+	    (node->service_id == key[KEY_DEV_HANDLE]) &&
 	    (node->index == key[KEY_INDEX]);
 }
@@ -264,5 +264,5 @@
 	unsigned refcnt;
 	fs_handle_t fs_handle;
-	devmap_handle_t devmap_handle;
+	service_id_t service_id;
 };
 
@@ -273,15 +273,15 @@
 
 	if ((node->fs_handle == rd->fs_handle) &&
-	    (node->devmap_handle == rd->devmap_handle))
+	    (node->service_id == rd->service_id))
 		rd->refcnt += node->refcnt;
 }
 
 unsigned
-vfs_nodes_refcount_sum_get(fs_handle_t fs_handle, devmap_handle_t devmap_handle)
+vfs_nodes_refcount_sum_get(fs_handle_t fs_handle, service_id_t service_id)
 {
 	struct refcnt_data rd = {
 		.refcnt = 0,
 		.fs_handle = fs_handle,
-		.devmap_handle = devmap_handle
+		.service_id = service_id
 	};
 
Index: uspace/srv/vfs/vfs_ops.c
===================================================================
--- uspace/srv/vfs/vfs_ops.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/vfs/vfs_ops.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -54,5 +54,5 @@
 
 /* Forward declarations of static functions. */
-static int vfs_truncate_internal(fs_handle_t, devmap_handle_t, fs_index_t,
+static int vfs_truncate_internal(fs_handle_t, service_id_t, fs_index_t,
     aoff64_t);
 
@@ -65,8 +65,8 @@
 vfs_pair_t rootfs = {
 	.fs_handle = 0,
-	.devmap_handle = 0
+	.service_id = 0
 };
 
-static void vfs_mount_internal(ipc_callid_t rid, devmap_handle_t devmap_handle,
+static void vfs_mount_internal(ipc_callid_t rid, service_id_t service_id,
     fs_handle_t fs_handle, char *mp, char *opts)
 {
@@ -125,5 +125,5 @@
 			exch = vfs_exchange_grab(fs_handle);
 			msg = async_send_1(exch, VFS_OUT_MOUNTED,
-			    (sysarg_t) devmap_handle, &answer);
+			    (sysarg_t) service_id, &answer);
 			/* Send the mount options */
 			rc = async_data_write_start(exch, (void *)opts,
@@ -150,5 +150,5 @@
 			
 			mr_res.triplet.fs_handle = fs_handle;
-			mr_res.triplet.devmap_handle = devmap_handle;
+			mr_res.triplet.service_id = service_id;
 			mr_res.triplet.index = rindex;
 			mr_res.size = rsize;
@@ -157,5 +157,5 @@
 			
 			rootfs.fs_handle = fs_handle;
-			rootfs.devmap_handle = devmap_handle;
+			rootfs.service_id = service_id;
 			
 			/* Add reference to the mounted root. */
@@ -178,6 +178,6 @@
 	
 	/*
-	 * At this point, we have all necessary pieces: file system and device
-	 * handles, and we know the mount point VFS node.
+	 * At this point, we have all necessary pieces: file system handle
+	 * and service ID, and we know the mount point VFS node.
 	 */
 	
@@ -187,8 +187,8 @@
 	exch = vfs_exchange_grab(mp_res.triplet.fs_handle);
 	msg = async_send_4(exch, VFS_OUT_MOUNT,
-	    (sysarg_t) mp_res.triplet.devmap_handle,
+	    (sysarg_t) mp_res.triplet.service_id,
 	    (sysarg_t) mp_res.triplet.index,
 	    (sysarg_t) fs_handle,
-	    (sysarg_t) devmap_handle, &answer);
+	    (sysarg_t) service_id, &answer);
 	
 	/* Send connection */
@@ -233,5 +233,5 @@
 		
 		mr_res.triplet.fs_handle = fs_handle;
-		mr_res.triplet.devmap_handle = devmap_handle;
+		mr_res.triplet.service_id = service_id;
 		mr_res.triplet.index = rindex;
 		mr_res.size = rsize;
@@ -254,5 +254,5 @@
 void vfs_mount(ipc_callid_t rid, ipc_call_t *request)
 {
-	devmap_handle_t devmap_handle;
+	service_id_t service_id;
 
 	/*
@@ -261,5 +261,5 @@
 	 * in the request.
 	 */
-	devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request);
+	service_id = (service_id_t) IPC_GET_ARG1(*request);
 	
 	/*
@@ -349,5 +349,5 @@
 	
 	/* Do the mount */
-	vfs_mount_internal(rid, devmap_handle, fs_handle, mp, opts);
+	vfs_mount_internal(rid, service_id, fs_handle, mp, opts);
 	free(mp);
 	free(fs_name);
@@ -408,5 +408,5 @@
 	 */
 	if (vfs_nodes_refcount_sum_get(mr_node->fs_handle,
-	    mr_node->devmap_handle) != 2) {
+	    mr_node->service_id) != 2) {
 		fibril_rwlock_write_unlock(&namespace_rwlock);
 		vfs_node_put(mr_node);
@@ -429,5 +429,5 @@
 		exch = vfs_exchange_grab(mr_node->fs_handle);
 		rc = async_req_1_0(exch, VFS_OUT_UNMOUNTED,
-		    mr_node->devmap_handle);
+		    mr_node->service_id);
 		vfs_exchange_release(exch);
 		
@@ -440,5 +440,5 @@
 		
 		rootfs.fs_handle = 0;
-		rootfs.devmap_handle = 0;
+		rootfs.service_id = 0;
 	} else {
 		
@@ -469,5 +469,5 @@
 		exch = vfs_exchange_grab(mp_node->fs_handle);
 		rc = async_req_2_0(exch, VFS_OUT_UNMOUNT,
-		    mp_node->devmap_handle, mp_node->index);
+		    mp_node->service_id, mp_node->index);
 		vfs_exchange_release(exch);
 		
@@ -574,5 +574,5 @@
 		if (node->size) {
 			rc = vfs_truncate_internal(node->fs_handle,
-			    node->devmap_handle, node->index, 0);
+			    node->service_id, node->index, 0);
 			if (rc) {
 				fibril_rwlock_write_unlock(&node->contents_rwlock);
@@ -627,5 +627,5 @@
 	
 	lr.triplet.fs_handle = IPC_GET_ARG1(*request);
-	lr.triplet.devmap_handle = IPC_GET_ARG2(*request);
+	lr.triplet.service_id = IPC_GET_ARG2(*request);
 	lr.triplet.index = IPC_GET_ARG3(*request);
 	int oflag = IPC_GET_ARG4(*request);
@@ -648,5 +648,5 @@
 		if (node->size) {
 			rc = vfs_truncate_internal(node->fs_handle,
-			    node->devmap_handle, node->index, 0);
+			    node->service_id, node->index, 0);
 			if (rc) {
 				fibril_rwlock_write_unlock(&node->contents_rwlock);
@@ -711,5 +711,5 @@
 	aid_t msg;
 	ipc_call_t answer;
-	msg = async_send_2(fs_exch, VFS_OUT_SYNC, file->node->devmap_handle,
+	msg = async_send_2(fs_exch, VFS_OUT_SYNC, file->node->service_id,
 	    file->node->index, &answer);
 	
@@ -796,5 +796,5 @@
 	if (read) {
 		rc = async_data_read_forward_3_1(fs_exch, VFS_OUT_READ,
-		    file->node->devmap_handle, file->node->index, file->pos,
+		    file->node->service_id, file->node->index, file->pos,
 		    &answer);
 	} else {
@@ -803,5 +803,5 @@
 		
 		rc = async_data_write_forward_3_1(fs_exch, VFS_OUT_WRITE,
-		    file->node->devmap_handle, file->node->index, file->pos,
+		    file->node->service_id, file->node->index, file->pos,
 		    &answer);
 	}
@@ -933,10 +933,10 @@
 }
 
-int vfs_truncate_internal(fs_handle_t fs_handle, devmap_handle_t devmap_handle,
+int vfs_truncate_internal(fs_handle_t fs_handle, service_id_t service_id,
     fs_index_t index, aoff64_t size)
 {
 	async_exch_t *exch = vfs_exchange_grab(fs_handle);
 	sysarg_t rc = async_req_4_0(exch, VFS_OUT_TRUNCATE,
-	    (sysarg_t) devmap_handle, (sysarg_t) index, LOWER32(size),
+	    (sysarg_t) service_id, (sysarg_t) index, LOWER32(size),
 	    UPPER32(size));
 	vfs_exchange_release(exch);
@@ -961,5 +961,5 @@
 	fibril_rwlock_write_lock(&file->node->contents_rwlock);
 	rc = vfs_truncate_internal(file->node->fs_handle,
-	    file->node->devmap_handle, file->node->index, size);
+	    file->node->service_id, file->node->index, size);
 	if (rc == EOK)
 		file->node->size = size;
@@ -995,5 +995,5 @@
 	
 	aid_t msg;
-	msg = async_send_3(exch, VFS_OUT_STAT, file->node->devmap_handle,
+	msg = async_send_3(exch, VFS_OUT_STAT, file->node->service_id,
 	    file->node->index, true, NULL);
 	async_forward_fast(callid, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
@@ -1048,5 +1048,5 @@
 	
 	aid_t msg;
-	msg = async_send_3(exch, VFS_OUT_STAT, node->devmap_handle,
+	msg = async_send_3(exch, VFS_OUT_STAT, node->service_id,
 	    node->index, false, NULL);
 	async_forward_fast(callid, exch, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
@@ -1225,5 +1225,5 @@
 	/* Check whether linking to the same file system instance. */
 	if ((old_node->fs_handle != new_par_lr.triplet.fs_handle) ||
-	    (old_node->devmap_handle != new_par_lr.triplet.devmap_handle)) {
+	    (old_node->service_id != new_par_lr.triplet.service_id)) {
 		fibril_rwlock_write_unlock(&namespace_rwlock);
 		vfs_node_put(old_node);
Index: uspace/srv/vfs/vfs_register.c
===================================================================
--- uspace/srv/vfs/vfs_register.c	(revision ef09a7ad92d2a727ade3cc5c9a88b9b28ec9a98b)
+++ uspace/srv/vfs/vfs_register.c	(revision 15f3c3fbb3cd87db466db2f9b1379fe5b0794299)
@@ -306,5 +306,5 @@
 	list_foreach(fs_list, cur) {
 		fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link);
-		if (str_cmp(fs->vfs_info.name, name) == 0) { 
+		if (str_cmp(fs->vfs_info.name, name) == 0) {
 			handle = fs->fs_handle;
 			break;
