From b27edba2bbf374b2e98d19d9fb3aa9f84721baf7 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 4 Oct 2015 15:40:59 +0200 Subject: [PATCH] Fix Trucate() bug causing files to be too small Uncovered by running xfstests generic/014 several times --- pathfs_frontend/file.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pathfs_frontend/file.go b/pathfs_frontend/file.go index 43114b2..47f935b 100644 --- a/pathfs_frontend/file.go +++ b/pathfs_frontend/file.go @@ -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