diff options
author | Jakob Unterwurzacher | 2016-07-02 00:12:36 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2016-07-02 00:12:36 +0200 |
commit | 7b22b426b9f5e68a0ff51799e04f193dc74586d0 (patch) | |
tree | ba30788cce61ca58608d669b75b07296df9b9422 /internal/fusefrontend | |
parent | f2b4d57068d13b6dc3de2ccc6550675d11d34cfa (diff) |
contentenc: rename PlaintextRange and CiphertextRange
The name could be misunderstood and actually caused a bug:
doWrite used to always preallocate 4128 instead of the actual
data length.
Diffstat (limited to 'internal/fusefrontend')
-rw-r--r-- | internal/fusefrontend/file.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/internal/fusefrontend/file.go b/internal/fusefrontend/file.go index 8f13553..b5775c2 100644 --- a/internal/fusefrontend/file.go +++ b/internal/fusefrontend/file.go @@ -244,7 +244,7 @@ func (f *file) doWrite(data []byte, off int64) (uint32, fuse.Status) { // Incomplete block -> Read-Modify-Write if b.IsPartial() { // Read - o, _ := b.PlaintextRange() + o := b.BlockPlainOff() var oldData []byte oldData, status = f.doRead(o, f.contentEnc.PlainBS()) if status != fuse.OK { @@ -257,13 +257,13 @@ func (f *file) doWrite(data []byte, off int64) (uint32, fuse.Status) { } // Encrypt - blockOffset, blockLen := b.CiphertextRange() + blockOffset := b.BlockCipherOff() blockData = f.contentEnc.EncryptBlock(blockData, b.BlockNo, f.header.Id) tlog.Debug.Printf("ino%d: Writing %d bytes to block #%d", f.ino, uint64(len(blockData))-f.contentEnc.BlockOverhead(), b.BlockNo) // Prevent partially written (=corrupt) blocks by preallocating the space beforehand - err := prealloc(int(f.fd.Fd()), int64(blockOffset), int64(blockLen)) + err := prealloc(int(f.fd.Fd()), int64(blockOffset), int64(len(blockData))) if err != nil { tlog.Warn.Printf("ino%d fh%d: doWrite: prealloc failed: %s", f.ino, f.intFd(), err.Error()) status = fuse.ToStatus(err) @@ -410,12 +410,12 @@ func (f *file) Truncate(newSize uint64) fuse.Status { } lastBlock := addBlocks[len(addBlocks)-1] if lastBlock.IsPartial() { - off, _ := lastBlock.PlaintextRange() + off := lastBlock.BlockPlainOff() _, status := f.doWrite(make([]byte, lastBlock.Length), int64(off+lastBlock.Skip)) return status } else { - off, length := lastBlock.CiphertextRange() - err = syscall.Ftruncate(f.intFd(), int64(off+length)) + off := lastBlock.BlockCipherOff() + err = syscall.Ftruncate(f.intFd(), int64(off+f.contentEnc.CipherBS())) if err != nil { tlog.Warn.Printf("Truncate: grow Ftruncate returned error: %v", err) } |