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:
parent
1e0d632785
commit
c81a8f2b6d
|
|
@ -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]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
//+build linux,!cgo
|
||||
|
||||
package libpod
|
||||
|
||||
func unixPathLength() int {
|
||||
return 107
|
||||
}
|
||||
Loading…
Reference in New Issue