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