mirror of
https://github.com/linuxkit/linuxkit.git
synced 2026-04-26 19:20:01 +00:00
Switch runc and containerd startup to be entirely Go
At present they use a small shared function called "prepare" that does the read-write remounts, that I will switch to doing overlay mounts soon. Signed-off-by: Justin Cormack <justin.cormack@docker.com>
This commit is contained in:
@@ -66,9 +66,8 @@ func main() {
|
||||
|
||||
args := flag.Args()
|
||||
if len(args) < 1 {
|
||||
fmt.Printf("Please specify a command.\n\n")
|
||||
flag.Usage()
|
||||
os.Exit(1)
|
||||
systemInitCmd(args)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
switch args[0] {
|
||||
|
||||
21
pkg/containerd/cmd/service/prepare.go
Normal file
21
pkg/containerd/cmd/service/prepare.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
// Please note this file is shared between pkg/runc and pkg/containerd
|
||||
// Update it in both places if you make changes
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func prepare(path string) error {
|
||||
rootfs := filepath.Join(path, "rootfs")
|
||||
if err := syscall.Mount(rootfs, rootfs, "", syscall.MS_BIND, ""); err != nil {
|
||||
return err
|
||||
}
|
||||
// remount rw
|
||||
if err := syscall.Mount("", rootfs, "", syscall.MS_REMOUNT, ""); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -58,6 +58,10 @@ func startCmd(args []string) {
|
||||
func start(service, sock, path, dumpSpec string) (string, uint32, string, error) {
|
||||
rootfs := filepath.Join(path, service, "rootfs")
|
||||
|
||||
if err := prepare(filepath.Join(path, service)); err != nil {
|
||||
return "", 0, "preparing rootfs", err
|
||||
}
|
||||
|
||||
client, err := containerd.New(sock)
|
||||
if err != nil {
|
||||
return "", 0, "creating containerd client", err
|
||||
|
||||
Reference in New Issue
Block a user