From c270b21efc1d9ecbe5c913c733204f826e263747 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sat, 22 Sep 2018 20:10:34 +0200 Subject: fusefrontend: get rid of os.File* wrapping Directly use int file descriptors for the dirfd and get rid of one level of indirection. --- internal/fusefrontend/names.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'internal/fusefrontend/names.go') diff --git a/internal/fusefrontend/names.go b/internal/fusefrontend/names.go index d7fbdce..86c87f0 100644 --- a/internal/fusefrontend/names.go +++ b/internal/fusefrontend/names.go @@ -3,7 +3,6 @@ package fusefrontend // This file forwards file encryption operations to cryptfs import ( - "os" "path/filepath" "github.com/rfjakob/gocryptfs/internal/configfile" @@ -45,17 +44,17 @@ func (fs *FS) getBackingPath(relPath string) (string, error) { // "relPath" and returns the dirfd and the encrypted basename. // The caller should then use Openat(dirfd, cName, ...) and friends. // openBackingDir is secure against symlink races. -func (fs *FS) openBackingDir(relPath string) (*os.File, string, error) { +func (fs *FS) openBackingDir(relPath string) (int, string, error) { cRelPath, err := fs.encryptPath(relPath) if err != nil { - return nil, "", err + return -1, "", err } // Open parent dir dirfd, err := syscallcompat.OpenDirNofollow(fs.args.Cipherdir, filepath.Dir(cRelPath)) if err != nil { - return nil, "", err + return -1, "", err } - return os.NewFile(uintptr(dirfd), cRelPath), filepath.Base(cRelPath), nil + return dirfd, filepath.Base(cRelPath), nil } // encryptPath - encrypt relative plaintext path -- cgit v1.2.3