diff options
author | Sebastian Lackner | 2017-11-28 01:11:19 +0100 |
---|---|---|
committer | rfjakob | 2017-11-28 09:28:06 +0100 |
commit | eba49402e44971fdf007c8b33aa71c29bc2a7cad (patch) | |
tree | 70ec3e47078eb6180d39271023577936bc3873bc /internal/fusefrontend/names.go | |
parent | ad2720e0f939ce82605549bdb8c8479c285cb7df (diff) |
fusefrontend: Introduce a openBackingPath helper and use it to simplify Mknod and Symlink
Diffstat (limited to 'internal/fusefrontend/names.go')
-rw-r--r-- | internal/fusefrontend/names.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/internal/fusefrontend/names.go b/internal/fusefrontend/names.go index 3833479..9be2623 100644 --- a/internal/fusefrontend/names.go +++ b/internal/fusefrontend/names.go @@ -3,6 +3,7 @@ package fusefrontend // This file forwards file encryption operations to cryptfs import ( + "os" "path/filepath" "github.com/rfjakob/gocryptfs/internal/configfile" @@ -39,6 +40,20 @@ func (fs *FS) getBackingPath(relPath string) (string, error) { return cAbsPath, nil } +// openBackingPath - get the absolute encrypted path of the backing file +// and open the corresponding directory +func (fs *FS) openBackingPath(relPath string) (*os.File, string, error) { + cPath, err := fs.getBackingPath(relPath) + if err != nil { + return nil, "", err + } + dirfd, err := os.Open(filepath.Dir(cPath)) + if err != nil { + return nil, "", err + } + return dirfd, filepath.Base(cPath), nil +} + // encryptPath - encrypt relative plaintext path func (fs *FS) encryptPath(plainPath string) (string, error) { if fs.args.PlaintextNames { |