From 6538dc15afb7a7a159f070a57a1e9073ca076661 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Tue, 25 Oct 2016 21:19:37 +0200 Subject: fusefrontend: rename "createsHole" to clearer "createsCiphertextHole" ...and add comments for what is happening. --- internal/fusefrontend/file_holes.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'internal/fusefrontend/file_holes.go') diff --git a/internal/fusefrontend/file_holes.go b/internal/fusefrontend/file_holes.go index 34f702f..ff626d1 100644 --- a/internal/fusefrontend/file_holes.go +++ b/internal/fusefrontend/file_holes.go @@ -8,10 +8,16 @@ import ( "github.com/rfjakob/gocryptfs/internal/tlog" ) -// Will a write to offset "off" create a file hole? -func (f *file) createsHole(plainSize uint64, off int64) bool { +// Will a write to plaintext offset "off" create a file hole in the ciphertext? +func (f *file) createsCiphertextHole(plainSize uint64, off int64) bool { + // Appending a single byte to the file (equivalent to writing to + // offset=plainSize) would write to "nextBlock". nextBlock := f.contentEnc.PlainOffToBlockNo(plainSize) + // targetBlock is the block the user wants to write to. targetBlock := f.contentEnc.PlainOffToBlockNo(uint64(off)) + // If the write goes past the next block, nextBlock will have + // to be zero-padded to the block boundary and at least nextBlock+1 + // becomes a file hole in the ciphertext. return targetBlock > nextBlock } -- cgit v1.2.3