MCPcopy
hub / github.com/opencontainers/runc / mountConsole

Function mountConsole

libcontainer/console_linux.go:140–155  ·  view source on GitHub ↗

mountConsole bind-mounts the provided pty on top of /dev/console so programs that operate on /dev/console operate on the correct container pty.

(peerPty *os.File)

Source from the content-addressed store, hash-verified

138// mountConsole bind-mounts the provided pty on top of /dev/console so programs
139// that operate on /dev/console operate on the correct container pty.
140func mountConsole(peerPty *os.File) error {
141 console, err := os.OpenFile("/dev/console", unix.O_NOFOLLOW|unix.O_CREAT|unix.O_CLOEXEC, 0o666)
142 if err != nil {
143 return fmt.Errorf("create /dev/console mount target: %w", err)
144 }
145 defer console.Close()
146
147 dstFd, closer := utils.ProcThreadSelfFd(console.Fd())
148 defer closer()
149
150 mntSrc := &mountSource{
151 Type: mountSourcePlain,
152 file: peerPty,
153 }
154 return mountViaFds(peerPty.Name(), mntSrc, "/dev/console", dstFd, "bind", unix.MS_BIND, "")
155}
156
157// dupStdio replaces stdio with the given peerPty.
158func dupStdio(peerPty *os.File) error {

Callers 1

setupConsoleFunction · 0.85

Calls 3

ProcThreadSelfFdFunction · 0.92
mountViaFdsFunction · 0.85
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…