From 70bcf58a9bda5f95a3037fb785858f5d7ce3f930 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 3 Dec 2017 17:57:08 +0100 Subject: syscallcompat: convert Getdents to fd input, add emulation Now that we have Fstatat we can use it in Getdents to get rid of the path name. Also, add an emulated version of getdents for MacOS. This allows to drop the !HaveGetdents special cases from fusefrontend. Modify the getdents test to test both native getdents and the emulated version. --- internal/fusefrontend/fs_dir.go | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'internal/fusefrontend') diff --git a/internal/fusefrontend/fs_dir.go b/internal/fusefrontend/fs_dir.go index ae52412..2102008 100644 --- a/internal/fusefrontend/fs_dir.go +++ b/internal/fusefrontend/fs_dir.go @@ -271,20 +271,14 @@ func (fs *FS) OpenDir(dirName string, context *fuse.Context) ([]fuse.DirEntry, f cDirAbsPath := filepath.Join(fs.args.Cipherdir, cDirName) var cipherEntries []fuse.DirEntry var status fuse.Status - if syscallcompat.HaveGetdents { - // Getdents avoids calling Lstat on each file. - cipherEntries, err = syscallcompat.Getdents(cDirAbsPath) - if err != nil { - return nil, fuse.ToStatus(err) - } - } else { - haveGetdentsWarnOnce.Do(func() { - tlog.Warn.Printf("OpenDir: Getdents not available, falling back to OpenDir") - }) - cipherEntries, status = fs.FileSystem.OpenDir(cDirName, context) - if !status.Ok() { - return nil, status - } + fd, err := syscall.Open(cDirAbsPath, syscall.O_RDONLY|syscall.O_NOFOLLOW, 0) + if err != nil { + return nil, fuse.ToStatus(err) + } + defer syscall.Close(fd) + cipherEntries, err = syscallcompat.Getdents(fd) + if err != nil { + return nil, fuse.ToStatus(err) } // Get DirIV (stays nil if PlaintextNames is used) var cachedIV []byte -- cgit v1.2.3