summaryrefslogtreecommitdiff
path: root/internal/fusefrontend/file2_holes.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2020-07-12 12:59:01 +0200
committerJakob Unterwurzacher2020-07-12 12:59:01 +0200
commit6196a5b5fe78f7a5b8e38c00e656f70c1592e1df (patch)
tree6bb2eb3058080f589a29d7104a09c2c6f3a1162e /internal/fusefrontend/file2_holes.go
parentd539a4c21474a5d45bb3b8432d7b6f07664e61bd (diff)
v2api: File2: implement Release, Read, Write, Fsync, Flush, Allocate
Fortunately, this just means fixing up the function signatures.
Diffstat (limited to 'internal/fusefrontend/file2_holes.go')
-rw-r--r--internal/fusefrontend/file2_holes.go24
1 files changed, 12 insertions, 12 deletions
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