2014-04-11 23:06:56 +08:00
|
|
|
// +build linux
|
|
|
|
|
|
|
|
package mount
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
2014-07-15 08:00:05 +08:00
|
|
|
|
|
|
|
"github.com/docker/libcontainer/console"
|
2014-04-11 23:06:56 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func SetupPtmx(rootfs, consolePath, mountLabel string) error {
|
|
|
|
ptmx := filepath.Join(rootfs, "dev/ptmx")
|
|
|
|
if err := os.Remove(ptmx); err != nil && !os.IsNotExist(err) {
|
|
|
|
return err
|
|
|
|
}
|
2014-07-15 08:00:05 +08:00
|
|
|
|
2014-04-11 23:06:56 +08:00
|
|
|
if err := os.Symlink("pts/ptmx", ptmx); err != nil {
|
|
|
|
return fmt.Errorf("symlink dev ptmx %s", err)
|
|
|
|
}
|
2014-07-15 08:00:05 +08:00
|
|
|
|
2014-04-11 23:06:56 +08:00
|
|
|
if consolePath != "" {
|
|
|
|
if err := console.Setup(rootfs, consolePath, mountLabel); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2014-07-15 08:00:05 +08:00
|
|
|
|
2014-04-11 23:06:56 +08:00
|
|
|
return nil
|
|
|
|
}
|