Index: boot/Makefile.common
===================================================================
--- boot/Makefile.common	(revision 812355884f3878eb249907e2c43d2db6a913e1ff)
+++ boot/Makefile.common	(revision fb623e2feb545b72f2f3dca3e41febed93271cf4)
@@ -48,4 +48,5 @@
 	$(USPACEDIR)/srv/kbd/kbd \
 	$(USPACEDIR)/srv/console/console \
+	$(USPACEDIR)/srv/clip/clip \
 	$(USPACEDIR)/srv/fs/devfs/devfs \
 	$(USPACEDIR)/srv/fs/tmpfs/tmpfs \
Index: uspace/Makefile
===================================================================
--- uspace/Makefile	(revision 812355884f3878eb249907e2c43d2db6a913e1ff)
+++ uspace/Makefile	(revision fb623e2feb545b72f2f3dca3e41febed93271cf4)
@@ -48,4 +48,5 @@
 	srv/devmap \
 	srv/part/mbr_part \
+	srv/clip \
 	app/edit \
 	app/tetris \
Index: uspace/app/init/init.c
===================================================================
--- uspace/app/init/init.c	(revision 812355884f3878eb249907e2c43d2db6a913e1ff)
+++ uspace/app/init/init.c	(revision fb623e2feb545b72f2f3dca3e41febed93271cf4)
@@ -235,4 +235,5 @@
 	spawn("/srv/kbd");
 	spawn("/srv/console");
+	spawn("/srv/clip");
 	spawn("/srv/fhc");
 	spawn("/srv/obio");
Index: uspace/lib/libc/generic/clipboard.c
===================================================================
--- uspace/lib/libc/generic/clipboard.c	(revision 812355884f3878eb249907e2c43d2db6a913e1ff)
+++ uspace/lib/libc/generic/clipboard.c	(revision fb623e2feb545b72f2f3dca3e41febed93271cf4)
@@ -33,65 +33,72 @@
  * @brief System clipboard API.
  *
- * The clipboard data is stored in a file and it is shared by the entire
- * system.
+ * The clipboard data is managed by the clipboard service and it is shared by
+ * the entire system.
  *
- * @note Synchronization is missing. File locks would be ideal for the job.
  */
 
-#include <stdlib.h>
+#include <clipboard.h>
+#include <ipc/services.h>
+#include <ipc/clipboard.h>
+#include <async.h>
 #include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <macros.h>
 #include <errno.h>
-#include <clipboard.h>
+#include <malloc.h>
 
-/** File used to store clipboard data */
-#define CLIPBOARD_FILE "/data/clip"
+static int clip_phone = -1;
 
-#define CHUNK_SIZE	4096
+/** Connect to clipboard server
+ *
+ */
+static void clip_connect(void)
+{
+	while (clip_phone < 0)
+		clip_phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_CLIPBOARD, 0, 0);
+}
 
 /** Copy string to clipboard.
  *
  * Sets the clipboard contents to @a str. Passing an empty string or NULL
- * makes the clipboard empty. 
+ * makes the clipboard empty.
  *
- * @param str	String to put to clipboard or NULL.
- * @return	Zero on success or negative error code.
+ * @param str String to put to clipboard or NULL.
+ *
+ * @return Zero on success or negative error code.
+ *
  */
 int clipboard_put_str(const char *str)
 {
-	int fd;
-	const char *sp;
-	ssize_t to_write, written, left;
-
-	fd = open(CLIPBOARD_FILE, O_CREAT | O_TRUNC | O_WRONLY, 0666);
-	if (fd < 0)
-		return EIO;
-
-	left = str_size(str);
-	sp = str;
-
-	while (left > 0) {
-		to_write = min(left, CHUNK_SIZE);
-		written = write(fd, sp, to_write);
-
-		if (written < 0) {
-			close(fd);
-			unlink(CLIPBOARD_FILE);
-			return EIO;
+	size_t size = str_size(str);
+	
+	if (size == 0) {
+		async_serialize_start();
+		clip_connect();
+		
+		ipcarg_t rc = async_req_1_0(clip_phone, CLIPBOARD_PUT_DATA, CLIPBOARD_TAG_NONE);
+		
+		async_serialize_end();
+		
+		return (int) rc;
+	} else {
+		async_serialize_start();
+		clip_connect();
+		
+		aid_t req = async_send_1(clip_phone, CLIPBOARD_PUT_DATA, CLIPBOARD_TAG_BLOB, NULL);
+		ipcarg_t rc = async_data_write_start(clip_phone, (void *) str, size);
+		if (rc != EOK) {
+			ipcarg_t rc_orig;
+			async_wait_for(req, &rc_orig);
+			async_serialize_end();
+			if (rc_orig == EOK)
+				return (int) rc;
+			else
+				return (int) rc_orig;
 		}
-
-		sp += written;
-		left -= written;
+		
+		async_wait_for(req, &rc);
+		async_serialize_end();
+		
+		return (int) rc;
 	}
-
-	if (close(fd) != EOK) {
-		unlink(CLIPBOARD_FILE);
-		return EIO;
-	}
-
-	return EOK;
 }
 
@@ -100,50 +107,77 @@
  * Returns a new string that can be deallocated with free().
  *
- * @param str	Here pointer to the newly allocated string is stored.
- * @return	Zero on success or negative error code.
+ * @param str Here pointer to the newly allocated string is stored.
+ *
+ * @return Zero on success or negative error code.
+ *
  */
 int clipboard_get_str(char **str)
 {
-	int fd;
-	char *sbuf, *sp;
-	ssize_t to_read, n_read, left;
-	struct stat cbs;
-
-	if (stat(CLIPBOARD_FILE, &cbs) != EOK)
-		return EIO;
-
-	sbuf = malloc(cbs.size + 1);
-	if (sbuf == NULL)
-		return ENOMEM;
-
-	fd = open(CLIPBOARD_FILE, O_RDONLY);
-	if (fd < 0) {
-		free(sbuf);
-		return EIO;
+	/* Loop until clipboard read succesful */
+	while (true) {
+		async_serialize_start();
+		clip_connect();
+		
+		ipcarg_t size;
+		ipcarg_t tag;
+		ipcarg_t rc = async_req_0_2(clip_phone, CLIPBOARD_CONTENT, &size, &tag);
+		
+		async_serialize_end();
+		
+		if (rc != EOK)
+			return (int) rc;
+		
+		char *sbuf;
+		
+		switch (tag) {
+		case CLIPBOARD_TAG_NONE:
+			sbuf = malloc(1);
+			if (sbuf == NULL)
+				return ENOMEM;
+			
+			sbuf[0] = 0;
+			*str = sbuf;
+			return EOK;
+		case CLIPBOARD_TAG_BLOB:
+			sbuf = malloc(size + 1);
+			if (sbuf == NULL)
+				return ENOMEM;
+			
+			async_serialize_start();
+			
+			aid_t req = async_send_1(clip_phone, CLIPBOARD_GET_DATA, tag, NULL);
+			rc = async_data_read_start(clip_phone, (void *) sbuf, size);
+			if (rc == EOVERFLOW) {
+				/*
+				 * The data in the clipboard has changed since
+				 * the last call of CLIPBOARD_CONTENT
+				 */
+				async_serialize_end();
+				break;
+			}
+			
+			if (rc != EOK) {
+				ipcarg_t rc_orig;
+				async_wait_for(req, &rc_orig);
+				async_serialize_end();
+				if (rc_orig == EOK)
+					return (int) rc;
+				else
+					return (int) rc_orig;
+			}
+			
+			async_wait_for(req, &rc);
+			async_serialize_end();
+			
+			if (rc == EOK) {
+				sbuf[size] = 0;
+				*str = sbuf;
+			}
+			
+			return rc;
+		default:
+			return EINVAL;
+		}
 	}
-
-	sp = sbuf;
-	left = cbs.size;
-
-	while (left > 0) {
-		to_read = min(left, CHUNK_SIZE);
-		n_read = read(fd, sp, to_read);
-
-		if (n_read < 0) {
-			close(fd);
-			free(sbuf);
-			return EIO;
-		}
-
-		sp += n_read;
-		left -= n_read;
-	}
-
-	close(fd);
-
-	*sp = '\0';
-	*str = sbuf;
-
-	return EOK;
 }
 
Index: uspace/lib/libc/include/ipc/clipboard.h
===================================================================
--- uspace/lib/libc/include/ipc/clipboard.h	(revision fb623e2feb545b72f2f3dca3e41febed93271cf4)
+++ uspace/lib/libc/include/ipc/clipboard.h	(revision fb623e2feb545b72f2f3dca3e41febed93271cf4)
@@ -0,0 +1,54 @@
+/*
+ * 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 libcipc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_IPC_CLIPBOARD_H_
+#define LIBC_IPC_CLIPBOARD_H_
+
+#include <ipc/ipc.h>
+
+typedef enum {
+	CLIPBOARD_PUT_DATA = IPC_FIRST_USER_METHOD,
+	CLIPBOARD_GET_DATA,
+	CLIPBOARD_CONTENT
+} clipboard_request_t;
+
+typedef enum {
+	CLIPBOARD_TAG_NONE,
+	CLIPBOARD_TAG_BLOB
+} clipboard_tag_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/libc/include/ipc/services.h
===================================================================
--- uspace/lib/libc/include/ipc/services.h	(revision 812355884f3878eb249907e2c43d2db6a913e1ff)
+++ uspace/lib/libc/include/ipc/services.h	(revision fb623e2feb545b72f2f3dca3e41febed93271cf4)
@@ -47,5 +47,6 @@
 	SERVICE_DEVMAP,
 	SERVICE_FHC,
-	SERVICE_OBIO
+	SERVICE_OBIO,
+	SERVICE_CLIPBOARD
 } services_t;
 
Index: uspace/srv/clip/Makefile
===================================================================
--- uspace/srv/clip/Makefile	(revision fb623e2feb545b72f2f3dca3e41febed93271cf4)
+++ uspace/srv/clip/Makefile	(revision fb623e2feb545b72f2f3dca3e41febed93271cf4)
@@ -0,0 +1,39 @@
+#
+# 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.
+#
+
+include Makefile.common
+
+.PHONY: all clean
+
+all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS)
+	-[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
+	$(MAKE) -f Makefile.build
+
+clean:
+	rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm
+	find . -name '*.o' -follow -exec rm \{\} \;
Index: uspace/srv/clip/Makefile.build
===================================================================
--- uspace/srv/clip/Makefile.build	(revision fb623e2feb545b72f2f3dca3e41febed93271cf4)
+++ uspace/srv/clip/Makefile.build	(revision fb623e2feb545b72f2f3dca3e41febed93271cf4)
@@ -0,0 +1,62 @@
+#
+# 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.
+#
+
+## Setup toolchain
+#
+
+include Makefile.common
+include $(LIBC_PREFIX)/Makefile.toolchain
+
+## Sources
+#
+
+SOURCES = \
+	clip.c
+
+CFLAGS += -D$(UARCH)
+
+OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
+
+.PHONY: all
+
+all: $(OUTPUT) $(OUTPUT).disasm
+
+-include $(DEPEND)
+
+$(OUTPUT).disasm: $(OUTPUT)
+	$(OBJDUMP) -d $< > $@
+
+$(OUTPUT): $(OBJECTS) $(LIBS)
+	$(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map
+
+%.o: %.c $(DEPEND)
+	$(CC) $(DEFS) $(CFLAGS) -c $< -o $@
+
+$(DEPEND):
+	makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) -- $(SOURCES) > $@ 2> /dev/null
+	-[ -f $(DEPEND_PREV) ] && diff -q $(DEPEND_PREV) $@ && mv -f $(DEPEND_PREV) $@
Index: uspace/srv/clip/Makefile.common
===================================================================
--- uspace/srv/clip/Makefile.common	(revision fb623e2feb545b72f2f3dca3e41febed93271cf4)
+++ uspace/srv/clip/Makefile.common	(revision fb623e2feb545b72f2f3dca3e41febed93271cf4)
@@ -0,0 +1,39 @@
+#
+# 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.
+#
+
+
+## Common names
+#
+
+LIBC_PREFIX = ../../lib/libc
+SOFTINT_PREFIX = ../../lib/softint
+LIBS = $(LIBC_PREFIX)/libc.a
+
+DEPEND = Makefile.depend
+DEPEND_PREV = $(DEPEND).prev
+OUTPUT = clip
Index: uspace/srv/clip/clip.c
===================================================================
--- uspace/srv/clip/clip.c	(revision fb623e2feb545b72f2f3dca3e41febed93271cf4)
+++ uspace/srv/clip/clip.c	(revision fb623e2feb545b72f2f3dca3e41febed93271cf4)
@@ -0,0 +1,208 @@
+/*
+ * 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.
+ */
+
+#include <stdio.h>
+#include <bool.h>
+#include <ipc/ipc.h>
+#include <async.h>
+#include <ipc/services.h>
+#include <ipc/clipboard.h>
+#include <malloc.h>
+#include <fibril_sync.h>
+#include <errno.h>
+
+#define NAME  "clip"
+
+static char *clip_data = NULL;
+static size_t clip_size = 0;
+static clipboard_tag_t clip_tag = CLIPBOARD_TAG_NONE;
+static FIBRIL_MUTEX_INITIALIZE(clip_mtx);
+
+static void clip_put_data(ipc_callid_t rid, ipc_call_t *request)
+{
+	ipc_callid_t callid;
+	size_t size;
+	
+	switch (IPC_GET_ARG1(*request)) {
+	case CLIPBOARD_TAG_NONE:
+		fibril_mutex_lock(&clip_mtx);
+		
+		if (clip_data)
+			free(clip_data);
+		
+		clip_data = NULL;
+		clip_size = 0;
+		clip_tag = CLIPBOARD_TAG_NONE;
+		
+		fibril_mutex_unlock(&clip_mtx);
+		ipc_answer_0(rid, EOK);
+		break;
+	case CLIPBOARD_TAG_BLOB:
+		if (!async_data_write_receive(&callid, &size)) {
+			ipc_answer_0(callid, EINVAL);
+			ipc_answer_0(rid, EINVAL);
+			break;
+		}
+		
+		char *data = malloc(size);
+		if (!data) {
+			ipc_answer_0(callid, ENOMEM);
+			ipc_answer_0(rid, ENOMEM);
+			break;
+		}
+		
+		ipcarg_t retval = async_data_write_finalize(callid, data, size);
+		if (retval != EOK) {
+			ipc_answer_0(rid, retval);
+			free(data);
+			break;
+		}
+		
+		fibril_mutex_lock(&clip_mtx);
+		
+		if (clip_data)
+			free(clip_data);
+		
+		clip_data = data;
+		clip_size = size;
+		clip_tag = CLIPBOARD_TAG_BLOB;
+		
+		fibril_mutex_unlock(&clip_mtx);
+		ipc_answer_0(rid, EOK);
+		break;
+	default:
+		ipc_answer_0(rid, EINVAL);
+	}
+}
+
+static void clip_get_data(ipc_callid_t rid, ipc_call_t *request)
+{
+	fibril_mutex_lock(&clip_mtx);
+	
+	ipc_callid_t callid;
+	size_t size;
+	
+	/* Check for clipboard data tag compatibility */
+	switch (IPC_GET_ARG1(*request)) {
+	case CLIPBOARD_TAG_BLOB:
+		if (!async_data_read_receive(&callid, &size)) {
+			ipc_answer_0(callid, EINVAL);
+			ipc_answer_0(rid, EINVAL);
+			break;
+		}
+		
+		if (clip_tag != CLIPBOARD_TAG_BLOB) {
+			/* So far we only understand BLOB */
+			ipc_answer_0(callid, EOVERFLOW);
+			ipc_answer_0(rid, EOVERFLOW);
+			break;
+		}
+		
+		if (clip_size != size) {
+			/* The client expects different size of data */
+			ipc_answer_0(callid, EOVERFLOW);
+			ipc_answer_0(rid, EOVERFLOW);
+			break;
+		}
+		
+		ipcarg_t retval = async_data_read_finalize(callid, clip_data, size);
+		if (retval != EOK) {
+			ipc_answer_0(rid, retval);
+			break;
+		}
+		
+		ipc_answer_0(rid, EOK);
+	default:
+		/*
+		 * Sorry, we don't know how to get unknown or NONE
+		 * data from the clipbard
+		 */
+		ipc_answer_0(rid, EINVAL);
+		break;
+	}
+	
+	fibril_mutex_unlock(&clip_mtx);
+}
+
+static void clip_content(ipc_callid_t rid, ipc_call_t *request)
+{
+	fibril_mutex_lock(&clip_mtx);
+	
+	size_t size = clip_size;
+	clipboard_tag_t tag = clip_tag;
+	
+	fibril_mutex_unlock(&clip_mtx);
+	ipc_answer_2(rid, EOK, (ipcarg_t) size, (ipcarg_t) clip_tag);
+}
+
+static void clip_connection(ipc_callid_t iid, ipc_call_t *icall)
+{
+	/* Accept connection */
+	ipc_answer_0(iid, EOK);
+	
+	bool cont = true;
+	while (cont) {
+		ipc_call_t call;
+		ipc_callid_t callid = async_get_call(&call);
+		
+		switch (IPC_GET_METHOD(call)) {
+		case IPC_M_PHONE_HUNGUP:
+			cont = false;
+			continue;
+		case CLIPBOARD_PUT_DATA:
+			clip_put_data(callid, &call);
+			break;
+		case CLIPBOARD_GET_DATA:
+			clip_get_data(callid, &call);
+			break;
+		case CLIPBOARD_CONTENT:
+			clip_content(callid, &call);
+			break;
+		default:
+			if (!(callid & IPC_CALLID_NOTIFICATION))
+				ipc_answer_0(callid, ENOENT);
+		}
+	}
+}
+
+int main(int argc, char *argv[])
+{
+	printf(NAME ": HelenOS clipboard service\n");
+	
+	async_set_client_connection(clip_connection);
+	
+	ipcarg_t phonead;
+	if (ipc_connect_to_me(PHONE_NS, SERVICE_CLIPBOARD, 0, 0, &phonead) != 0) 
+		return -1;
+	
+	printf(NAME ": Accepting connections\n");
+	async_manager();
+	
+	/* Never reached */
+	return 0;
+}
Index: uspace/srv/clip/clip.h
===================================================================
--- uspace/srv/clip/clip.h	(revision fb623e2feb545b72f2f3dca3e41febed93271cf4)
+++ uspace/srv/clip/clip.h	(revision fb623e2feb545b72f2f3dca3e41febed93271cf4)
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+
+#ifndef CLIP_MAIN_H_
+#define CLIP_MAIN_H_
+
+#endif
Index: uspace/srv/devmap/devmap.c
===================================================================
--- uspace/srv/devmap/devmap.c	(revision 812355884f3878eb249907e2c43d2db6a913e1ff)
+++ uspace/srv/devmap/devmap.c	(revision fb623e2feb545b72f2f3dca3e41febed93271cf4)
@@ -867,5 +867,5 @@
 }
 
-/** 
+/**
  * @}
  */
