Index: uspace/lib/libblock/libblock.c
===================================================================
--- uspace/lib/libblock/libblock.c	(revision 5cf723b0f447edb54b15926eb1388300785f7859)
+++ uspace/lib/libblock/libblock.c	(revision 7858bc5ff895eb1e87b5c19c5e2ca2a23717133a)
@@ -39,5 +39,8 @@
 #include "../../srv/vfs/vfs.h"
 #include "../../srv/rd/rd.h"
+#include <ipc/devmap.h>
+#include <ipc/services.h>
 #include <errno.h>
+#include <sys/mman.h>
 #include <async.h>
 #include <ipc/ipc.h>
@@ -45,8 +48,71 @@
 #include <assert.h>
 
+static int dev_phone = -1;		/* FIXME */
+static void *dev_buffer = NULL;		/* FIXME */
+static size_t dev_buffer_len = 0;	/* FIXME */
+static void *bblock = NULL;		/* FIXME */
+
+int
+block_init(dev_handle_t dev_handle, size_t com_size, off_t bb_off,
+    size_t bb_size)
+{
+	int rc;
+
+	bblock = malloc(bb_size);
+	if (!bblock)
+		return ENOMEM;
+	dev_buffer_len = com_size;
+	dev_buffer = mmap(NULL, com_size, PROTO_READ | PROTO_WRITE,
+	    MAP_ANONYMOUS | MAP_PRIVATE, 0, 0);
+	if (!dev_buffer) {
+		free(bblock);
+		return ENOMEM;
+	}
+	dev_phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP,
+	    DEVMAP_CONNECT_TO_DEVICE, dev_handle);
+
+	if (dev_phone < 0) {
+		free(bblock);
+		munmap(dev_buffer, com_size);
+		return dev_phone;
+	}
+
+	rc = ipc_share_out_start(dev_phone, dev_buffer,
+	    AS_AREA_READ | AS_AREA_WRITE);
+	if (rc != EOK) {
+		ipc_hangup(dev_phone);
+		free(bblock);
+	    	munmap(dev_buffer, com_size);
+		return rc;
+	}
+	off_t bufpos = 0;
+	size_t buflen = 0;
+	if (!block_read(dev_handle, &bufpos, &buflen, &bb_off,
+	    bblock, bb_size, bb_size)) {
+	    	ipc_hangup(dev_phone);
+	    	free(bblock);
+		munmap(dev_buffer, com_size);
+		return EIO;	/* XXX real error code */
+	}
+	return EOK;
+}
+
+void block_fini(dev_handle_t dev_handle)
+{
+	/* XXX */
+	free(bblock);
+	munmap(dev_buffer, dev_buffer_len);
+	ipc_hangup(dev_phone);
+}
+
+void *block_bb_get(dev_handle_t dev_handle)
+{
+	/* XXX */
+	return bblock;
+}
+
 /** Read data from a block device.
  *
- * @param phone		Phone to be used to communicate with the device.
- * @param buffer	Communication buffer shared with the device.
+ * @param dev_handle	Device handle of the block device.
  * @param bufpos	Pointer to the first unread valid offset within the
  * 			communication buffer.
@@ -60,6 +126,7 @@
  * @return		True on success, false on failure.
  */
-bool blockread(int phone, void *buffer, off_t *bufpos, size_t *buflen,
-    off_t *pos, void *dst, size_t size, size_t block_size)
+bool
+block_read(int dev_handle, off_t *bufpos, size_t *buflen, off_t *pos, void *dst,
+    size_t size, size_t block_size)
 {
 	off_t offset = 0;
@@ -79,5 +146,5 @@
 			 * destination buffer.
 			 */
-			memcpy(dst + offset, buffer + *bufpos, rd);
+			memcpy(dst + offset, dev_buffer + *bufpos, rd);
 			offset += rd;
 			*bufpos += rd;
@@ -89,5 +156,5 @@
 			/* Refill the communication buffer with a new block. */
 			ipcarg_t retval;
-			int rc = async_req_2_1(phone, RD_READ_BLOCK,
+			int rc = async_req_2_1(dev_phone, RD_READ_BLOCK,
 			    *pos / block_size, block_size, &retval);
 			if ((rc != EOK) || (retval != EOK))
@@ -101,7 +168,4 @@
 	return true;
 }
-
-int dev_phone = -1;		/* FIXME */
-void *dev_buffer = NULL;	/* FIXME */
 
 block_t *block_get(dev_handle_t dev_handle, off_t offset, size_t bs)
@@ -127,5 +191,5 @@
 	b->size = bs;
 
-	if (!blockread(dev_phone, dev_buffer, &bufpos, &buflen, &pos, b->data,
+	if (!block_read(dev_handle, &bufpos, &buflen, &pos, b->data,
 	    bs, bs)) {
 		free(b->data);
Index: uspace/lib/libblock/libblock.h
===================================================================
--- uspace/lib/libblock/libblock.h	(revision 5cf723b0f447edb54b15926eb1388300785f7859)
+++ uspace/lib/libblock/libblock.h	(revision 7858bc5ff895eb1e87b5c19c5e2ca2a23717133a)
@@ -68,12 +68,12 @@
 } block_t;
 
-extern int dev_phone;		/* FIXME */
-extern void *dev_buffer;	/* FIXME */
+extern int block_init(dev_handle_t, size_t, off_t, size_t);
+extern void block_fini(dev_handle_t);
+extern void *block_bb_get(dev_handle_t);
 
 extern block_t *block_get(dev_handle_t, off_t, size_t);
 extern void block_put(block_t *);
 
-extern bool blockread(int, void *, off_t *, size_t *, off_t *, void *, size_t,
-    size_t);
+extern bool block_read(int, off_t *, size_t *, off_t *, void *, size_t, size_t);
 
 #endif
Index: uspace/lib/libc/include/errno.h
===================================================================
--- uspace/lib/libc/include/errno.h	(revision 5cf723b0f447edb54b15926eb1388300785f7859)
+++ uspace/lib/libc/include/errno.h	(revision 7858bc5ff895eb1e87b5c19c5e2ca2a23717133a)
@@ -47,4 +47,5 @@
 #define ERANGE		(-263)
 #define EXDEV		(-264)
+#define EIO		(-265)
 
 #endif
