diff options
author | Nicolas Lacasse <nlacasse@google.com> | 2020-03-26 13:45:02 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-03-26 13:49:59 -0700 |
commit | e466ab04a20731ebeb8a9725d808def975d4c88d (patch) | |
tree | 4402fe0a4b110f5555920eff5dc442f511b17755 /pkg/sentry | |
parent | 01ac53099fedf7dd5da01a50e60f3dfa2eb17892 (diff) |
Add unique ID to Mount type.
Analagous to Linux's mount.mnt_id. This ID is displayed in
/proc/[pid]/mountinfo.
PiperOrigin-RevId: 303185564
Diffstat (limited to 'pkg/sentry')
-rw-r--r-- | pkg/sentry/vfs/mount.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/pkg/sentry/vfs/mount.go b/pkg/sentry/vfs/mount.go index 05f6233f9..4b68cabda 100644 --- 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, |