in cmd/hotdog-cc-hook/main.go [49:95]
func reexeced_main() error {
if len(os.Args) != 3 {
return errors.New("wrong arg len")
}
bundle := os.Args[2]
spec, err := hook.Config(specs.State{Bundle: bundle})
if err != nil {
return err
}
rootfs, err := hook.Root(bundle, spec)
if err != nil {
return err
}
hotdogBundleDir := filepath.Join(bundle, "hotdog")
if err := os.Mkdir(hotdogBundleDir, 0755); err != nil {
return err
}
if err := cp(filepath.Join(hotdog.HostDir, hotdog.PatchPath), filepath.Join(hotdogBundleDir, hotdog.PatchPath)); err != nil {
return err
}
if err := cp(filepath.Join(hotdog.HostDir, hotdog.HotpatchBinary), filepath.Join(hotdogBundleDir, hotdog.HotpatchBinary)); err != nil {
return err
}
mountTarget := filepath.Join(rootfs, hotdog.ContainerDir)
if stat, err := os.Stat(mountTarget); err != nil {
if _, ok := err.(*os.PathError); !ok {
// cannot hotpatch
return nil
}
if err := os.Mkdir(mountTarget, 0755); err != nil {
// cannot hotpatch
return nil
}
} else if !stat.IsDir() {
// cannot hotpatch
return nil
}
err = unix.Mount(hotdogBundleDir, mountTarget, "bind", unix.MS_BIND|unix.MS_NODEV|unix.MS_NOATIME|unix.MS_RELATIME, "")
if err != nil {
// cannot hotpatch
return nil
}
// remount readonly
return unix.Mount(hotdogBundleDir, mountTarget, "bind", unix.MS_REMOUNT|unix.MS_BIND|unix.MS_RDONLY, "")
}