diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-09-02 02:25:18 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-09-02 02:25:18 +0000 |
commit | 2e80f58b0d18b8dd122dc192a1cef9aa6a2da56f (patch) | |
tree | b21a43a5da78fe858a03f51c92533455195e7fdf /pkg/p9/handlers.go | |
parent | 01ab43f3f87e34c2a661bfdcf560dd9b5173974a (diff) | |
parent | 37a217aca4a128d66a6dd4969375ea81bd879ac7 (diff) |
Merge release-20200818.0-105-g37a217aca (automated)
Diffstat (limited to 'pkg/p9/handlers.go')
-rw-r--r-- | pkg/p9/handlers.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/pkg/p9/handlers.go b/pkg/p9/handlers.go index 1db5797dd..abd237f46 100644 --- a/pkg/p9/handlers.go +++ b/pkg/p9/handlers.go @@ -123,6 +123,37 @@ func (t *Tclunk) handle(cs *connState) message { return &Rclunk{} } +func (t *Tsetattrclunk) handle(cs *connState) message { + ref, ok := cs.LookupFID(t.FID) + if !ok { + return newErr(syscall.EBADF) + } + defer ref.DecRef() + + setAttrErr := ref.safelyWrite(func() error { + // We don't allow setattr on files that have been deleted. + // This might be technically incorrect, as it's possible that + // there were multiple links and you can still change the + // corresponding inode information. + if ref.isDeleted() { + return syscall.EINVAL + } + + // Set the attributes. + return ref.file.SetAttr(t.Valid, t.SetAttr) + }) + + // Try to delete FID even in case of failure above. Since the state of the + // file is unknown to the caller, it will not attempt to close the file again. + if !cs.DeleteFID(t.FID) { + return newErr(syscall.EBADF) + } + if setAttrErr != nil { + return newErr(setAttrErr) + } + return &Rsetattrclunk{} +} + // handle implements handler.handle. func (t *Tremove) handle(cs *connState) message { ref, ok := cs.LookupFID(t.FID) |