aboutsummaryrefslogtreecommitdiff
path: root/internal/fusefrontend/fs_dir.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2017-08-15 18:35:30 +0200
committerJakob Unterwurzacher2017-08-15 19:04:02 +0200
commit989b88098951e5ad68b66049e59fd2ca475c4711 (patch)
tree189387bad1071586c246b17f2b0a4373aca56399 /internal/fusefrontend/fs_dir.go
parente50a6a57e57bc3cc925ba9a6e7f4dc1da4da3c84 (diff)
fusefrontend: use Getdents if available
Getdents avoids calling Lstat on each file.
Diffstat (limited to 'internal/fusefrontend/fs_dir.go')
-rw-r--r--internal/fusefrontend/fs_dir.go19
1 files changed, 14 insertions, 5 deletions
diff --git a/internal/fusefrontend/fs_dir.go b/internal/fusefrontend/fs_dir.go
index 30e715a..44a4ad2 100644
--- a/internal/fusefrontend/fs_dir.go
+++ b/internal/fusefrontend/fs_dir.go
@@ -242,16 +242,25 @@ func (fs *FS) OpenDir(dirName string, context *fuse.Context) ([]fuse.DirEntry, f
return nil, fuse.ToStatus(err)
}
// Read ciphertext directory
- cipherEntries, status := fs.FileSystem.OpenDir(cDirName, context)
- if cipherEntries == nil {
- return nil, status
+ 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 {
+ cipherEntries, status = fs.FileSystem.OpenDir(cDirName, context)
+ if !status.Ok() {
+ return nil, status
+ }
}
// Get DirIV (stays nil if PlaintextNames is used)
var cachedIV []byte
- var cDirAbsPath string
if !fs.args.PlaintextNames {
// Read the DirIV once and use it for all later name decryptions
- cDirAbsPath = filepath.Join(fs.args.Cipherdir, cDirName)
cachedIV, err = nametransform.ReadDirIV(cDirAbsPath)
if err != nil {
// This can happen during normal operation when the directory has