2014-08-08 16:18:18 -04:00
|
|
|
// +build linux
|
|
|
|
|
|
|
|
package native
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"runtime"
|
|
|
|
|
2014-10-30 08:48:30 -04:00
|
|
|
"github.com/docker/docker/pkg/reexec"
|
2015-07-16 19:00:55 -04:00
|
|
|
"github.com/opencontainers/runc/libcontainer"
|
2014-08-08 16:18:18 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
reexec.Register(DriverName, initializer)
|
|
|
|
}
|
|
|
|
|
2015-03-05 12:55:14 -05:00
|
|
|
func fatal(err error) {
|
|
|
|
if lerr, ok := err.(libcontainer.Error); ok {
|
|
|
|
lerr.Detail(os.Stderr)
|
|
|
|
os.Exit(1)
|
2014-08-08 16:18:18 -04:00
|
|
|
}
|
|
|
|
|
2015-03-05 12:55:14 -05:00
|
|
|
fmt.Fprintln(os.Stderr, err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
2014-08-08 16:18:18 -04:00
|
|
|
|
2015-03-05 12:55:14 -05:00
|
|
|
func initializer() {
|
|
|
|
runtime.GOMAXPROCS(1)
|
|
|
|
runtime.LockOSThread()
|
|
|
|
factory, err := libcontainer.New("")
|
2014-08-08 16:18:18 -04:00
|
|
|
if err != nil {
|
2015-03-05 12:55:14 -05:00
|
|
|
fatal(err)
|
2014-08-08 16:18:18 -04:00
|
|
|
}
|
2015-05-04 13:02:44 -04:00
|
|
|
if err := factory.StartInitialization(); err != nil {
|
2015-03-05 12:55:14 -05:00
|
|
|
fatal(err)
|
2014-08-08 16:18:18 -04:00
|
|
|
}
|
|
|
|
|
2015-03-05 12:55:14 -05:00
|
|
|
panic("unreachable")
|
2014-08-08 16:18:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func writeError(err error) {
|
2014-08-13 03:37:30 -04:00
|
|
|
fmt.Fprint(os.Stderr, err)
|
2014-07-29 03:14:10 -04:00
|
|
|
os.Exit(1)
|
2014-08-08 16:18:18 -04:00
|
|
|
}
|