Index: uspace/srv/fs/fat/fat_fat.c
===================================================================
--- uspace/srv/fs/fat/fat_fat.c	(revision dc87ad11ff256254adc0520ebc4226b1b715a918)
+++ uspace/srv/fs/fat/fat_fat.c	(revision cca29e3c4af59e2c0dcd39ec5f532e5cc61145a2)
@@ -187,6 +187,8 @@
  *			this argument is ignored.
  * @param pos		Position in the last node block.
- */
-void fat_fill_gap(fat_bs_t *bs, fat_node_t *nodep, fat_cluster_t mcl, off_t pos)
+ *
+ * @return		EOK on success or a negative error code.
+ */
+int fat_fill_gap(fat_bs_t *bs, fat_node_t *nodep, fat_cluster_t mcl, off_t pos)
 {
 	uint16_t bps;
@@ -207,13 +209,15 @@
 		    BLOCK_FLAGS_NOREAD : BLOCK_FLAGS_NONE;
 		rc = fat_block_get(&b, bs, nodep, o / bps, flags);
-		assert(rc == EOK);
+		if (rc != EOK)
+			return rc;
 		memset(b->data + o % bps, 0, bps - o % bps);
 		b->dirty = true;		/* need to sync node */
 		rc = block_put(b);
-		assert(rc == EOK);
+		if (rc != EOK)
+			return rc;
 	}
 	
 	if (o >= pos)
-		return;
+		return EOK;
 	
 	/* zero out the initial part of the new cluster chain */
@@ -221,10 +225,14 @@
 		rc = _fat_block_get(&b, bs, nodep->idx->dev_handle, mcl,
 		    (o - boundary) / bps, BLOCK_FLAGS_NOREAD);
-		assert(rc == EOK);
+		if (rc != EOK)
+			return rc;
 		memset(b->data, 0, min(bps, pos - o));
 		b->dirty = true;		/* need to sync node */
 		rc = block_put(b);
-		assert(rc == EOK);
-	}
+		if (rc != EOK)
+			return rc;
+	}
+
+	return EOK;
 }
 
@@ -269,6 +277,8 @@
  * @param clst		Cluster which is to be set.
  * @param value		Value to set the cluster with.
- */
-void
+ *
+ * @return		EOK on success or a negative error code.
+ */
+int
 fat_set_cluster(fat_bs_t *bs, dev_handle_t dev_handle, unsigned fatno,
     fat_cluster_t clst, fat_cluster_t value)
@@ -288,10 +298,11 @@
 	rc = block_get(&b, dev_handle, rscnt + sf * fatno +
 	    (clst * sizeof(fat_cluster_t)) / bps, BLOCK_FLAGS_NONE);
-	assert(rc == EOK);
+	if (rc != EOK)
+		return rc;
 	cp = (fat_cluster_t *)b->data + clst % (bps / sizeof(fat_cluster_t));
 	*cp = host2uint16_t_le(value);
 	b->dirty = true;		/* need to sync block */
 	rc = block_put(b);
-	assert(rc == EOK);
+	return rc;
 }
 
@@ -302,17 +313,24 @@
  * @param lifo		Chain of allocated clusters.
  * @param nclsts	Number of clusters in the lifo chain.
- */
-void fat_alloc_shadow_clusters(fat_bs_t *bs, dev_handle_t dev_handle,
+ *
+ * @return		EOK on success or a negative error code.
+ */
+int fat_alloc_shadow_clusters(fat_bs_t *bs, dev_handle_t dev_handle,
     fat_cluster_t *lifo, unsigned nclsts)
 {
 	uint8_t fatno;
 	unsigned c;
+	int rc;
 
 	for (fatno = FAT1 + 1; fatno < bs->fatcnt; fatno++) {
 		for (c = 0; c < nclsts; c++) {
-			fat_set_cluster(bs, dev_handle, fatno, lifo[c],
+			rc = fat_set_cluster(bs, dev_handle, fatno, lifo[c],
 			    c == 0 ? FAT_CLST_LAST1 : lifo[c - 1]);
+			if (rc != EOK)
+				return rc;
 		}
 	}
+
+	return EOK;
 }
 
@@ -378,6 +396,7 @@
 					assert(rc == EOK);
 					/* update the shadow copies of FAT */
-					fat_alloc_shadow_clusters(bs,
+					rc = fat_alloc_shadow_clusters(bs,
 					    dev_handle, lifo, nclsts);
+					assert(rc == EOK);
 					*mcl = lifo[found - 1];
 					*lcl = lifo[0];
@@ -398,6 +417,10 @@
 	 */
 	while (found--) {
-		fat_set_cluster(bs, dev_handle, FAT1, lifo[found],
+		rc = fat_set_cluster(bs, dev_handle, FAT1, lifo[found],
 		    FAT_CLST_RES0);
+		if (rc != EOK) {
+			free(lifo);
+			return rc;
+		}
 	}
 	
@@ -411,6 +434,8 @@
  * @param dev_handle	Device handle of the file system.
  * @param firstc	First cluster in the chain which is to be freed.
- */
-void
+ *
+ * @return		EOK on success or a negative return code.
+ */
+int
 fat_free_clusters(fat_bs_t *bs, dev_handle_t dev_handle, fat_cluster_t firstc)
 {
@@ -423,10 +448,17 @@
 		assert(firstc >= FAT_CLST_FIRST && firstc < FAT_CLST_BAD);
 		rc = fat_get_cluster(bs, dev_handle, firstc, &nextc);
-		assert(rc == EOK);
-		for (fatno = FAT1; fatno < bs->fatcnt; fatno++)
-			fat_set_cluster(bs, dev_handle, fatno, firstc,
+		if (rc != EOK)
+			return rc;
+		for (fatno = FAT1; fatno < bs->fatcnt; fatno++) {
+			rc = fat_set_cluster(bs, dev_handle, fatno, firstc,
 			    FAT_CLST_RES0);
+			if (rc != EOK)
+				return rc;
+		}
+
 		firstc = nextc;
 	}
+
+	return EOK;
 }
 
@@ -436,6 +468,8 @@
  * @param nodep		Node representing the file.
  * @param mcl		First cluster of the cluster chain to append.
- */
-void fat_append_clusters(fat_bs_t *bs, fat_node_t *nodep, fat_cluster_t mcl)
+ *
+ * @return		EOK on success or a negative error code.
+ */
+int fat_append_clusters(fat_bs_t *bs, fat_node_t *nodep, fat_cluster_t mcl)
 {
 	dev_handle_t dev_handle = nodep->idx->dev_handle;
@@ -447,5 +481,6 @@
 	rc = fat_cluster_walk(bs, dev_handle, nodep->firstc, &lcl, &numc,
 	    (uint16_t) -1);
-	assert(rc == EOK);
+	if (rc != EOK)
+		return rc;
 
 	if (numc == 0) {
@@ -453,9 +488,15 @@
 		nodep->firstc = mcl;
 		nodep->dirty = true;		/* need to sync node */
-		return;
-	}
-
-	for (fatno = FAT1; fatno < bs->fatcnt; fatno++)
-		fat_set_cluster(bs, nodep->idx->dev_handle, fatno, lcl, mcl);
+		return EOK;
+	}
+
+	for (fatno = FAT1; fatno < bs->fatcnt; fatno++) {
+		rc = fat_set_cluster(bs, nodep->idx->dev_handle, fatno, lcl,
+		    mcl);
+		if (rc != EOK)
+			return rc;
+	}
+
+	return EOK;
 }
 
@@ -467,6 +508,8 @@
  *			argument is FAT_CLST_RES0, then all clusters will
  *			be chopped off.
- */
-void fat_chop_clusters(fat_bs_t *bs, fat_node_t *nodep, fat_cluster_t lastc)
+ *
+ * @return		EOK on success or a negative return code.
+ */
+int fat_chop_clusters(fat_bs_t *bs, fat_node_t *nodep, fat_cluster_t lastc)
 {
 	int rc;
@@ -475,5 +518,7 @@
 	if (lastc == FAT_CLST_RES0) {
 		/* The node will have zero size and no clusters allocated. */
-		fat_free_clusters(bs, dev_handle, nodep->firstc);
+		rc = fat_free_clusters(bs, dev_handle, nodep->firstc);
+		if (rc != EOK)
+			return rc;
 		nodep->firstc = FAT_CLST_RES0;
 		nodep->dirty = true;		/* need to sync node */
@@ -483,16 +528,25 @@
 
 		rc = fat_get_cluster(bs, dev_handle, lastc, &nextc);
-		assert(rc == EOK);
+		if (rc != EOK)
+			return rc;
 
 		/* Terminate the cluster chain in all copies of FAT. */
-		for (fatno = FAT1; fatno < bs->fatcnt; fatno++)
-			fat_set_cluster(bs, dev_handle, fatno, lastc, FAT_CLST_LAST1);
+		for (fatno = FAT1; fatno < bs->fatcnt; fatno++) {
+			rc = fat_set_cluster(bs, dev_handle, fatno, lastc,
+			    FAT_CLST_LAST1);
+			if (rc != EOK)
+				return rc;
+		}
 
 		/* Free all following clusters. */
-		fat_free_clusters(bs, dev_handle, nextc);
-	}
-}
-
-void
+		rc = fat_free_clusters(bs, dev_handle, nextc);
+		if (rc != EOK)
+			return rc;
+	}
+
+	return EOK;
+}
+
+int
 fat_zero_cluster(struct fat_bs *bs, dev_handle_t dev_handle, fat_cluster_t c)
 {
@@ -507,10 +561,14 @@
 		rc = _fat_block_get(&b, bs, dev_handle, c, i,
 		    BLOCK_FLAGS_NOREAD);
-		assert(rc == EOK);
+		if (rc != EOK)
+			return rc;
 		memset(b->data, 0, bps);
 		b->dirty = true;
 		rc = block_put(b);
-		assert(rc == EOK);
-	}
+		if (rc != EOK)
+			return rc;
+	}
+
+	return EOK;
 }
 
Index: uspace/srv/fs/fat/fat_fat.h
===================================================================
--- uspace/srv/fs/fat/fat_fat.h	(revision dc87ad11ff256254adc0520ebc4226b1b715a918)
+++ uspace/srv/fs/fat/fat_fat.h	(revision cca29e3c4af59e2c0dcd39ec5f532e5cc61145a2)
@@ -71,20 +71,20 @@
     fat_cluster_t, bn_t, int);
   
-extern void fat_append_clusters(struct fat_bs *, struct fat_node *,
+extern int fat_append_clusters(struct fat_bs *, struct fat_node *,
     fat_cluster_t);
-extern void fat_chop_clusters(struct fat_bs *, struct fat_node *,
+extern int fat_chop_clusters(struct fat_bs *, struct fat_node *,
     fat_cluster_t);
 extern int fat_alloc_clusters(struct fat_bs *, dev_handle_t, unsigned,
     fat_cluster_t *, fat_cluster_t *);
-extern void fat_free_clusters(struct fat_bs *, dev_handle_t, fat_cluster_t);
-extern void fat_alloc_shadow_clusters(struct fat_bs *, dev_handle_t,
+extern int fat_free_clusters(struct fat_bs *, dev_handle_t, fat_cluster_t);
+extern int fat_alloc_shadow_clusters(struct fat_bs *, dev_handle_t,
     fat_cluster_t *, unsigned);
 extern int fat_get_cluster(struct fat_bs *, dev_handle_t, fat_cluster_t,
     fat_cluster_t *);
-extern void fat_set_cluster(struct fat_bs *, dev_handle_t, unsigned,
+extern int fat_set_cluster(struct fat_bs *, dev_handle_t, unsigned,
     fat_cluster_t, fat_cluster_t);
-extern void fat_fill_gap(struct fat_bs *, struct fat_node *, fat_cluster_t,
+extern int fat_fill_gap(struct fat_bs *, struct fat_node *, fat_cluster_t,
     off_t);
-extern void fat_zero_cluster(struct fat_bs *, dev_handle_t, fat_cluster_t);
+extern int fat_zero_cluster(struct fat_bs *, dev_handle_t, fat_cluster_t);
 
 #endif
Index: uspace/srv/fs/fat/fat_ops.c
===================================================================
--- uspace/srv/fs/fat/fat_ops.c	(revision dc87ad11ff256254adc0520ebc4226b1b715a918)
+++ uspace/srv/fs/fat/fat_ops.c	(revision cca29e3c4af59e2c0dcd39ec5f532e5cc61145a2)
@@ -329,10 +329,10 @@
 	nodep = fat_node_get_new();
 	if (!nodep) {
-		fat_free_clusters(bs, dev_handle, mcl);	
+		(void) fat_free_clusters(bs, dev_handle, mcl);
 		return NULL;
 	}
 	idxp = fat_idx_get_new(dev_handle);
 	if (!idxp) {
-		fat_free_clusters(bs, dev_handle, mcl);	
+		(void) fat_free_clusters(bs, dev_handle, mcl);	
 		fat_node_put(FS_NODE(nodep));
 		return NULL;
@@ -341,5 +341,6 @@
 	if (flags & L_DIRECTORY) {
 		/* Populate the new cluster with unused dentries. */
-		fat_zero_cluster(bs, dev_handle, mcl);
+		rc = fat_zero_cluster(bs, dev_handle, mcl);
+		assert(rc == EOK);
 		nodep->type = FAT_DIRECTORY;
 		nodep->firstc = mcl;
@@ -365,4 +366,5 @@
 	fat_node_t *nodep = FAT_NODE(fn);
 	fat_bs_t *bs;
+	int rc = EOK;
 
 	/*
@@ -383,5 +385,6 @@
 		assert(nodep->size);
 		/* Free all clusters allocated to the node. */
-		fat_free_clusters(bs, nodep->idx->dev_handle, nodep->firstc);
+		rc = fat_free_clusters(bs, nodep->idx->dev_handle,
+		    nodep->firstc);
 	}
 
@@ -389,5 +392,5 @@
 	free(nodep->bp);
 	free(nodep);
-	return EOK;
+	return rc;
 }
 
@@ -470,6 +473,8 @@
 		return rc;
 	}
-	fat_zero_cluster(bs, parentp->idx->dev_handle, mcl);
-	fat_append_clusters(bs, parentp, mcl);
+	rc = fat_zero_cluster(bs, parentp->idx->dev_handle, mcl);
+	assert(rc == EOK);
+	rc = fat_append_clusters(bs, parentp, mcl);
+	assert(rc == EOK);
 	parentp->size += bps * bs->spc;
 	parentp->dirty = true;		/* need to sync node */
@@ -1088,5 +1093,6 @@
 		 * next block size boundary.
 		 */
-		fat_fill_gap(bs, nodep, FAT_CLST_RES0, pos);
+		rc = fat_fill_gap(bs, nodep, FAT_CLST_RES0, pos);
+		assert(rc == EOK);
 		rc = fat_block_get(&b, bs, nodep, pos / bps, flags);
 		assert(rc == EOK);
@@ -1123,5 +1129,6 @@
 		}
 		/* zero fill any gaps */
-		fat_fill_gap(bs, nodep, mcl, pos);
+		rc = fat_fill_gap(bs, nodep, mcl, pos);
+		assert(rc == EOK);
 		rc = _fat_block_get(&b, bs, dev_handle, lcl, (pos / bps) % spc,
 		    flags);
@@ -1136,5 +1143,6 @@
 		 * node's cluster chain.
 		 */
-		fat_append_clusters(bs, nodep, mcl);
+		rc = fat_append_clusters(bs, nodep, mcl);
+		assert(rc == EOK);
 		nodep->size = pos + bytes;
 		nodep->dirty = true;		/* need to sync node */
@@ -1189,5 +1197,7 @@
 		 */
 		if (size == 0) {
-			fat_chop_clusters(bs, nodep, FAT_CLST_RES0);
+			rc = fat_chop_clusters(bs, nodep, FAT_CLST_RES0);
+			if (rc != EOK)
+				goto out;
 		} else {
 			fat_cluster_t lastc;
@@ -1196,5 +1206,7 @@
 			if (rc != EOK)
 				goto out;
-			fat_chop_clusters(bs, nodep, lastc);
+			rc = fat_chop_clusters(bs, nodep, lastc);
+			if (rc != EOK)
+				goto out;
 		}
 		nodep->size = size;
