From 6196a5b5fe78f7a5b8e38c00e656f70c1592e1df Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 12 Jul 2020 12:59:01 +0200 Subject: v2api: File2: implement Release, Read, Write, Fsync, Flush, Allocate Fortunately, this just means fixing up the function signatures. --- internal/fusefrontend/file2_holes.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'internal/fusefrontend/file2_holes.go') diff --git a/internal/fusefrontend/file2_holes.go b/internal/fusefrontend/file2_holes.go index 5e06981..83918d2 100644 --- a/internal/fusefrontend/file2_holes.go +++ b/internal/fusefrontend/file2_holes.go @@ -6,19 +6,19 @@ import ( "runtime" "syscall" - "github.com/hanwen/go-fuse/v2/fuse" + "github.com/hanwen/go-fuse/v2/fs" "github.com/rfjakob/gocryptfs/internal/tlog" ) // Will a write to plaintext offset "targetOff" create a file hole in the // ciphertext? If yes, zero-pad the last ciphertext block. -func (f *File2) writePadHole(targetOff int64) fuse.Status { +func (f *File2) writePadHole(targetOff int64) syscall.Errno { // Get the current file size. fi, err := f.fd.Stat() if err != nil { tlog.Warn.Printf("checkAndPadHole: Fstat failed: %v", err) - return fuse.ToStatus(err) + return fs.ToErrno(err) } plainSize := f.contentEnc.CipherSizeToPlainSize(uint64(fi.Size())) // Appending a single byte to the file (equivalent to writing to @@ -29,31 +29,31 @@ func (f *File2) writePadHole(targetOff int64) fuse.Status { // The write goes into an existing block or (if the last block was full) // starts a new one directly after the last block. Nothing to do. if targetBlock <= nextBlock { - return fuse.OK + return 0 } // The write goes past the next block. nextBlock has // to be zero-padded to the block boundary and (at least) nextBlock+1 // will contain a file hole in the ciphertext. - status := f.zeroPad(plainSize) - if status != fuse.OK { - return status + errno := f.zeroPad(plainSize) + if errno != 0 { + return errno } - return fuse.OK + return 0 } // Zero-pad the file of size plainSize to the next block boundary. This is a no-op // if the file is already block-aligned. -func (f *File2) zeroPad(plainSize uint64) fuse.Status { +func (f *File2) zeroPad(plainSize uint64) syscall.Errno { lastBlockLen := plainSize % f.contentEnc.PlainBS() if lastBlockLen == 0 { // Already block-aligned - return fuse.OK + return 0 } missing := f.contentEnc.PlainBS() - lastBlockLen pad := make([]byte, missing) tlog.Debug.Printf("zeroPad: Writing %d bytes\n", missing) - _, status := f.doWrite(pad, int64(plainSize)) - return status + _, errno := f.doWrite(pad, int64(plainSize)) + return errno } // SeekData calls the lseek syscall with SEEK_DATA. It returns the offset of the -- cgit v1.2.3