From c81a8f2b6d785e989eb091786dd473e383e2f00a Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Wed, 26 Jun 2019 12:09:30 +0200 Subject: attach: move cgo bits to a different file move the cgo bits to a separate file to allow building without cgo. Signed-off-by: Giuseppe Scrivano --- libpod/container_attach_linux.go | 6 +----- libpod/container_attach_linux_cgo.go | 11 +++++++++++ libpod/container_attach_linux_nocgo.go | 7 +++++++ 3 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 libpod/container_attach_linux_cgo.go create mode 100644 libpod/container_attach_linux_nocgo.go (limited to 'libpod') diff --git a/libpod/container_attach_linux.go b/libpod/container_attach_linux.go index f5aac5794..fc53268c3 100644 --- a/libpod/container_attach_linux.go +++ b/libpod/container_attach_linux.go @@ -19,10 +19,6 @@ import ( "k8s.io/client-go/tools/remotecommand" ) -//#include -// extern int unix_path_length(){struct sockaddr_un addr; return sizeof(addr.sun_path) - 1;} -import "C" - /* Sync with stdpipe_t in conmon.c */ const ( AttachPipeStdin = 1 @@ -80,7 +76,7 @@ func (c *Container) attachContainerSocket(resize <-chan remotecommand.TerminalSi socketPath := c.AttachSocketPath() - maxUnixLength := int(C.unix_path_length()) + maxUnixLength := unixPathLength() if maxUnixLength < len(socketPath) { socketPath = socketPath[0:maxUnixLength] } diff --git a/libpod/container_attach_linux_cgo.go b/libpod/container_attach_linux_cgo.go new file mode 100644 index 000000000..d81243360 --- /dev/null +++ b/libpod/container_attach_linux_cgo.go @@ -0,0 +1,11 @@ +//+build linux,cgo + +package libpod + +//#include +// extern int unix_path_length(){struct sockaddr_un addr; return sizeof(addr.sun_path) - 1;} +import "C" + +func unixPathLength() int { + return int(C.unix_path_length()) +} diff --git a/libpod/container_attach_linux_nocgo.go b/libpod/container_attach_linux_nocgo.go new file mode 100644 index 000000000..a514a555d --- /dev/null +++ b/libpod/container_attach_linux_nocgo.go @@ -0,0 +1,7 @@ +//+build linux,!cgo + +package libpod + +func unixPathLength() int { + return 107 +} -- cgit v1.2.3-54-g00ecf