Fix Trucate() bug causing files to be too small

Uncovered by running xfstests generic/014 several times
This commit is contained in:
Jakob Unterwurzacher 2015-10-04 15:40:59 +02:00
parent 089629442d
commit b27edba2bb
1 changed files with 2 additions and 2 deletions

View File

@ -273,8 +273,8 @@ func (f *file) Truncate(newSize uint64) fuse.Status {
// File shrinks
} else {
blockNo := f.cfs.BlockNoPlainOff(newSize)
lastBlockOff := blockNo * f.cfs.PlainBS()
lastBlockLen := newSize - lastBlockOff
lastBlockOff := blockNo * f.cfs.CipherBS()
lastBlockLen := newSize - blockNo * f.cfs.PlainBS()
var data []byte
if lastBlockLen > 0 {
var status fuse.Status