From 0f44c617d01f3e203933459be5fb64c1904d40b6 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Wed, 29 Nov 2017 12:23:40 +0100 Subject: syscallcompat: Introduce unlinkat syscall with flags argument --- internal/fusefrontend/fs.go | 2 +- internal/fusefrontend/fs_dir.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'internal/fusefrontend') diff --git a/internal/fusefrontend/fs.go b/internal/fusefrontend/fs.go index 08edd2b..002b4e1 100644 --- a/internal/fusefrontend/fs.go +++ b/internal/fusefrontend/fs.go @@ -388,7 +388,7 @@ func (fs *FS) Unlink(path string, context *fuse.Context) (code fuse.Status) { } defer dirfd.Close() // Delete content - err = syscallcompat.Unlinkat(int(dirfd.Fd()), cName) + err = syscallcompat.Unlinkat(int(dirfd.Fd()), cName, 0) if err != nil { return fuse.ToStatus(err) } diff --git a/internal/fusefrontend/fs_dir.go b/internal/fusefrontend/fs_dir.go index 91c899e..ae150b5 100644 --- a/internal/fusefrontend/fs_dir.go +++ b/internal/fusefrontend/fs_dir.go @@ -11,6 +11,8 @@ import ( "sync" "syscall" + "golang.org/x/sys/unix" + "github.com/hanwen/go-fuse/fuse" "github.com/rfjakob/gocryptfs/internal/configfile" @@ -231,9 +233,7 @@ retry: return fuse.ToStatus(err) } // Actual Rmdir - // TODO Use syscall.Unlinkat with the AT_REMOVEDIR flag once it is available - // in Go - err = syscall.Rmdir(cPath) + err = syscallcompat.Unlinkat(int(parentDirFd.Fd()), cName, unix.AT_REMOVEDIR) if err != nil { // This can happen if another file in the directory was created in the // meantime, undo the rename @@ -245,7 +245,7 @@ retry: return fuse.ToStatus(err) } // Delete "gocryptfs.diriv.rmdir.XYZ" - err = syscallcompat.Unlinkat(int(parentDirFd.Fd()), tmpName) + err = syscallcompat.Unlinkat(int(parentDirFd.Fd()), tmpName, 0) if err != nil { tlog.Warn.Printf("Rmdir: Could not clean up %s: %v", tmpName, err) } -- cgit v1.2.3