summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/uniqueid/context.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/sentry/uniqueid/context.go')
-rw-r--r--pkg/sentry/uniqueid/context.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/pkg/sentry/uniqueid/context.go b/pkg/sentry/uniqueid/context.go
index eeb8c4286..541e0611d 100644
--- a/pkg/sentry/uniqueid/context.go
+++ b/pkg/sentry/uniqueid/context.go
@@ -18,6 +18,7 @@ package uniqueid
import (
"gvisor.googlesource.com/gvisor/pkg/sentry/context"
+ "gvisor.googlesource.com/gvisor/pkg/tcpip/transport/unix"
)
// contextID is the kernel package's type for context.Context.Value keys.
@@ -28,6 +29,10 @@ const (
// unique identifier.
CtxGlobalUniqueID contextID = iota
+ // CtxGlobalUniqueIDProvider is a Context.Value key for a
+ // system-wide unique identifier generator.
+ CtxGlobalUniqueIDProvider
+
// CtxInotifyCookie is a Context.Value key for a unique inotify
// event cookie.
CtxInotifyCookie
@@ -38,6 +43,11 @@ func GlobalFromContext(ctx context.Context) uint64 {
return ctx.Value(CtxGlobalUniqueID).(uint64)
}
+// GlobalProviderFromContext returns a system-wide unique identifier from ctx.
+func GlobalProviderFromContext(ctx context.Context) unix.UniqueIDProvider {
+ return ctx.Value(CtxGlobalUniqueIDProvider).(unix.UniqueIDProvider)
+}
+
// InotifyCookie generates a unique inotify event cookie from ctx.
func InotifyCookie(ctx context.Context) uint32 {
return ctx.Value(CtxInotifyCookie).(uint32)