summaryrefslogtreecommitdiff
path: root/internal/fusefrontend/fs_dir.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 /internal/fusefrontend/fs_dir.go
parent0fd7637624c6994ce50be8a374648352f3f52501 (diff)
nametransform: simplify WriteDirIV to WriteDirIVAt
Un-spaghettify the function and let the callers open the directory.
Diffstat (limited to 'internal/fusefrontend/fs_dir.go')
-rw-r--r--internal/fusefrontend/fs_dir.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/internal/fusefrontend/fs_dir.go b/internal/fusefrontend/fs_dir.go
index 181ccb5..302fe38 100644
--- a/internal/fusefrontend/fs_dir.go
+++ b/internal/fusefrontend/fs_dir.go
@@ -37,9 +37,14 @@ func (fs *FS) mkdirWithIv(dirfd int, cName string, mode uint32) error {
if err != nil {
return err
}
- // Create gocryptfs.diriv
- err = nametransform.WriteDirIV(dirfd, cName)
+ dirfd2, err := syscallcompat.Openat(dirfd, cName, syscall.O_DIRECTORY|syscall.O_NOFOLLOW|syscallcompat.O_PATH, 0)
+ if err == nil {
+ // Create gocryptfs.diriv
+ err = nametransform.WriteDirIVAt(dirfd2)
+ syscall.Close(dirfd2)
+ }
if err != nil {
+ // Delete inconsistent directory (missing gocryptfs.diriv!)
err2 := syscallcompat.Unlinkat(dirfd, cName, unix.AT_REMOVEDIR)
if err2 != nil {
tlog.Warn.Printf("mkdirWithIv: rollback failed: %v", err2)