build: container: Setup /dev/console.
* gnu/build/linux-container.scm (mount-file-systems): Bind mount the controlling terminal as /dev/console.
This commit is contained in:
parent
468e56576c
commit
4949ada9da
|
@ -55,6 +55,9 @@ to ROOT, then make ROOT the new root directory for the process."
|
||||||
(define (scope dir)
|
(define (scope dir)
|
||||||
(string-append root dir))
|
(string-append root dir))
|
||||||
|
|
||||||
|
(define (touch file-name)
|
||||||
|
(call-with-output-file file-name (const #t)))
|
||||||
|
|
||||||
(define (bind-mount src dest)
|
(define (bind-mount src dest)
|
||||||
(mount src dest "none" MS_BIND))
|
(mount src dest "none" MS_BIND))
|
||||||
|
|
||||||
|
@ -89,8 +92,7 @@ to ROOT, then make ROOT the new root directory for the process."
|
||||||
(for-each (lambda (device)
|
(for-each (lambda (device)
|
||||||
(when (file-exists? device)
|
(when (file-exists? device)
|
||||||
;; Create the mount point file.
|
;; Create the mount point file.
|
||||||
(call-with-output-file (scope device)
|
(touch (scope device))
|
||||||
(const #t))
|
|
||||||
(bind-mount device (scope device))))
|
(bind-mount device (scope device))))
|
||||||
'("/dev/null"
|
'("/dev/null"
|
||||||
"/dev/zero"
|
"/dev/zero"
|
||||||
|
@ -101,6 +103,15 @@ to ROOT, then make ROOT the new root directory for the process."
|
||||||
"/dev/ptmx"
|
"/dev/ptmx"
|
||||||
"/dev/fuse"))
|
"/dev/fuse"))
|
||||||
|
|
||||||
|
;; Setup the container's /dev/console by bind mounting the pseudo-terminal
|
||||||
|
;; associated with standard input.
|
||||||
|
(let ((in (current-input-port))
|
||||||
|
(console (scope "/dev/console")))
|
||||||
|
(when (isatty? in)
|
||||||
|
(touch console)
|
||||||
|
(chmod console #o600)
|
||||||
|
(bind-mount (ttyname in) console)))
|
||||||
|
|
||||||
;; Setup standard input/output/error.
|
;; Setup standard input/output/error.
|
||||||
(symlink "/proc/self/fd" (scope "/dev/fd"))
|
(symlink "/proc/self/fd" (scope "/dev/fd"))
|
||||||
(symlink "/proc/self/fd/0" (scope "/dev/stdin"))
|
(symlink "/proc/self/fd/0" (scope "/dev/stdin"))
|
||||||
|
|
Loading…
Reference in New Issue