summaryrefslogtreecommitdiff
path: root/pathfs_frontend
diff options
context:
space:
mode:
authorJakob Unterwurzacher2015-10-04 16:04:25 +0200
committerJakob Unterwurzacher2015-10-04 16:04:25 +0200
commit90bd9782831f9d3a3c7c682f9cc04ccef0a1666d (patch)
tree49b72f0edd5c7cf6bd6347432c5c2eb4c9da56b9 /pathfs_frontend
parentaa6fa7f3cf0c7a2ab078ad4648eca742e5acd232 (diff)
truncate: Fix bug that caused xfstests generic/030 to fail
The bug was caused by using cipherOff where plainOff should have been used. Renamed the symbols for less confusion.
Diffstat (limited to 'pathfs_frontend')
-rw-r--r--pathfs_frontend/file.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/pathfs_frontend/file.go b/pathfs_frontend/file.go
index b328b61..697d58d 100644
--- a/pathfs_frontend/file.go
+++ b/pathfs_frontend/file.go
@@ -270,29 +270,30 @@ func (f *file) Truncate(newSize uint64) fuse.Status {
}
}
return fuse.OK
- // File shrinks
} else {
+ // File shrinks
blockNo := f.cfs.BlockNoPlainOff(newSize)
- lastBlockOff := blockNo * f.cfs.CipherBS()
- lastBlockLen := newSize - blockNo * f.cfs.PlainBS()
+ cipherOff := blockNo * f.cfs.CipherBS()
+ plainOff := blockNo * f.cfs.PlainBS()
+ lastBlockLen := newSize - plainOff
var data []byte
if lastBlockLen > 0 {
var status fuse.Status
- data, status = f.doRead(lastBlockOff, lastBlockLen)
+ data, status = f.doRead(plainOff, lastBlockLen)
if status != fuse.OK {
cryptfs.Warn.Printf("shrink doRead returned error: %v", err)
return status
}
}
f.lock.Lock()
- err = syscall.Ftruncate(int(f.fd.Fd()), int64(lastBlockOff))
+ err = syscall.Ftruncate(int(f.fd.Fd()), int64(cipherOff))
f.lock.Unlock()
if err != nil {
cryptfs.Warn.Printf("shrink Ftruncate returned error: %v", err)
return fuse.ToStatus(err)
}
if lastBlockLen > 0 {
- _, status := f.doWrite(data, int64(lastBlockOff))
+ _, status := f.doWrite(data, int64(plainOff))
return status
}
return fuse.OK