summaryrefslogtreecommitdiff
path: root/gnu/build/linux-container.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2015-08-01 13:54:40 -0400
committerDavid Thompson <dthompson2@worcester.edu>2015-09-07 13:09:58 -0400
commit4949ada9da470b266063ff490438c85541af24cc (patch)
treefbc54ac309cb44e20b20a7528a42583cdc43758a /gnu/build/linux-container.scm
parent468e56576c23c44b96f0af08e15bd302862f9c81 (diff)
build: container: Setup /dev/console.
* gnu/build/linux-container.scm (mount-file-systems): Bind mount the controlling terminal as /dev/console.
Diffstat (limited to 'gnu/build/linux-container.scm')
-rw-r--r--gnu/build/linux-container.scm15
1 files changed, 13 insertions, 2 deletions
diff --git a/gnu/build/linux-container.scm b/gnu/build/linux-container.scm
index af599040a1a..c004303f035 100644
--- a/gnu/build/linux-container.scm
+++ b/gnu/build/linux-container.scm
@@ -55,6 +55,9 @@ to ROOT, then make ROOT the new root directory for the process."
55 (define (scope dir) 55 (define (scope dir)
56 (string-append root dir)) 56 (string-append root dir))
57 57
58 (define (touch file-name)
59 (call-with-output-file file-name (const #t)))
60
58 (define (bind-mount src dest) 61 (define (bind-mount src dest)
59 (mount src dest "none" MS_BIND)) 62 (mount src dest "none" MS_BIND))
60 63
@@ -89,8 +92,7 @@ to ROOT, then make ROOT the new root directory for the process."
89 (for-each (lambda (device) 92 (for-each (lambda (device)
90 (when (file-exists? device) 93 (when (file-exists? device)
91 ;; Create the mount point file. 94 ;; Create the mount point file.
92 (call-with-output-file (scope device) 95 (touch (scope device))
93 (const #t))
94 (bind-mount device (scope device)))) 96 (bind-mount device (scope device))))
95 '("/dev/null" 97 '("/dev/null"
96 "/dev/zero" 98 "/dev/zero"
@@ -101,6 +103,15 @@ to ROOT, then make ROOT the new root directory for the process."
101 "/dev/ptmx" 103 "/dev/ptmx"
102 "/dev/fuse")) 104 "/dev/fuse"))
103 105
106 ;; Setup the container's /dev/console by bind mounting the pseudo-terminal
107 ;; associated with standard input.
108 (let ((in (current-input-port))
109 (console (scope "/dev/console")))
110 (when (isatty? in)
111 (touch console)
112 (chmod console #o600)
113 (bind-mount (ttyname in) console)))
114
104 ;; Setup standard input/output/error. 115 ;; Setup standard input/output/error.
105 (symlink "/proc/self/fd" (scope "/dev/fd")) 116 (symlink "/proc/self/fd" (scope "/dev/fd"))
106 (symlink "/proc/self/fd/0" (scope "/dev/stdin")) 117 (symlink "/proc/self/fd/0" (scope "/dev/stdin"))