fusefrontend: use Getdents if available
Getdents avoids calling Lstat on each file.
This commit is contained in:
parent
e50a6a57e5
commit
989b880989
|
@ -242,16 +242,25 @@ func (fs *FS) OpenDir(dirName string, context *fuse.Context) ([]fuse.DirEntry, f
|
||||||
return nil, fuse.ToStatus(err)
|
return nil, fuse.ToStatus(err)
|
||||||
}
|
}
|
||||||
// Read ciphertext directory
|
// Read ciphertext directory
|
||||||
cipherEntries, status := fs.FileSystem.OpenDir(cDirName, context)
|
cDirAbsPath := filepath.Join(fs.args.Cipherdir, cDirName)
|
||||||
if cipherEntries == nil {
|
var cipherEntries []fuse.DirEntry
|
||||||
return nil, status
|
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)
|
// Get DirIV (stays nil if PlaintextNames is used)
|
||||||
var cachedIV []byte
|
var cachedIV []byte
|
||||||
var cDirAbsPath string
|
|
||||||
if !fs.args.PlaintextNames {
|
if !fs.args.PlaintextNames {
|
||||||
// Read the DirIV once and use it for all later name decryptions
|
// Read the DirIV once and use it for all later name decryptions
|
||||||
cDirAbsPath = filepath.Join(fs.args.Cipherdir, cDirName)
|
|
||||||
cachedIV, err = nametransform.ReadDirIV(cDirAbsPath)
|
cachedIV, err = nametransform.ReadDirIV(cDirAbsPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// This can happen during normal operation when the directory has
|
// This can happen during normal operation when the directory has
|
||||||
|
|
Loading…
Reference in New Issue