summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/uniqueid
diff options
context:
space:
mode:
authorIan Gudger <igudger@google.com>2018-10-15 17:47:24 -0700
committerShentubot <shentubot@google.com>2018-10-15 17:48:11 -0700
commit167f2401c4abb1ebda1f4536a04d9854e9008e0b (patch)
treedc9c7d33f0635039bf3ba45e912fb693f3a99812 /pkg/sentry/uniqueid
parentecd94ea7a693d49a0edce8607241a8e2ac22bfe0 (diff)
Merge host.endpoint into host.ConnectedEndpoint
host.endpoint contained duplicated logic from the sockerpair implementation and host.ConnectedEndpoint. Remove host.endpoint in favor of a host.ConnectedEndpoint wrapped in a socketpair end. PiperOrigin-RevId: 217240096 Change-Id: I4a3d51e3fe82bdf30e2d0152458b8499ab4c987c
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)