aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/fusefrontend/file.go11
-rw-r--r--internal/fusefrontend/node.go10
-rw-r--r--internal/fusefrontend/prepare_syscall_test.go4
-rw-r--r--internal/syscallcompat/open_nofollow_test.go1
4 files changed, 13 insertions, 13 deletions
diff --git a/internal/fusefrontend/file.go b/internal/fusefrontend/file.go
index 716a0db..ef043ae 100644
--- a/internal/fusefrontend/file.go
+++ b/internal/fusefrontend/file.go
@@ -277,16 +277,13 @@ func (f *File) Read(ctx context.Context, buf []byte, off int64) (resultData fuse
// Empty writes do nothing and are allowed.
func (f *File) doWrite(data []byte, off int64) (uint32, syscall.Errno) {
fileWasEmpty := false
- // Get the file ID, create a new one if it does not exist yet.
- var fileID []byte
// The caller has exclusively locked ContentLock, which blocks all other
// readers and writers. No need to take IDLock.
- if f.fileTableEntry.ID != nil {
- fileID = f.fileTableEntry.ID
- } else {
- // If the file ID is not cached, read it from disk
+ //
+ // If the file ID is not cached, read it from disk
+ if f.fileTableEntry.ID == nil {
var err error
- fileID, err = f.readFileID()
+ fileID, err := f.readFileID()
// Write a new file header if the file is empty
if err == io.EOF {
fileID, err = f.createHeader()
diff --git a/internal/fusefrontend/node.go b/internal/fusefrontend/node.go
index 8a3cfa2..7280624 100644
--- a/internal/fusefrontend/node.go
+++ b/internal/fusefrontend/node.go
@@ -354,23 +354,25 @@ func (n *Node) Symlink(ctx context.Context, target, name string, out *fuse.Entry
if !rn.args.PlaintextNames && nametransform.IsLongContent(cName) {
err = rn.nameTransform.WriteLongNameAt(dirfd, cName, name)
if err != nil {
- errno = fs.ToErrno(err)
- return
+ return nil, fs.ToErrno(err)
}
// Create "gocryptfs.longfile." symlink
err = syscallcompat.SymlinkatUser(cTarget, dirfd, cName, ctx2)
if err != nil {
nametransform.DeleteLongNameAt(dirfd, cName)
+ return nil, fs.ToErrno(err)
}
} else {
// Create symlink
err = syscallcompat.SymlinkatUser(cTarget, dirfd, cName, ctx2)
+ if err != nil {
+ return nil, fs.ToErrno(err)
+ }
}
st, err := syscallcompat.Fstatat2(dirfd, cName, unix.AT_SYMLINK_NOFOLLOW)
if err != nil {
- errno = fs.ToErrno(err)
- return
+ return nil, fs.ToErrno(err)
}
// Report the plaintext size, not the encrypted blob size
st.Size = int64(len(target))
diff --git a/internal/fusefrontend/prepare_syscall_test.go b/internal/fusefrontend/prepare_syscall_test.go
index 28e655c..693f62a 100644
--- a/internal/fusefrontend/prepare_syscall_test.go
+++ b/internal/fusefrontend/prepare_syscall_test.go
@@ -63,8 +63,8 @@ func TestPrepareAtSyscall(t *testing.T) {
syscall.Close(dirfd)
dirfd, cName, errno = rn.prepareAtSyscall("dir1")
- if err != nil {
- t.Fatal(err)
+ if errno != 0 {
+ t.Fatal(errno)
}
if cName == "" {
t.Fatal("cName should not be empty")
diff --git a/internal/syscallcompat/open_nofollow_test.go b/internal/syscallcompat/open_nofollow_test.go
index 1eeac3a..0d3ac3d 100644
--- a/internal/syscallcompat/open_nofollow_test.go
+++ b/internal/syscallcompat/open_nofollow_test.go
@@ -33,6 +33,7 @@ func TestOpenNofollow(t *testing.T) {
os.Symlink(tmpDir+"/d1.renamed", tmpDir+"/d1")
fd, err = OpenDirNofollow(tmpDir, "d1/d2/d3")
if err == nil {
+ syscall.Close(fd)
t.Fatalf("should have failed")
}
if err != syscall.ELOOP && err != syscall.ENOTDIR {