summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fsimpl/gofer
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-08-31 21:00:22 +0000
committergVisor bot <gvisor-bot@google.com>2020-08-31 21:00:22 +0000
commit2c813fd661746668b37c37247aac1572994771be (patch)
tree23069bf61c01c145a983613a1332982c16eb88a6 /pkg/sentry/fsimpl/gofer
parent503e617835a0db546644a09f60e73682cf856f6c (diff)
parent6cdfa4fee06dfe4d37b79a8426906c99fe294964 (diff)
Merge release-20200818.0-93-g6cdfa4fee (automated)
Diffstat (limited to 'pkg/sentry/fsimpl/gofer')
-rw-r--r--pkg/sentry/fsimpl/gofer/gofer.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/pkg/sentry/fsimpl/gofer/gofer.go b/pkg/sentry/fsimpl/gofer/gofer.go
index 81d34cfe3..57bff1789 100644
--- a/pkg/sentry/fsimpl/gofer/gofer.go
+++ b/pkg/sentry/fsimpl/gofer/gofer.go
@@ -1472,8 +1472,9 @@ func (d *dentry) ensureSharedHandle(ctx context.Context, read, write, trunc bool
return err
}
- if d.hostFD < 0 && openReadable && h.fd >= 0 {
- // We have no existing FD; use the new FD for at least reading.
+ if d.hostFD < 0 && h.fd >= 0 && openReadable && (d.writeFile.isNil() || openWritable) {
+ // We have no existing FD, and the new FD meets the requirements
+ // for d.hostFD, so start using it.
d.hostFD = h.fd
} else if d.hostFD >= 0 && d.writeFile.isNil() && openWritable {
// We have an existing read-only FD, but the file has just been