diff options
author | Ian Lewis <ianlewis@google.com> | 2019-11-26 18:19:47 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2019-11-26 18:21:09 -0800 |
commit | 20279c305ece6a458006999c8dafc5672ca92803 (patch) | |
tree | 086e072c05f1bc0f6f1b972774fad452b7bb6c35 /pkg/sentry/fs/tty/master.go | |
parent | 4a620c436dabbb0d5036e137bfdd44b945e3cff0 (diff) |
Allow open(O_TRUNC) and (f)truncate for proc files.
This allows writable proc and devices files to be opened with O_CREAT|O_TRUNC.
This is encountered most frequently when interacting with proc or devices files
via the command line.
e.g. $ echo 8192 1048576 4194304 > /proc/sys/net/ipv4/tcp_rmem
Also adds a test to test the behavior of open(O_TRUNC), truncate, and ftruncate
on named pipes.
Fixes #1116
PiperOrigin-RevId: 282677425
Diffstat (limited to 'pkg/sentry/fs/tty/master.go')
-rw-r--r-- | pkg/sentry/fs/tty/master.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/pkg/sentry/fs/tty/master.go b/pkg/sentry/fs/tty/master.go index bc56be696..934828c12 100644 --- a/pkg/sentry/fs/tty/master.go +++ b/pkg/sentry/fs/tty/master.go @@ -32,7 +32,6 @@ import ( // +stateify savable type masterInodeOperations struct { fsutil.SimpleFileInode - fsutil.InodeNoopTruncate // d is the containing dir. d *dirInodeOperations @@ -77,6 +76,11 @@ func newMasterInode(ctx context.Context, d *dirInodeOperations, owner fs.FileOwn func (mi *masterInodeOperations) Release(ctx context.Context) { } +// Truncate implements fs.InodeOperations.Truncate. +func (masterInodeOperations) Truncate(context.Context, *fs.Inode, int64) error { + return nil +} + // GetFile implements fs.InodeOperations.GetFile. // // It allocates a new terminal. |