From e4a4af4bfed55871b80d67d8836f93b119b04a59 Mon Sep 17 00:00:00 2001 From: Saied Kazemi Date: Tue, 23 Sep 2014 14:04:55 -0700 Subject: [PATCH] Add RootFs field to configuration options in libcontainer's Config Since currently the container.json file does not include the pathname to a container's root filesystem, we need to parse /proc/mounts which is slow and error-prone. This patch addresses this issue by adding a new RootFs field. Signed-off-by: Saied Kazemi --- config.go | 3 +++ namespaces/exec.go | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/config.go b/config.go index 8fe95c24f..1fb377dce 100644 --- a/config.go +++ b/config.go @@ -15,6 +15,9 @@ type Config struct { // Mount specific options. MountConfig *MountConfig `json:"mount_config,omitempty"` + // Pathname to container's root filesystem + RootFs string `json:"root_fs,omitempty"` + // Hostname optionally sets the container's hostname if provided Hostname string `json:"hostname,omitempty"` diff --git a/namespaces/exec.go b/namespaces/exec.go index 382abfbcc..e07e1a95f 100644 --- a/namespaces/exec.go +++ b/namespaces/exec.go @@ -21,7 +21,7 @@ import ( // Move this to libcontainer package. // Exec performs setup outside of a namespace so that a container can be // executed. Exec is a high level function for working with container namespaces. -func Exec(container *libcontainer.Config, stdin io.Reader, stdout, stderr io.Writer, console string, rootfs, dataPath string, args []string, createCommand CreateCommand, startCallback func()) (int, error) { +func Exec(container *libcontainer.Config, stdin io.Reader, stdout, stderr io.Writer, console, dataPath string, args []string, createCommand CreateCommand, startCallback func()) (int, error) { var ( err error ) @@ -34,7 +34,7 @@ func Exec(container *libcontainer.Config, stdin io.Reader, stdout, stderr io.Wri } defer syncPipe.Close() - command := createCommand(container, console, rootfs, dataPath, os.Args[0], syncPipe.Child(), args) + command := createCommand(container, console, container.RootFs, dataPath, os.Args[0], syncPipe.Child(), args) // Note: these are only used in non-tty mode // if there is a tty for the container it will be opened within the namespace and the // fds will be duped to stdin, stdiout, and stderr