Index: uspace/srv/fs/fat/fat_fat.c
===================================================================
--- uspace/srv/fs/fat/fat_fat.c	(revision 684b6555b34924d5acac46dd80885b86adfe4faa)
+++ uspace/srv/fs/fat/fat_fat.c	(revision e402382f203ec32bb859c547174ce438b44e0f74)
@@ -61,12 +61,15 @@
  * @param dev_handle	Device handle 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 number visited.
+ * @param lastc		If non-NULL, output argument hodling the last cluster
+ *			number visited.
+ * @param numc		If non-NULL, output argument holding the number of
+ *			clusters seen during the walk.
  * @param max_clusters	Maximum number of clusters to visit.	
  *
- * @return		Number of clusters seen during the walk.
- */
-uint16_t 
+ * @return		EOK on success or a negative error code.
+ */
+int 
 fat_cluster_walk(fat_bs_t *bs, dev_handle_t dev_handle, fat_cluster_t firstc,
-    fat_cluster_t *lastc, uint16_t max_clusters)
+    fat_cluster_t *lastc, uint16_t *numc, uint16_t max_clusters)
 {
 	block_t *b;
@@ -84,5 +87,7 @@
 		if (lastc)
 			*lastc = firstc;
-		return 0;
+		if (numc)
+			*numc = 0;
+		return EOK;
 	}
 
@@ -98,9 +103,11 @@
 		/* read FAT1 */
 		rc = block_get(&b, dev_handle, rscnt + fsec, BLOCK_FLAGS_NONE);
-		assert(rc == EOK);
+		if (rc != EOK)
+			return rc;
 		clst = uint16_t_le2host(((fat_cluster_t *)b->data)[fidx]);
 		assert(clst != FAT_CLST_BAD);
 		rc = block_put(b);
-		assert(rc == EOK);
+		if (rc != EOK)
+			return rc;
 		clusters++;
 	}
@@ -108,6 +115,8 @@
 	if (lastc && clst < FAT_CLST_LAST1)
 		*lastc = clst;
-
-	return clusters;
+	if (numc)
+		*numc = clusters;
+
+	return EOK;
 }
 
@@ -134,5 +143,6 @@
 	unsigned sf;
 	unsigned ssa;		/* size of the system area */
-	unsigned clusters, max_clusters;
+	uint16_t clusters;
+	unsigned max_clusters;
 	fat_cluster_t lastc;
 	int rc;
@@ -156,6 +166,8 @@
 
 	max_clusters = bn / bs->spc;
-	clusters = fat_cluster_walk(bs, dev_handle, firstc, &lastc,
+	rc = fat_cluster_walk(bs, dev_handle, firstc, &lastc, &clusters,
 	    max_clusters);
+	if (rc != EOK)
+		return rc;
 	assert(clusters == max_clusters);
 
@@ -425,8 +437,13 @@
 	dev_handle_t dev_handle = nodep->idx->dev_handle;
 	fat_cluster_t lcl;
+	uint16_t numc;
 	uint8_t fatno;
-
-	if (fat_cluster_walk(bs, dev_handle, nodep->firstc, &lcl,
-	    (uint16_t) -1) == 0) {
+	int rc;
+
+	rc = fat_cluster_walk(bs, dev_handle, nodep->firstc, &lcl, &numc,
+	    (uint16_t) -1);
+	assert(rc == EOK);
+
+	if (numc == 0) {
 		/* No clusters allocated to the node yet. */
 		nodep->firstc = mcl;
Index: uspace/srv/fs/fat/fat_fat.h
===================================================================
--- uspace/srv/fs/fat/fat_fat.h	(revision 684b6555b34924d5acac46dd80885b86adfe4faa)
+++ uspace/srv/fs/fat/fat_fat.h	(revision e402382f203ec32bb859c547174ce438b44e0f74)
@@ -59,8 +59,8 @@
 typedef uint16_t fat_cluster_t;
 
-#define fat_clusters_get(bs, dh, fc) \
-    fat_cluster_walk((bs), (dh), (fc), NULL, (uint16_t) -1)
-extern uint16_t fat_cluster_walk(struct fat_bs *, dev_handle_t, fat_cluster_t,
-    fat_cluster_t *, uint16_t);
+#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 *, dev_handle_t, fat_cluster_t,
+    fat_cluster_t *, uint16_t *, uint16_t);
 
 #define fat_block_get(b, bs, np, bn, flags) \
Index: uspace/srv/fs/fat/fat_ops.c
===================================================================
--- uspace/srv/fs/fat/fat_ops.c	(revision 684b6555b34924d5acac46dd80885b86adfe4faa)
+++ uspace/srv/fs/fat/fat_ops.c	(revision e402382f203ec32bb859c547174ce438b44e0f74)
@@ -220,6 +220,9 @@
 		 * size of the directory by walking the FAT.
 		 */
-		nodep->size = bps * spc * fat_clusters_get(bs, idxp->dev_handle,
+		uint16_t clusters;
+		rc = fat_clusters_get(&clusters, bs, idxp->dev_handle,
 		    uint16_t_le2host(d->firstc));
+		assert(rc == EOK);
+		nodep->size = bps * spc * clusters;
 	} else {
 		nodep->type = FAT_FILE;
@@ -1189,6 +1192,8 @@
 		} else {
 			fat_cluster_t lastc;
-			(void) fat_cluster_walk(bs, dev_handle, nodep->firstc,
-			    &lastc, (size - 1) / bpc);
+			rc = fat_cluster_walk(bs, dev_handle, nodep->firstc,
+			    &lastc, NULL, (size - 1) / bpc);
+			if (rc != EOK)
+				goto out;
 			fat_chop_clusters(bs, nodep, lastc);
 		}
@@ -1197,4 +1202,5 @@
 		rc = EOK;	
 	}
+out:
 	fat_node_put(fn);
 	ipc_answer_0(rid, rc);
