summaryrefslogtreecommitdiffhomepage
path: root/pkg/p9
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2021-08-21 01:01:34 +0000
committergVisor bot <gvisor-bot@google.com>2021-08-21 01:01:34 +0000
commit571f7889f5f0da85d2f7d287c73b39e47441c8a6 (patch)
tree4052f8e89d65f8faf6fafe9b4b583666a58ae155 /pkg/p9
parent1f33090b75cc2af7aea5c43b33098f3c19539620 (diff)
parent0a15a216daab9523a5f0c7b93bbceae98dbcbcc1 (diff)
Merge release-20210806.0-54-g0a15a216d (automated)
Diffstat (limited to 'pkg/p9')
-rw-r--r--pkg/p9/file.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/pkg/p9/file.go b/pkg/p9/file.go
index 97e0231d6..8d6af2d6b 100644
--- a/pkg/p9/file.go
+++ b/pkg/p9/file.go
@@ -325,6 +325,12 @@ func (*DisallowServerCalls) Renamed(File, string) {
func DefaultMultiGetAttr(start File, names []string) ([]FullStat, error) {
stats := make([]FullStat, 0, len(names))
parent := start
+ closeParent := func() {
+ if parent != start {
+ _ = parent.Close()
+ }
+ }
+ defer closeParent()
mask := AttrMaskAll()
for i, name := range names {
if len(name) == 0 && i == 0 {
@@ -340,15 +346,14 @@ func DefaultMultiGetAttr(start File, names []string) ([]FullStat, error) {
continue
}
qids, child, valid, attr, err := parent.WalkGetAttr([]string{name})
- if parent != start {
- _ = parent.Close()
- }
if err != nil {
if errors.Is(err, unix.ENOENT) {
return stats, nil
}
return nil, err
}
+ closeParent()
+ parent = child
stats = append(stats, FullStat{
QID: qids[0],
Valid: valid,
@@ -357,13 +362,8 @@ func DefaultMultiGetAttr(start File, names []string) ([]FullStat, error) {
if attr.Mode.FileType() != ModeDirectory {
// Doesn't need to continue if entry is not a dir. Including symlinks
// that cannot be followed.
- _ = child.Close()
break
}
- parent = child
- }
- if parent != start {
- _ = parent.Close()
}
return stats, nil
}