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
|
|
|
|
2015-02-01 11:56:27 +08:00
|
|
|
"github.com/docker/libcontainer/configs"
|
2014-07-15 08:00:05 +08:00
|
|
|
"github.com/docker/libcontainer/console"
|
2014-04-11 23:06:56 +08:00
|
|
|
)
|
|
|
|
|
2015-02-01 11:56:27 +08:00
|
|
|
func setupPtmx(config *configs.Config) error {
|
2015-02-04 09:44:58 +08:00
|
|
|
ptmx := filepath.Join(config.Rootfs, "dev/ptmx")
|
2014-04-11 23:06:56 +08:00
|
|
|
if err := os.Remove(ptmx); err != nil && !os.IsNotExist(err) {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := os.Symlink("pts/ptmx", ptmx); err != nil {
|
|
|
|
return fmt.Errorf("symlink dev ptmx %s", err)
|
|
|
|
}
|
2015-02-01 11:56:27 +08:00
|
|
|
if config.Console != "" {
|
|
|
|
uid, err := config.HostUID()
|
|
|
|
if err != nil {
|
2014-04-11 23:06:56 +08:00
|
|
|
return err
|
|
|
|
}
|
2015-02-01 11:56:27 +08:00
|
|
|
gid, err := config.HostGID()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2015-02-04 09:44:58 +08:00
|
|
|
return console.Setup(config.Rootfs, config.Console, config.MountLabel, uid, gid)
|
2014-04-11 23:06:56 +08:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|