From e111e20649cfacd7b02dd454d75db879aa2ca53c Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sat, 6 Feb 2016 22:54:14 +0100 Subject: longnames part I: Create and OpenDir work with long filenames > 176 bytes Todo: Rename, Unlink, Rmdir, Mknod, Mkdir --- internal/fusefrontend/names.go | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'internal/fusefrontend/names.go') diff --git a/internal/fusefrontend/names.go b/internal/fusefrontend/names.go index 5760c87..e913792 100644 --- a/internal/fusefrontend/names.go +++ b/internal/fusefrontend/names.go @@ -3,8 +3,10 @@ package fusefrontend // This file forwards file encryption operations to cryptfs import ( + "path/filepath" + "github.com/rfjakob/gocryptfs/internal/configfile" - mylog "github.com/rfjakob/gocryptfs/internal/toggledlog" + "github.com/rfjakob/gocryptfs/internal/toggledlog" ) // isFiltered - check if plaintext "path" should be forbidden @@ -16,7 +18,7 @@ func (fs *FS) isFiltered(path string) bool { } // gocryptfs.conf in the root directory is forbidden if path == configfile.ConfDefaultName { - mylog.Info.Printf("The name /%s is reserved when -plaintextnames is used\n", + toggledlog.Info.Printf("The name /%s is reserved when -plaintextnames is used\n", configfile.ConfDefaultName) return true } @@ -25,6 +27,18 @@ func (fs *FS) isFiltered(path string) bool { return false } +// GetBackingPath - get the absolute encrypted path of the backing file +// from the relative plaintext path "relPath" +func (fs *FS) getBackingPath(relPath string) (string, error) { + cPath, err := fs.encryptPath(relPath) + if err != nil { + return "", err + } + cAbsPath := filepath.Join(fs.args.Cipherdir, cPath) + toggledlog.Debug.Printf("getBackingPath: %s + %s -> %s", fs.args.Cipherdir, relPath, cAbsPath) + return cAbsPath, nil +} + // encryptPath - encrypt relative plaintext path func (fs *FS) encryptPath(plainPath string) (string, error) { if fs.args.PlaintextNames { @@ -34,8 +48,10 @@ func (fs *FS) encryptPath(plainPath string) (string, error) { return fs.nameTransform.EncryptPathNoIV(plainPath), nil } fs.dirIVLock.RLock() - defer fs.dirIVLock.RUnlock() - return fs.nameTransform.EncryptPathDirIV(plainPath, fs.args.Cipherdir) + cPath, err := fs.nameTransform.EncryptPathDirIV(plainPath, fs.args.Cipherdir) + toggledlog.Debug.Printf("encryptPath '%s' -> '%s' (err: %v)", plainPath, cPath, err) + fs.dirIVLock.RUnlock() + return cPath, err } // decryptPath - decrypt relative ciphertext path @@ -48,5 +64,5 @@ func (fs *FS) decryptPath(cipherPath string) (string, error) { } fs.dirIVLock.RLock() defer fs.dirIVLock.RUnlock() - return fs.nameTransform.DecryptPathDirIV(cipherPath, fs.args.Cipherdir, fs.args.EMENames) + return fs.nameTransform.DecryptPathDirIV(cipherPath, fs.args.Cipherdir) } -- cgit v1.2.3