]> git.lizzy.rs Git - plan9front.git/commitdiff
ramfs: fix truncfile() for non multiple of extend size (64k)
authorcinap_lenrek <cinap_lenrek@felloff.net>
Sat, 27 Feb 2021 14:08:34 +0000 (15:08 +0100)
committercinap_lenrek <cinap_lenrek@felloff.net>
Sat, 27 Feb 2021 14:08:34 +0000 (15:08 +0100)
The calculation of the last block size is wrong and we can
only shrink the size of the last data block, not extend it.

sys/src/cmd/ramfs.c

index 85bbe9e318ab6b1fd0aa50648885081bcbb3012b..90f1225e84a6080eab787ee4cb2a0063265dc202 100644 (file)
@@ -249,7 +249,8 @@ truncfile(File *f, vlong l)
                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){