Refactor driver to use Exec function from nsini

Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
Michael Crosby 2014-02-22 01:21:26 -08:00
parent 1271ddcd61
commit a42c6fafbe
2 changed files with 15 additions and 4 deletions

View file

@ -4,6 +4,7 @@ import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
)
type StateWriter interface {
@ -12,13 +13,14 @@ type StateWriter interface {
}
type DefaultStateWriter struct {
Root string
}
// writePidFile writes the namespaced processes pid to .nspid in the rootfs for the container
func (*DefaultStateWriter) WritePid(pid int) error {
return ioutil.WriteFile(".nspid", []byte(fmt.Sprint(pid)), 0655)
func (d *DefaultStateWriter) WritePid(pid int) error {
return ioutil.WriteFile(filepath.Join(d.Root, ".nspid"), []byte(fmt.Sprint(pid)), 0655)
}
func (*DefaultStateWriter) DeletePid() error {
return os.Remove(".nspid")
func (d *DefaultStateWriter) DeletePid() error {
return os.Remove(filepath.Join(d.Root, ".nspid"))
}