summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/kernel/pipe
diff options
context:
space:
mode:
authorBrian Geffon <bgeffon@google.com>2018-06-15 12:54:38 -0700
committerShentubot <shentubot@google.com>2018-06-15 12:55:29 -0700
commitfa6db05e0ce828f2500651ca1226babbbf5edc80 (patch)
tree825534ff5613ccdf3e77129380e5b88ece21ed39 /pkg/sentry/kernel/pipe
parent52110bfc33f294805d89b82385911ab06b9330ba (diff)
FIFOs should support O_TRUNC as a no-op.
PiperOrigin-RevId: 200759323 Change-Id: I683b2edcc2188304c4ca563e46af457e23625905
Diffstat (limited to 'pkg/sentry/kernel/pipe')
-rw-r--r--pkg/sentry/kernel/pipe/node.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/pkg/sentry/kernel/pipe/node.go b/pkg/sentry/kernel/pipe/node.go
index 5b47427ef..e418cf174 100644
--- a/pkg/sentry/kernel/pipe/node.go
+++ b/pkg/sentry/kernel/pipe/node.go
@@ -162,6 +162,18 @@ func (i *inodeOperations) waitFor(wakeupChan *chan struct{}, sleeper amutex.Slee
}
}
+// Truncate implements fs.InodeOperations.Truncate
+//
+// This method is required to override the default i.InodeOperations.Truncate
+// which may return ErrInvalidOperation, this allows open related
+// syscalls to set the O_TRUNC flag without returning an error by
+// calling Truncate directly during openat. The ftruncate and truncate
+// system calls will check that the file is an actual file and return
+// EINVAL because it's a PIPE, making this behavior consistent with linux.
+func (i *inodeOperations) Truncate(context.Context, *fs.Inode, int64) error {
+ return nil
+}
+
// newHandleLocked signals a new pipe reader or writer depending on where
// 'wakeupChan' points. This unblocks any corresponding reader or writer
// waiting for the other end of the channel to be opened, see Fifo.waitFor.