aboutsummaryrefslogtreecommitdiff
path: root/tests/test_helpers/helpers.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2019-01-03 13:32:13 +0100
committerJakob Unterwurzacher2019-01-03 15:31:13 +0100
commitf6dad8d0fae25b5d88ad036b841fea10b7296ccb (patch)
tree6fd3ebb0e8114445027cb36b340925e275f82a84 /tests/test_helpers/helpers.go
parent0fd7637624c6994ce50be8a374648352f3f52501 (diff)
nametransform: simplify WriteDirIV to WriteDirIVAt
Un-spaghettify the function and let the callers open the directory.
Diffstat (limited to 'tests/test_helpers/helpers.go')
-rw-r--r--tests/test_helpers/helpers.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/test_helpers/helpers.go b/tests/test_helpers/helpers.go
index c6a4d6e..9ff29a8 100644
--- a/tests/test_helpers/helpers.go
+++ b/tests/test_helpers/helpers.go
@@ -18,6 +18,7 @@ import (
"github.com/rfjakob/gocryptfs/internal/ctlsock"
"github.com/rfjakob/gocryptfs/internal/nametransform"
+ "github.com/rfjakob/gocryptfs/internal/syscallcompat"
)
// TmpDir will be created inside this directory, set in init() to
@@ -112,7 +113,12 @@ func ResetTmpDir(createDirIV bool) {
panic(err)
}
if createDirIV {
- err = nametransform.WriteDirIV(-1, DefaultCipherDir)
+ // Open cipherdir (following symlinks)
+ dirfd, err := syscall.Open(DefaultCipherDir, syscall.O_RDONLY|syscall.O_DIRECTORY|syscallcompat.O_PATH, 0)
+ if err == nil {
+ err = nametransform.WriteDirIVAt(dirfd)
+ syscall.Close(dirfd)
+ }
if err != nil {
panic(err)
}