summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/uniqueid
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/sentry/uniqueid')
-rw-r--r--pkg/sentry/uniqueid/BUILD5
-rw-r--r--pkg/sentry/uniqueid/context.go10
2 files changed, 14 insertions, 1 deletions
diff --git a/pkg/sentry/uniqueid/BUILD b/pkg/sentry/uniqueid/BUILD
index 8eba3609e..ff50b9925 100644
--- a/pkg/sentry/uniqueid/BUILD
+++ b/pkg/sentry/uniqueid/BUILD
@@ -7,5 +7,8 @@ go_library(
srcs = ["context.go"],
importpath = "gvisor.googlesource.com/gvisor/pkg/sentry/uniqueid",
visibility = ["//pkg/sentry:internal"],
- deps = ["//pkg/sentry/context"],
+ deps = [
+ "//pkg/sentry/context",
+ "//pkg/tcpip/transport/unix",
+ ],
)
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)