Skip to content

Commit c9457cb

Browse files
committed
fix Lookup
1 parent 745f4d0 commit c9457cb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

nfs/target.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,9 @@ func (v *Target) Lookup(p string) (os.FileInfo, []byte, error) {
155155
dirents := strings.Split(path.Clean(p), "/")
156156
for _, dirent := range dirents {
157157
// we're assuming the root is always the root of the mount
158-
if dirent == "." || dirent == "" {
158+
if dirent == "" {
159159
util.Debugf("root -> 0x%x", fh)
160-
continue
160+
dirent = "."
161161
}
162162

163163
fattr, fh, err = v.cachedLookup(fh, dirent)
@@ -189,7 +189,7 @@ func (v *Target) cachedLookup(fh []byte, name string) (*Fattr, []byte, error) {
189189
}
190190
v.cacheM.Unlock()
191191
attr, fh, err := v.lookup(fh, name)
192-
if err == nil {
192+
if err == nil && attr.Type == 2 { // only cache directories
193193
if es == nil {
194194
es = make(map[string]*cacheEntry)
195195
v.entries[ino] = es
@@ -198,7 +198,7 @@ func (v *Target) cachedLookup(fh []byte, name string) (*Fattr, []byte, error) {
198198
es[name] = &cacheEntry{fh, attr, time.Now().Add(v.entryTimeout)}
199199
v.cacheM.Unlock()
200200
}
201-
return nil, nil, nil
201+
return attr, fh, err
202202
}
203203

204204
func (v *Target) invalidateEntryCache(fh []byte, name string) {

0 commit comments

Comments
 (0)