diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-04-21 23:36:34 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-04-21 23:36:34 +0000 |
commit | 9e983d691225db47475f4447899e7421864b9b6c (patch) | |
tree | 7fe8779aa43d31d1c6199f5e44458eb1d8a425a7 /pkg/sentry/vfs/file_description.go | |
parent | 306c14cdd4e68b95703e78c3877b627d4f7d7885 (diff) | |
parent | 37e01fd2ea6a0e67637975863317be9aae1b02f0 (diff) |
Merge release-20200323.0-207-g37e01fd (automated)
Diffstat (limited to 'pkg/sentry/vfs/file_description.go')
-rwxr-xr-x | pkg/sentry/vfs/file_description.go | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/pkg/sentry/vfs/file_description.go b/pkg/sentry/vfs/file_description.go index 15cc091e2..418d69b96 100755 --- a/pkg/sentry/vfs/file_description.go +++ b/pkg/sentry/vfs/file_description.go @@ -111,10 +111,10 @@ type FileDescriptionOptions struct { } // Init must be called before first use of fd. If it succeeds, it takes -// references on mnt and d. statusFlags is the initial file description status -// flags, which is usually the full set of flags passed to open(2). -func (fd *FileDescription) Init(impl FileDescriptionImpl, statusFlags uint32, mnt *Mount, d *Dentry, opts *FileDescriptionOptions) error { - writable := MayWriteFileWithOpenFlags(statusFlags) +// references on mnt and d. flags is the initial file description flags, which +// is usually the full set of flags passed to open(2). +func (fd *FileDescription) Init(impl FileDescriptionImpl, flags uint32, mnt *Mount, d *Dentry, opts *FileDescriptionOptions) error { + writable := MayWriteFileWithOpenFlags(flags) if writable { if err := mnt.CheckBeginWrite(); err != nil { return err @@ -122,7 +122,10 @@ func (fd *FileDescription) Init(impl FileDescriptionImpl, statusFlags uint32, mn } fd.refs = 1 - fd.statusFlags = statusFlags + + // Remove "file creation flags" to mirror the behavior from file.f_flags in + // fs/open.c:do_dentry_open + fd.statusFlags = flags &^ (linux.O_CREAT | linux.O_EXCL | linux.O_NOCTTY | linux.O_TRUNC) fd.vd = VirtualDentry{ mount: mnt, dentry: d, @@ -130,7 +133,7 @@ func (fd *FileDescription) Init(impl FileDescriptionImpl, statusFlags uint32, mn mnt.IncRef() d.IncRef() fd.opts = *opts - fd.readable = MayReadFileWithOpenFlags(statusFlags) + fd.readable = MayReadFileWithOpenFlags(flags) fd.writable = writable fd.impl = impl return nil |