From fa6db05e0ce828f2500651ca1226babbbf5edc80 Mon Sep 17 00:00:00 2001 From: Brian Geffon Date: Fri, 15 Jun 2018 12:54:38 -0700 Subject: FIFOs should support O_TRUNC as a no-op. PiperOrigin-RevId: 200759323 Change-Id: I683b2edcc2188304c4ca563e46af457e23625905 --- pkg/sentry/kernel/pipe/node.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'pkg/sentry/kernel') 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. -- cgit v1.2.3