shithub: riscv

Download patch

ref: 51f4f46ae05251967a6152514d9a935e960d022b
parent: 692919521c15531cc0bed3006fd958b164a746ab
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Feb 27 10:08:34 EST 2021

ramfs: fix truncfile() for non multiple of extend size (64k)

The calculation of the last block size is wrong and we can
only shrink the size of the last data block, not extend it.

--- a/sys/src/cmd/ramfs.c
+++ b/sys/src/cmd/ramfs.c
@@ -249,7 +249,8 @@
 		if(i < n){
 			o = l % ESIZE;
 			if(o != 0 && x->ent[i] != nil){
-				x->ent[i]->size = o * sizeof(Ram*);
+				if(o < x->ent[i]->size)
+					x->ent[i]->size = o;
 				i++;
 			}
 			while(i < n){