diff options
author | Jakob Unterwurzacher | 2017-12-03 17:57:08 +0100 |
---|---|---|
committer | Jakob Unterwurzacher | 2017-12-03 19:33:26 +0100 |
commit | 70bcf58a9bda5f95a3037fb785858f5d7ce3f930 (patch) | |
tree | 15122949d8adede1b6e8a68e7e2a2b19d42a1660 /internal/fusefrontend | |
parent | e33593d30d9dee6fd6b0e7c0d01832e478815d88 (diff) |
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.
Diffstat (limited to 'internal/fusefrontend')
-rw-r--r-- | internal/fusefrontend/fs_dir.go | 22 |
1 files changed, 8 insertions, 14 deletions
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 |