diff --git a/internal/fusefrontend/ctlsock_interface.go b/internal/fusefrontend/ctlsock_interface.go index 2131463..f34739a 100644 --- a/internal/fusefrontend/ctlsock_interface.go +++ b/internal/fusefrontend/ctlsock_interface.go @@ -13,17 +13,17 @@ import ( "github.com/rfjakob/gocryptfs/internal/tlog" ) -var _ ctlsocksrv.Interface = &FS{} // Verify that interface is implemented. +var _ ctlsocksrv.Interface = &RootNode{} // Verify that interface is implemented. // EncryptPath implements ctlsock.Backend // // Symlink-safe through openBackingDir(). -func (fs *FS) EncryptPath(plainPath string) (string, error) { +func (rn *RootNode) EncryptPath(plainPath string) (string, error) { if plainPath == "" { // Empty string gets encrypted as empty string return plainPath, nil } - if fs.args.PlaintextNames { + if rn.args.PlaintextNames { return plainPath, nil } // Encrypt path level by level using openBackingDir. Pretty inefficient, @@ -33,7 +33,7 @@ func (fs *FS) EncryptPath(plainPath string) (string, error) { cPath := "" for _, part := range parts { wd = filepath.Join(wd, part) - dirfd, cName, err := fs.openBackingDir(wd) + dirfd, cName, err := rn.openBackingDir(wd) if err != nil { return "", err } @@ -48,20 +48,20 @@ func (fs *FS) EncryptPath(plainPath string) (string, error) { // // DecryptPath is symlink-safe because openBackingDir() and decryptPathAt() // are symlink-safe. -func (fs *FS) DecryptPath(cipherPath string) (plainPath string, err error) { - dirfd, _, err := fs.openBackingDir("") +func (rn *RootNode) DecryptPath(cipherPath string) (plainPath string, err error) { + dirfd, _, err := rn.openBackingDir("") if err != nil { return "", err } defer syscall.Close(dirfd) - return fs.decryptPathAt(dirfd, cipherPath) + return rn.decryptPathAt(dirfd, cipherPath) } // decryptPathAt decrypts a ciphertext path relative to dirfd. // // Symlink-safe through ReadDirIVAt() and ReadLongNameAt(). -func (fs *FS) decryptPathAt(dirfd int, cipherPath string) (plainPath string, err error) { - if fs.args.PlaintextNames || cipherPath == "" { +func (rn *RootNode) decryptPathAt(dirfd int, cipherPath string) (plainPath string, err error) { + if rn.args.PlaintextNames || cipherPath == "" { return cipherPath, nil } parts := strings.Split(cipherPath, "/") @@ -80,7 +80,7 @@ func (fs *FS) decryptPathAt(dirfd int, cipherPath string) (plainPath string, err return "", err } } - name, err := fs.nameTransform.DecryptName(longPart, dirIV) + name, err := rn.nameTransform.DecryptName(longPart, dirIV) if err != nil { fmt.Printf("DecryptName: %v\n", err) return "", err