summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fs
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/sentry/fs')
-rw-r--r--pkg/sentry/fs/inode.go4
-rw-r--r--pkg/sentry/fs/tty/master.go1
-rw-r--r--pkg/sentry/fs/tty/slave.go1
-rwxr-xr-xpkg/sentry/fs/tty/tty_state_autogen.go4
4 files changed, 10 insertions, 0 deletions
diff --git a/pkg/sentry/fs/inode.go b/pkg/sentry/fs/inode.go
index f4ddfa406..2d43dff1d 100644
--- a/pkg/sentry/fs/inode.go
+++ b/pkg/sentry/fs/inode.go
@@ -344,6 +344,10 @@ func (i *Inode) SetTimestamps(ctx context.Context, d *Dirent, ts TimeSpec) error
// Truncate calls i.InodeOperations.Truncate with i as the Inode.
func (i *Inode) Truncate(ctx context.Context, d *Dirent, size int64) error {
+ if IsDir(i.StableAttr) {
+ return syserror.EISDIR
+ }
+
if i.overlay != nil {
return overlayTruncate(ctx, i.overlay, d, size)
}
diff --git a/pkg/sentry/fs/tty/master.go b/pkg/sentry/fs/tty/master.go
index 19b7557d5..bc56be696 100644
--- a/pkg/sentry/fs/tty/master.go
+++ b/pkg/sentry/fs/tty/master.go
@@ -32,6 +32,7 @@ import (
// +stateify savable
type masterInodeOperations struct {
fsutil.SimpleFileInode
+ fsutil.InodeNoopTruncate
// d is the containing dir.
d *dirInodeOperations
diff --git a/pkg/sentry/fs/tty/slave.go b/pkg/sentry/fs/tty/slave.go
index 944c4ada1..4cbea0367 100644
--- a/pkg/sentry/fs/tty/slave.go
+++ b/pkg/sentry/fs/tty/slave.go
@@ -31,6 +31,7 @@ import (
// +stateify savable
type slaveInodeOperations struct {
fsutil.SimpleFileInode
+ fsutil.InodeNoopTruncate
// d is the containing dir.
d *dirInodeOperations
diff --git a/pkg/sentry/fs/tty/tty_state_autogen.go b/pkg/sentry/fs/tty/tty_state_autogen.go
index c54600104..676e531c7 100755
--- a/pkg/sentry/fs/tty/tty_state_autogen.go
+++ b/pkg/sentry/fs/tty/tty_state_autogen.go
@@ -101,12 +101,14 @@ func (x *masterInodeOperations) beforeSave() {}
func (x *masterInodeOperations) save(m state.Map) {
x.beforeSave()
m.Save("SimpleFileInode", &x.SimpleFileInode)
+ m.Save("InodeNoopTruncate", &x.InodeNoopTruncate)
m.Save("d", &x.d)
}
func (x *masterInodeOperations) afterLoad() {}
func (x *masterInodeOperations) load(m state.Map) {
m.Load("SimpleFileInode", &x.SimpleFileInode)
+ m.Load("InodeNoopTruncate", &x.InodeNoopTruncate)
m.Load("d", &x.d)
}
@@ -146,6 +148,7 @@ func (x *slaveInodeOperations) beforeSave() {}
func (x *slaveInodeOperations) save(m state.Map) {
x.beforeSave()
m.Save("SimpleFileInode", &x.SimpleFileInode)
+ m.Save("InodeNoopTruncate", &x.InodeNoopTruncate)
m.Save("d", &x.d)
m.Save("t", &x.t)
}
@@ -153,6 +156,7 @@ func (x *slaveInodeOperations) save(m state.Map) {
func (x *slaveInodeOperations) afterLoad() {}
func (x *slaveInodeOperations) load(m state.Map) {
m.Load("SimpleFileInode", &x.SimpleFileInode)
+ m.Load("InodeNoopTruncate", &x.InodeNoopTruncate)
m.Load("d", &x.d)
m.Load("t", &x.t)
}