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 <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2019-06-26 12:09:30 +02:00
parent 1e0d632785
commit c81a8f2b6d
No known key found for this signature in database
GPG Key ID: E4730F97F60286ED
3 changed files with 19 additions and 5 deletions

View File

@ -19,10 +19,6 @@ import (
"k8s.io/client-go/tools/remotecommand"
)
//#include <sys/un.h>
// 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]
}

View File

@ -0,0 +1,11 @@
//+build linux,cgo
package libpod
//#include <sys/un.h>
// 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())
}

View File

@ -0,0 +1,7 @@
//+build linux,!cgo
package libpod
func unixPathLength() int {
return 107
}