summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fsimpl/overlay
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-09-24 17:19:53 +0000
committergVisor bot <gvisor-bot@google.com>2020-09-24 17:19:53 +0000
commit61cc049caaa2317eda73e66f65f82b5099dd2bc2 (patch)
tree352bfc9c114c181e052a9656be9f3b2acd5f7b33 /pkg/sentry/fsimpl/overlay
parent3102024707dc370e025f1b46fa2be12eade2f9cb (diff)
parent0a7075f38a4870ded687e117a299ac4996c0673e (diff)
Merge release-20200914.0-152-g0a7075f38 (automated)
Diffstat (limited to 'pkg/sentry/fsimpl/overlay')
-rw-r--r--pkg/sentry/fsimpl/overlay/directory.go3
-rw-r--r--pkg/sentry/fsimpl/overlay/non_directory.go3
-rw-r--r--pkg/sentry/fsimpl/overlay/overlay.go16
-rw-r--r--pkg/sentry/fsimpl/overlay/overlay_state_autogen.go282
4 files changed, 299 insertions, 5 deletions
diff --git a/pkg/sentry/fsimpl/overlay/directory.go b/pkg/sentry/fsimpl/overlay/directory.go
index 7ab42e71e..aea599460 100644
--- a/pkg/sentry/fsimpl/overlay/directory.go
+++ b/pkg/sentry/fsimpl/overlay/directory.go
@@ -100,12 +100,13 @@ func (d *dentry) collectWhiteoutsForRmdirLocked(ctx context.Context) (map[string
return whiteouts, readdirErr
}
+// +stateify savable
type directoryFD struct {
fileDescription
vfs.DirectoryFileDescriptionDefaultImpl
vfs.DentryMetadataFileDescriptionImpl
- mu sync.Mutex
+ mu sync.Mutex `state:"nosave"`
off int64
dirents []vfs.Dirent
}
diff --git a/pkg/sentry/fsimpl/overlay/non_directory.go b/pkg/sentry/fsimpl/overlay/non_directory.go
index 6e04705c7..50b4a50f1 100644
--- a/pkg/sentry/fsimpl/overlay/non_directory.go
+++ b/pkg/sentry/fsimpl/overlay/non_directory.go
@@ -39,6 +39,7 @@ func (d *dentry) readlink(ctx context.Context) (string, error) {
})
}
+// +stateify savable
type nonDirectoryFD struct {
fileDescription
@@ -47,7 +48,7 @@ type nonDirectoryFD struct {
// fileDescription.dentry().upperVD. cachedFlags is the last known value of
// cachedFD.StatusFlags(). copiedUp, cachedFD, and cachedFlags are
// protected by mu.
- mu sync.Mutex
+ mu sync.Mutex `state:"nosave"`
copiedUp bool
cachedFD *vfs.FileDescription
cachedFlags uint32
diff --git a/pkg/sentry/fsimpl/overlay/overlay.go b/pkg/sentry/fsimpl/overlay/overlay.go
index d0d26185e..b03fa9121 100644
--- a/pkg/sentry/fsimpl/overlay/overlay.go
+++ b/pkg/sentry/fsimpl/overlay/overlay.go
@@ -51,6 +51,8 @@ import (
const Name = "overlay"
// FilesystemType implements vfs.FilesystemType.
+//
+// +stateify savable
type FilesystemType struct{}
// Name implements vfs.FilesystemType.Name.
@@ -60,6 +62,8 @@ func (FilesystemType) Name() string {
// FilesystemOptions may be passed as vfs.GetFilesystemOptions.InternalData to
// FilesystemType.GetFilesystem.
+//
+// +stateify savable
type FilesystemOptions struct {
// Callers passing FilesystemOptions to
// overlay.FilesystemType.GetFilesystem() are responsible for ensuring that
@@ -76,6 +80,8 @@ type FilesystemOptions struct {
}
// filesystem implements vfs.FilesystemImpl.
+//
+// +stateify savable
type filesystem struct {
vfsfs vfs.Filesystem
@@ -98,7 +104,7 @@ type filesystem struct {
// renameMu synchronizes renaming with non-renaming operations in order to
// ensure consistent lock ordering between dentry.dirMu in different
// dentries.
- renameMu sync.RWMutex
+ renameMu sync.RWMutex `state:"nosave"`
// lastDirIno is the last inode number assigned to a directory. lastDirIno
// is accessed using atomic memory operations.
@@ -367,6 +373,8 @@ func (fs *filesystem) newDirIno() uint64 {
}
// dentry implements vfs.DentryImpl.
+//
+// +stateify savable
type dentry struct {
vfsd vfs.Dentry
@@ -399,7 +407,7 @@ type dentry struct {
// and dirents (if not nil) is a cache of dirents as returned by
// directoryFDs representing this directory. children is protected by
// dirMu.
- dirMu sync.Mutex
+ dirMu sync.Mutex `state:"nosave"`
children map[string]*dentry
dirents []vfs.Dirent
@@ -409,7 +417,7 @@ type dentry struct {
// If !upperVD.Ok(), it can transition to a valid vfs.VirtualDentry (i.e.
// be copied up) with copyMu locked for writing; otherwise, it is
// immutable. lowerVDs is always immutable.
- copyMu sync.RWMutex
+ copyMu sync.RWMutex `state:"nosave"`
upperVD vfs.VirtualDentry
lowerVDs []vfs.VirtualDentry
@@ -652,6 +660,8 @@ func (d *dentry) updateAfterSetStatLocked(opts *vfs.SetStatOptions) {
// fileDescription is embedded by overlay implementations of
// vfs.FileDescriptionImpl.
+//
+// +stateify savable
type fileDescription struct {
vfsfd vfs.FileDescription
vfs.FileDescriptionDefaultImpl
diff --git a/pkg/sentry/fsimpl/overlay/overlay_state_autogen.go b/pkg/sentry/fsimpl/overlay/overlay_state_autogen.go
index 0c184964f..5fd2dc37e 100644
--- a/pkg/sentry/fsimpl/overlay/overlay_state_autogen.go
+++ b/pkg/sentry/fsimpl/overlay/overlay_state_autogen.go
@@ -1,3 +1,285 @@
// automatically generated by stateify.
package overlay
+
+import (
+ "gvisor.dev/gvisor/pkg/state"
+)
+
+func (x *directoryFD) StateTypeName() string {
+ return "pkg/sentry/fsimpl/overlay.directoryFD"
+}
+
+func (x *directoryFD) StateFields() []string {
+ return []string{
+ "fileDescription",
+ "DirectoryFileDescriptionDefaultImpl",
+ "DentryMetadataFileDescriptionImpl",
+ "off",
+ "dirents",
+ }
+}
+
+func (x *directoryFD) beforeSave() {}
+
+func (x *directoryFD) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.fileDescription)
+ m.Save(1, &x.DirectoryFileDescriptionDefaultImpl)
+ m.Save(2, &x.DentryMetadataFileDescriptionImpl)
+ m.Save(3, &x.off)
+ m.Save(4, &x.dirents)
+}
+
+func (x *directoryFD) afterLoad() {}
+
+func (x *directoryFD) StateLoad(m state.Source) {
+ m.Load(0, &x.fileDescription)
+ m.Load(1, &x.DirectoryFileDescriptionDefaultImpl)
+ m.Load(2, &x.DentryMetadataFileDescriptionImpl)
+ m.Load(3, &x.off)
+ m.Load(4, &x.dirents)
+}
+
+func (x *nonDirectoryFD) StateTypeName() string {
+ return "pkg/sentry/fsimpl/overlay.nonDirectoryFD"
+}
+
+func (x *nonDirectoryFD) StateFields() []string {
+ return []string{
+ "fileDescription",
+ "copiedUp",
+ "cachedFD",
+ "cachedFlags",
+ }
+}
+
+func (x *nonDirectoryFD) beforeSave() {}
+
+func (x *nonDirectoryFD) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.fileDescription)
+ m.Save(1, &x.copiedUp)
+ m.Save(2, &x.cachedFD)
+ m.Save(3, &x.cachedFlags)
+}
+
+func (x *nonDirectoryFD) afterLoad() {}
+
+func (x *nonDirectoryFD) StateLoad(m state.Source) {
+ m.Load(0, &x.fileDescription)
+ m.Load(1, &x.copiedUp)
+ m.Load(2, &x.cachedFD)
+ m.Load(3, &x.cachedFlags)
+}
+
+func (x *FilesystemType) StateTypeName() string {
+ return "pkg/sentry/fsimpl/overlay.FilesystemType"
+}
+
+func (x *FilesystemType) StateFields() []string {
+ return []string{}
+}
+
+func (x *FilesystemType) beforeSave() {}
+
+func (x *FilesystemType) StateSave(m state.Sink) {
+ x.beforeSave()
+}
+
+func (x *FilesystemType) afterLoad() {}
+
+func (x *FilesystemType) StateLoad(m state.Source) {
+}
+
+func (x *FilesystemOptions) StateTypeName() string {
+ return "pkg/sentry/fsimpl/overlay.FilesystemOptions"
+}
+
+func (x *FilesystemOptions) StateFields() []string {
+ return []string{
+ "UpperRoot",
+ "LowerRoots",
+ }
+}
+
+func (x *FilesystemOptions) beforeSave() {}
+
+func (x *FilesystemOptions) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.UpperRoot)
+ m.Save(1, &x.LowerRoots)
+}
+
+func (x *FilesystemOptions) afterLoad() {}
+
+func (x *FilesystemOptions) StateLoad(m state.Source) {
+ m.Load(0, &x.UpperRoot)
+ m.Load(1, &x.LowerRoots)
+}
+
+func (x *filesystem) StateTypeName() string {
+ return "pkg/sentry/fsimpl/overlay.filesystem"
+}
+
+func (x *filesystem) StateFields() []string {
+ return []string{
+ "vfsfs",
+ "opts",
+ "creds",
+ "dirDevMinor",
+ "lowerDevMinors",
+ "lastDirIno",
+ }
+}
+
+func (x *filesystem) beforeSave() {}
+
+func (x *filesystem) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.vfsfs)
+ m.Save(1, &x.opts)
+ m.Save(2, &x.creds)
+ m.Save(3, &x.dirDevMinor)
+ m.Save(4, &x.lowerDevMinors)
+ m.Save(5, &x.lastDirIno)
+}
+
+func (x *filesystem) afterLoad() {}
+
+func (x *filesystem) StateLoad(m state.Source) {
+ m.Load(0, &x.vfsfs)
+ m.Load(1, &x.opts)
+ m.Load(2, &x.creds)
+ m.Load(3, &x.dirDevMinor)
+ m.Load(4, &x.lowerDevMinors)
+ m.Load(5, &x.lastDirIno)
+}
+
+func (x *dentry) StateTypeName() string {
+ return "pkg/sentry/fsimpl/overlay.dentry"
+}
+
+func (x *dentry) StateFields() []string {
+ return []string{
+ "vfsd",
+ "refs",
+ "fs",
+ "mode",
+ "uid",
+ "gid",
+ "copiedUp",
+ "parent",
+ "name",
+ "children",
+ "dirents",
+ "upperVD",
+ "lowerVDs",
+ "inlineLowerVDs",
+ "devMajor",
+ "devMinor",
+ "ino",
+ "mapsMu",
+ "lowerMappings",
+ "dataMu",
+ "wrappedMappable",
+ "isMappable",
+ "locks",
+ }
+}
+
+func (x *dentry) beforeSave() {}
+
+func (x *dentry) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.vfsd)
+ m.Save(1, &x.refs)
+ m.Save(2, &x.fs)
+ m.Save(3, &x.mode)
+ m.Save(4, &x.uid)
+ m.Save(5, &x.gid)
+ m.Save(6, &x.copiedUp)
+ m.Save(7, &x.parent)
+ m.Save(8, &x.name)
+ m.Save(9, &x.children)
+ m.Save(10, &x.dirents)
+ m.Save(11, &x.upperVD)
+ m.Save(12, &x.lowerVDs)
+ m.Save(13, &x.inlineLowerVDs)
+ m.Save(14, &x.devMajor)
+ m.Save(15, &x.devMinor)
+ m.Save(16, &x.ino)
+ m.Save(17, &x.mapsMu)
+ m.Save(18, &x.lowerMappings)
+ m.Save(19, &x.dataMu)
+ m.Save(20, &x.wrappedMappable)
+ m.Save(21, &x.isMappable)
+ m.Save(22, &x.locks)
+}
+
+func (x *dentry) afterLoad() {}
+
+func (x *dentry) StateLoad(m state.Source) {
+ m.Load(0, &x.vfsd)
+ m.Load(1, &x.refs)
+ m.Load(2, &x.fs)
+ m.Load(3, &x.mode)
+ m.Load(4, &x.uid)
+ m.Load(5, &x.gid)
+ m.Load(6, &x.copiedUp)
+ m.Load(7, &x.parent)
+ m.Load(8, &x.name)
+ m.Load(9, &x.children)
+ m.Load(10, &x.dirents)
+ m.Load(11, &x.upperVD)
+ m.Load(12, &x.lowerVDs)
+ m.Load(13, &x.inlineLowerVDs)
+ m.Load(14, &x.devMajor)
+ m.Load(15, &x.devMinor)
+ m.Load(16, &x.ino)
+ m.Load(17, &x.mapsMu)
+ m.Load(18, &x.lowerMappings)
+ m.Load(19, &x.dataMu)
+ m.Load(20, &x.wrappedMappable)
+ m.Load(21, &x.isMappable)
+ m.Load(22, &x.locks)
+}
+
+func (x *fileDescription) StateTypeName() string {
+ return "pkg/sentry/fsimpl/overlay.fileDescription"
+}
+
+func (x *fileDescription) StateFields() []string {
+ return []string{
+ "vfsfd",
+ "FileDescriptionDefaultImpl",
+ "LockFD",
+ }
+}
+
+func (x *fileDescription) beforeSave() {}
+
+func (x *fileDescription) StateSave(m state.Sink) {
+ x.beforeSave()
+ m.Save(0, &x.vfsfd)
+ m.Save(1, &x.FileDescriptionDefaultImpl)
+ m.Save(2, &x.LockFD)
+}
+
+func (x *fileDescription) afterLoad() {}
+
+func (x *fileDescription) StateLoad(m state.Source) {
+ m.Load(0, &x.vfsfd)
+ m.Load(1, &x.FileDescriptionDefaultImpl)
+ m.Load(2, &x.LockFD)
+}
+
+func init() {
+ state.Register((*directoryFD)(nil))
+ state.Register((*nonDirectoryFD)(nil))
+ state.Register((*FilesystemType)(nil))
+ state.Register((*FilesystemOptions)(nil))
+ state.Register((*filesystem)(nil))
+ state.Register((*dentry)(nil))
+ state.Register((*fileDescription)(nil))
+}