Index: uspace/srv/fs/minixfs/mfs_rw.c
===================================================================
--- uspace/srv/fs/minixfs/mfs_rw.c	(revision 5e0427e81c3c2cc2b72f2a1e775d48424eae228e)
+++ uspace/srv/fs/minixfs/mfs_rw.c	(revision 9a0be341d462b5cb93242f88efe36f9ed4f4eb6d)
@@ -83,4 +83,9 @@
 	const struct mfs_sb_info *sbi = mnode->instance->sbi;
 
+	if (pos >= sbi->max_file_size) {
+		/*Can't write beyond the maximum file size*/
+		return EINVAL;
+	}
+
 	/*Compute the relative block number in file*/
 	int rblock = pos / sbi->block_size;
@@ -97,15 +102,10 @@
 	uint32_t *ind_zone, *ind2_zone;
 
-	assert(mnode);
 	struct mfs_ino_info *ino_i = mnode->ino_i;
-
-	assert(ino_i);
-	assert(mnode->instance);
-
 	struct mfs_instance *inst = mnode->instance;
 	struct mfs_sb_info *sbi = inst->sbi;
-	assert(sbi);
 
 	const mfs_version_t fs_version = sbi->fs_version;
+	const bool deleting = write_mode && (w_block == 0);
 
 	if (fs_version == MFS_VERSION_V1) {
@@ -132,5 +132,5 @@
 		/*The wanted block is in the single indirect zone chain*/
 		if (ino_i->i_izone[0] == 0) {
-			if (write_mode) {
+			if (write_mode && !deleting) {
 				uint32_t zone;
 				r = alloc_zone_and_clear(inst, &zone);
@@ -166,5 +166,5 @@
 	/*read the first indirect zone of the chain*/
 	if (ino_i->i_izone[1] == 0) {
-		if (write_mode) {
+		if (write_mode && !deleting) {
 			uint32_t zone;
 			r = alloc_zone_and_clear(inst, &zone);
@@ -193,5 +193,5 @@
 	/*read the second indirect zone of the chain*/
 	if (ind_zone[ind2_off] == 0) {
-		if (write_mode) {
+		if (write_mode && !deleting) {
 			uint32_t zone;
 			r = alloc_zone_and_clear(inst, &zone);
