summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-03-26 20:54:21 +0000
committergVisor bot <gvisor-bot@google.com>2020-03-26 20:54:21 +0000
commitabd55c233ce4ceca722a6b5dcf52727db48987b0 (patch)
tree49d021bf483f386e879a4359216e44b9b90de527
parent00bff12e1ed7abaa85dbf102057b8ae969dd6466 (diff)
parente466ab04a20731ebeb8a9725d808def975d4c88d (diff)
Merge release-20200219.0-246-ge466ab0 (automated)
-rwxr-xr-xpkg/sentry/vfs/mount.go7
-rwxr-xr-xpkg/sentry/vfs/vfs_state_autogen.go2
2 files changed, 9 insertions, 0 deletions
diff --git a/pkg/sentry/vfs/mount.go b/pkg/sentry/vfs/mount.go
index 05f6233f9..4b68cabda 100755
--- a/pkg/sentry/vfs/mount.go
+++ b/pkg/sentry/vfs/mount.go
@@ -24,6 +24,9 @@ import (
"gvisor.dev/gvisor/pkg/syserror"
)
+// lastMountID is used to allocate mount ids. Must be accessed atomically.
+var lastMountID uint64
+
// A Mount is a replacement of a Dentry (Mount.key.point) from one Filesystem
// (Mount.key.parent.fs) with a Dentry (Mount.root) from another Filesystem
// (Mount.fs), which applies to path resolution in the context of a particular
@@ -48,6 +51,9 @@ type Mount struct {
fs *Filesystem
root *Dentry
+ // ID is the immutable mount ID.
+ ID uint64
+
// key is protected by VirtualFilesystem.mountMu and
// VirtualFilesystem.mounts.seq, and may be nil. References are held on
// key.parent and key.point if they are not nil.
@@ -87,6 +93,7 @@ type Mount struct {
func newMount(vfs *VirtualFilesystem, fs *Filesystem, root *Dentry, mntns *MountNamespace, opts *MountOptions) *Mount {
mnt := &Mount{
+ ID: atomic.AddUint64(&lastMountID, 1),
vfs: vfs,
fs: fs,
root: root,
diff --git a/pkg/sentry/vfs/vfs_state_autogen.go b/pkg/sentry/vfs/vfs_state_autogen.go
index 036defa97..d0221f0ff 100755
--- a/pkg/sentry/vfs/vfs_state_autogen.go
+++ b/pkg/sentry/vfs/vfs_state_autogen.go
@@ -114,6 +114,7 @@ func (x *Mount) save(m state.Map) {
m.Save("vfs", &x.vfs)
m.Save("fs", &x.fs)
m.Save("root", &x.root)
+ m.Save("ID", &x.ID)
m.Save("key", &x.key)
m.Save("ns", &x.ns)
m.Save("refs", &x.refs)
@@ -128,6 +129,7 @@ func (x *Mount) load(m state.Map) {
m.Load("vfs", &x.vfs)
m.Load("fs", &x.fs)
m.Load("root", &x.root)
+ m.Load("ID", &x.ID)
m.Load("key", &x.key)
m.Load("ns", &x.ns)
m.Load("refs", &x.refs)