Index: uspace/lib/libblock/Makefile
===================================================================
--- uspace/lib/libblock/Makefile	(revision 405f7599e6313c421a16c96d2a71c715c1b5188b)
+++ uspace/lib/libblock/Makefile	(revision c03f610e65346872d240cc10daf706dc37099a7b)
@@ -34,7 +34,7 @@
 all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBC_PREFIX)/libc.a
 	-[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
-	$(MAKE) -f Makefile.build
+	$(MAKE) -f Makefile.build PRECHECK=$(PRECHECK)
 
 clean:
-	rm -f $(DEPEND) $(DEPEND_PREV) $(LIBBLOCK)
+	rm -f $(DEPEND) $(DEPEND_PREV) $(JOB) $(LIBBLOCK)
 	find . -name '*.o' -follow -exec rm \{\} \;
Index: uspace/lib/libblock/Makefile.build
===================================================================
--- uspace/lib/libblock/Makefile.build	(revision 405f7599e6313c421a16c96d2a71c715c1b5188b)
+++ uspace/lib/libblock/Makefile.build	(revision c03f610e65346872d240cc10daf706dc37099a7b)
@@ -53,4 +53,7 @@
 %.o: %.c $(DEPEND)
 	$(CC) $(DEFS) $(CFLAGS) -c $< -o $@
+ifeq ($(PRECHECK),y)
+	$(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS)
+endif
 
 $(DEPEND):
Index: uspace/lib/libblock/Makefile.common
===================================================================
--- uspace/lib/libblock/Makefile.common	(revision 405f7599e6313c421a16c96d2a71c715c1b5188b)
+++ uspace/lib/libblock/Makefile.common	(revision c03f610e65346872d240cc10daf706dc37099a7b)
@@ -34,3 +34,4 @@
 DEPEND = Makefile.depend
 DEPEND_PREV = $(DEPEND).prev
+JOB = libblock.job
 LIBBLOCK = libblock.a
Index: uspace/lib/libblock/libblock.c
===================================================================
--- uspace/lib/libblock/libblock.c	(revision 405f7599e6313c421a16c96d2a71c715c1b5188b)
+++ uspace/lib/libblock/libblock.c	(revision c03f610e65346872d240cc10daf706dc37099a7b)
@@ -87,4 +87,5 @@
 static int write_blocks(devcon_t *devcon, bn_t ba, size_t cnt);
 static int get_block_size(int dev_phone, size_t *bsize);
+static int get_num_blocks(int dev_phone, bn_t *nblocks);
 
 static devcon_t *devcon_search(dev_handle_t dev_handle)
@@ -714,5 +715,5 @@
 
 	memcpy(devcon->comm_area, data, devcon->pblock_size * cnt);
-	rc = read_blocks(devcon, ba, cnt);
+	rc = write_blocks(devcon, ba, cnt);
 
 	fibril_mutex_unlock(&devcon->comm_area_lock);
@@ -736,4 +737,21 @@
 	
 	return get_block_size(devcon->dev_phone, bsize);
+}
+
+/** Get number of blocks on device.
+ *
+ * @param dev_handle	Device handle of the block device.
+ * @param nblocks	Output number of blocks.
+ *
+ * @return		EOK on success or negative error code on failure.
+ */
+int block_get_nblocks(dev_handle_t dev_handle, bn_t *nblocks)
+{
+	devcon_t *devcon;
+
+	devcon = devcon_search(dev_handle);
+	assert(devcon);
+	
+	return get_num_blocks(devcon->dev_phone, nblocks);
 }
 
@@ -789,4 +807,18 @@
 }
 
+/** Get total number of blocks on block device. */
+static int get_num_blocks(int dev_phone, bn_t *nblocks)
+{
+	ipcarg_t nb_l, nb_h;
+	int rc;
+
+	rc = async_req_0_2(dev_phone, BD_GET_NUM_BLOCKS, &nb_l, &nb_h);
+	if (rc == EOK) {
+		*nblocks = (bn_t) MERGE_LOUP32(nb_l, nb_h);
+	}
+
+	return rc;
+}
+
 /** @}
  */
Index: uspace/lib/libblock/libblock.h
===================================================================
--- uspace/lib/libblock/libblock.h	(revision 405f7599e6313c421a16c96d2a71c715c1b5188b)
+++ uspace/lib/libblock/libblock.h	(revision c03f610e65346872d240cc10daf706dc37099a7b)
@@ -60,6 +60,4 @@
 #define BLOCK_FLAGS_NOREAD	1
 
-typedef uint64_t bn_t;	/**< Block number type. */
-
 typedef struct block {
 	/** Mutex protecting the reference count. */
@@ -110,4 +108,5 @@
 
 extern int block_get_bsize(dev_handle_t, size_t *);
+extern int block_get_nblocks(dev_handle_t, bn_t *);
 extern int block_read_direct(dev_handle_t, bn_t, size_t, void *);
 extern int block_write_direct(dev_handle_t, bn_t, size_t, const void *);
Index: uspace/lib/libc/Makefile
===================================================================
--- uspace/lib/libc/Makefile	(revision 405f7599e6313c421a16c96d2a71c715c1b5188b)
+++ uspace/lib/libc/Makefile	(revision c03f610e65346872d240cc10daf706dc37099a7b)
@@ -33,7 +33,7 @@
 all: ../../../Makefile.config ../../../config.h ../../../config.defs
 	-[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
-	$(MAKE) -f Makefile.build
+	$(MAKE) -f Makefile.build PRECHECK=$(PRECHECK)
 
 clean:
-	rm -f $(DEPEND) $(DEPEND_PREV) $(INCLUDE_KERNEL) $(INCLUDE_ARCH) $(INCLUDE_LIBARCH) $(LIBC) arch/*/_link.ld
+	rm -f $(DEPEND) $(DEPEND_PREV) $(JOB) $(INCLUDE_KERNEL) $(INCLUDE_ARCH) $(INCLUDE_LIBARCH) $(LIBC) arch/*/_link.ld
 	find generic/ arch/*/ -name '*.o' -follow -exec rm \{\} \;
Index: uspace/lib/libc/Makefile.build
===================================================================
--- uspace/lib/libc/Makefile.build	(revision 405f7599e6313c421a16c96d2a71c715c1b5188b)
+++ uspace/lib/libc/Makefile.build	(revision c03f610e65346872d240cc10daf706dc37099a7b)
@@ -112,10 +112,19 @@
 %.o: %.S $(DEPEND)
 	$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
+ifeq ($(PRECHECK),y)
+	$(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__
+endif
 
 %.o: %.s $(DEPEND)
 	$(AS) $(AFLAGS) $< -o $@
+ifeq ($(PRECHECK),y)
+	$(JOBFILE) $(JOB) $< $@ as asm $(AFLAGS)
+endif
 
 %.o: %.c $(DEPEND)
 	$(CC) $(DEFS) $(CFLAGS) -c $< -o $@
+ifeq ($(PRECHECK),y)
+	$(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS)
+endif
 
 $(DEPEND): $(INCLUDE_KERNEL) $(INCLUDE_ARCH) $(INCLUDE_LIBARCH)
Index: uspace/lib/libc/Makefile.common
===================================================================
--- uspace/lib/libc/Makefile.common	(revision 405f7599e6313c421a16c96d2a71c715c1b5188b)
+++ uspace/lib/libc/Makefile.common	(revision c03f610e65346872d240cc10daf706dc37099a7b)
@@ -33,4 +33,5 @@
 DEPEND = Makefile.depend
 DEPEND_PREV = $(DEPEND).prev
+JOB = libc.job
 LIBC = libc.a
 INCLUDE_KERNEL = include/kernel
Index: uspace/lib/libc/Makefile.toolchain
===================================================================
--- uspace/lib/libc/Makefile.toolchain	(revision 405f7599e6313c421a16c96d2a71c715c1b5188b)
+++ uspace/lib/libc/Makefile.toolchain	(revision c03f610e65346872d240cc10daf706dc37099a7b)
@@ -78,4 +78,6 @@
 #
 
+JOBFILE = $(LIBC_PREFIX)/../../../tools/jobfile.py
+
 ifeq ($(COMPILER),gcc_cross)
 	CC = $(TOOLCHAIN_DIR)/$(TARGET)-gcc
Index: uspace/lib/libc/generic/io/io.c
===================================================================
--- uspace/lib/libc/generic/io/io.c	(revision 405f7599e6313c421a16c96d2a71c715c1b5188b)
+++ uspace/lib/libc/generic/io/io.c	(revision c03f610e65346872d240cc10daf706dc37099a7b)
@@ -554,4 +554,15 @@
 }
 
+int ftell(FILE *stream)
+{
+	off_t rc = lseek(stream->fd, 0, SEEK_CUR);
+	if (rc == (off_t) (-1)) {
+		/* errno has been set by lseek. */
+		return -1;
+	}
+
+	return rc;
+}
+
 void rewind(FILE *stream)
 {
@@ -584,4 +595,10 @@
 }
 
+void clearerr(FILE *stream)
+{
+	stream->eof = false;
+	stream->error = false;
+}
+
 int fphone(FILE *stream)
 {
Index: uspace/lib/libc/include/ipc/bd.h
===================================================================
--- uspace/lib/libc/include/ipc/bd.h	(revision 405f7599e6313c421a16c96d2a71c715c1b5188b)
+++ uspace/lib/libc/include/ipc/bd.h	(revision c03f610e65346872d240cc10daf706dc37099a7b)
@@ -40,4 +40,5 @@
 typedef enum {
 	BD_GET_BLOCK_SIZE = IPC_FIRST_USER_METHOD,
+	BD_GET_NUM_BLOCKS,
 	BD_READ_BLOCKS,
 	BD_WRITE_BLOCKS
Index: uspace/lib/libc/include/ipc/char.h
===================================================================
--- uspace/lib/libc/include/ipc/char.h	(revision c03f610e65346872d240cc10daf706dc37099a7b)
+++ uspace/lib/libc/include/ipc/char.h	(revision c03f610e65346872d240cc10daf706dc37099a7b)
@@ -0,0 +1,53 @@
+/*
+ * 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 libcipc
+ * @{
+ */
+/** @file
+ * @brief Character device interface.
+ */ 
+
+#ifndef LIBC_IPC_CHAR_H_
+#define LIBC_IPC_CHAR_H_
+
+#include <ipc/ipc.h>
+
+typedef enum {
+	CHAR_WRITE_BYTE = IPC_FIRST_USER_METHOD
+} char_request_t;
+
+
+typedef enum {
+	CHAR_NOTIF_BYTE = IPC_FIRST_USER_METHOD
+} char_notif_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/libc/include/ipc/mouse.h
===================================================================
--- uspace/lib/libc/include/ipc/mouse.h	(revision c03f610e65346872d240cc10daf706dc37099a7b)
+++ uspace/lib/libc/include/ipc/mouse.h	(revision c03f610e65346872d240cc10daf706dc37099a7b)
@@ -0,0 +1,50 @@
+/*
+ * 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 mouse
+ * @brief
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBC_IPC_MOUSE_H_
+#define LIBC_IPC_MOUSE_H_
+
+#include <ipc/ipc.h>
+
+typedef enum {
+	MEVENT_BUTTON = IPC_FIRST_USER_METHOD,
+	MEVENT_MOVE
+} mouse_notif_t;
+
+#endif
+
+/**
+ * @}
+ */
Index: uspace/lib/libc/include/sys/types.h
===================================================================
--- uspace/lib/libc/include/sys/types.h	(revision 405f7599e6313c421a16c96d2a71c715c1b5188b)
+++ uspace/lib/libc/include/sys/types.h	(revision c03f610e65346872d240cc10daf706dc37099a7b)
@@ -40,4 +40,5 @@
 typedef long off_t;
 typedef int mode_t;
+typedef uint64_t bn_t;	/**< Block number type. */
 
 typedef int32_t wchar_t;
Index: uspace/lib/libfs/Makefile
===================================================================
--- uspace/lib/libfs/Makefile	(revision 405f7599e6313c421a16c96d2a71c715c1b5188b)
+++ uspace/lib/libfs/Makefile	(revision c03f610e65346872d240cc10daf706dc37099a7b)
@@ -34,7 +34,7 @@
 all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBC_PREFIX)/libc.a
 	-[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
-	$(MAKE) -f Makefile.build
+	$(MAKE) -f Makefile.build PRECHECK=$(PRECHECK)
 
 clean:
-	rm -f $(DEPEND) $(DEPEND_PREV) $(LIBFS)
+	rm -f $(DEPEND) $(DEPEND_PREV) $(JOB) $(LIBFS)
 	find . -name '*.o' -follow -exec rm \{\} \;
Index: uspace/lib/libfs/Makefile.build
===================================================================
--- uspace/lib/libfs/Makefile.build	(revision 405f7599e6313c421a16c96d2a71c715c1b5188b)
+++ uspace/lib/libfs/Makefile.build	(revision c03f610e65346872d240cc10daf706dc37099a7b)
@@ -53,4 +53,7 @@
 %.o: %.c $(DEPEND)
 	$(CC) $(DEFS) $(CFLAGS) -c $< -o $@
+ifeq ($(PRECHECK),y)
+	$(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS)
+endif
 
 $(DEPEND):
Index: uspace/lib/libfs/Makefile.common
===================================================================
--- uspace/lib/libfs/Makefile.common	(revision 405f7599e6313c421a16c96d2a71c715c1b5188b)
+++ uspace/lib/libfs/Makefile.common	(revision c03f610e65346872d240cc10daf706dc37099a7b)
@@ -34,3 +34,4 @@
 DEPEND = Makefile.depend
 DEPEND_PREV = $(DEPEND).prev
+JOB = libfs.job
 LIBFS = libfs.a
Index: uspace/lib/softfloat/Makefile
===================================================================
--- uspace/lib/softfloat/Makefile	(revision 405f7599e6313c421a16c96d2a71c715c1b5188b)
+++ uspace/lib/softfloat/Makefile	(revision c03f610e65346872d240cc10daf706dc37099a7b)
@@ -34,7 +34,7 @@
 all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBC_PREFIX)/libc.a
 	-[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
-	$(MAKE) -f Makefile.build
+	$(MAKE) -f Makefile.build PRECHECK=$(PRECHECK)
 
 clean:
-	rm -f $(DEPEND) $(DEPEND_PREV) $(LIBSOFTFLOAT)
+	rm -f $(DEPEND) $(DEPEND_PREV) $(JOB) $(LIBSOFTFLOAT)
 	find . -name '*.o' -follow -exec rm \{\} \;
Index: uspace/lib/softfloat/Makefile.build
===================================================================
--- uspace/lib/softfloat/Makefile.build	(revision 405f7599e6313c421a16c96d2a71c715c1b5188b)
+++ uspace/lib/softfloat/Makefile.build	(revision c03f610e65346872d240cc10daf706dc37099a7b)
@@ -63,4 +63,7 @@
 %.o: %.c $(DEPEND)
 	$(CC) $(DEFS) $(CFLAGS) -c $< -o $@
+ifeq ($(PRECHECK),y)
+	$(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS)
+endif
 
 $(DEPEND):
Index: uspace/lib/softfloat/Makefile.common
===================================================================
--- uspace/lib/softfloat/Makefile.common	(revision 405f7599e6313c421a16c96d2a71c715c1b5188b)
+++ uspace/lib/softfloat/Makefile.common	(revision c03f610e65346872d240cc10daf706dc37099a7b)
@@ -34,3 +34,4 @@
 DEPEND = Makefile.depend
 DEPEND_PREV = $(DEPEND).prev
+JOB = softfloat.job
 LIBSOFTFLOAT = libsoftfloat.a
Index: uspace/lib/softint/Makefile
===================================================================
--- uspace/lib/softint/Makefile	(revision 405f7599e6313c421a16c96d2a71c715c1b5188b)
+++ uspace/lib/softint/Makefile	(revision c03f610e65346872d240cc10daf706dc37099a7b)
@@ -34,7 +34,7 @@
 all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBC_PREFIX)/libc.a
 	-[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)
-	$(MAKE) -f Makefile.build
+	$(MAKE) -f Makefile.build PRECHECK=$(PRECHECK)
 
 clean:
-	rm -f $(DEPEND) $(DEPEND_PREV) $(LIBSOFTINT)
+	rm -f $(DEPEND) $(DEPEND_PREV) $(JOB) $(LIBSOFTINT)
 	find . -name '*.o' -follow -exec rm \{\} \;
Index: uspace/lib/softint/Makefile.build
===================================================================
--- uspace/lib/softint/Makefile.build	(revision 405f7599e6313c421a16c96d2a71c715c1b5188b)
+++ uspace/lib/softint/Makefile.build	(revision c03f610e65346872d240cc10daf706dc37099a7b)
@@ -56,4 +56,7 @@
 %.o: %.c $(DEPEND)
 	$(CC) $(DEFS) $(CFLAGS) -c $< -o $@
+ifeq ($(PRECHECK),y)
+	$(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS)
+endif
 
 $(DEPEND):
Index: uspace/lib/softint/Makefile.common
===================================================================
--- uspace/lib/softint/Makefile.common	(revision 405f7599e6313c421a16c96d2a71c715c1b5188b)
+++ uspace/lib/softint/Makefile.common	(revision c03f610e65346872d240cc10daf706dc37099a7b)
@@ -34,3 +34,4 @@
 DEPEND = Makefile.depend
 DEPEND_PREV = $(DEPEND).prev
+JOB = softint.job
 LIBSOFTINT = libsoftint.a
