Add a constant for the container console path.

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
Mrunal Patel 2015-02-13 18:15:58 -05:00
parent 031524c73d
commit 77085907a4
2 changed files with 8 additions and 3 deletions

View File

@ -12,6 +12,10 @@ import (
"github.com/docker/libcontainer/label"
)
const (
containerConsolePath string = "/dev/console"
)
// NewConsole returns an initalized console that can be used within a container by copying bytes
// from the master side to the slave that is attached as the tty for the container's init process.
func NewConsole() (Console, error) {
@ -83,7 +87,7 @@ func (c *linuxConsole) mount(rootfs, mountLabel string, uid, gid int) error {
if err := label.SetFileLabel(c.slavePath, mountLabel); err != nil {
return err
}
dest := filepath.Join(rootfs, "dev/console")
dest := filepath.Join(rootfs, containerConsolePath)
f, err := os.Create(dest)
if err != nil && !os.IsExist(err) {
return err

View File

@ -21,8 +21,9 @@ func (l *linuxUsernsInit) Init() error {
}
consolePath := l.config.Config.Console
if consolePath != "" {
// TODO: why is this hard coded?
console := newConsoleFromPath("/dev/console")
// We use the containerConsolePath here, because the console has already been
// setup by the side car process for the user namespace scenario.
console := newConsoleFromPath(containerConsolePath)
if err := console.dupStdio(); err != nil {
return err
}