[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
05/09: build: container: Setup /dev/console.
From: |
David Thompson |
Subject: |
05/09: build: container: Setup /dev/console. |
Date: |
Sun, 02 Aug 2015 01:51:43 +0000 |
davexunit pushed a commit to branch wip-container
in repository guix.
commit d1b9d9669b338a652b33235e402a3295cdec5716
Author: David Thompson <address@hidden>
Date: Sat Aug 1 13:54:40 2015 -0400
build: container: Setup /dev/console.
* gnu/build/linux-container.scm (mount-file-systems): Bind mount the
controlling terminal as /dev/console.
---
gnu/build/linux-container.scm | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/gnu/build/linux-container.scm b/gnu/build/linux-container.scm
index af59904..e59194b 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."
(define (scope dir)
(string-append root dir))
+ (define (touch file-name)
+ (call-with-output-file file-name (const #t)))
+
(define (bind-mount src dest)
(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)
(when (file-exists? device)
;; Create the mount point file.
- (call-with-output-file (scope device)
- (const #t))
+ (touch (scope device))
(bind-mount device (scope device))))
'("/dev/null"
"/dev/zero"
@@ -101,6 +103,14 @@ to ROOT, then make ROOT the new root directory for the
process."
"/dev/ptmx"
"/dev/fuse"))
+ ;; Setup pseudo-terminal.
+ (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.
(symlink "/proc/self/fd" (scope "/dev/fd"))
(symlink "/proc/self/fd/0" (scope "/dev/stdin"))
- branch wip-container created (now 94e4501), David Thompson, 2015/08/01
- 02/09: gnu: guix: Re-enable container tests., David Thompson, 2015/08/01
- 01/09: build: container: Add #:host-uids argument to call-with-container., David Thompson, 2015/08/01
- 05/09: build: container: Setup /dev/console.,
David Thompson <=
- 03/09: build: file-systems: Allow for bind mounting regular files., David Thompson, 2015/08/01
- 04/09: build: syscalls: Add pseudo-terminal bindings., David Thompson, 2015/08/01
- 07/09: scripts: system: Add 'container' action., David Thompson, 2015/08/01
- 06/09: gnu: system: Add Linux container module., David Thompson, 2015/08/01
- 08/09: scripts: environment: Add --container option., David Thompson, 2015/08/01
- 09/09: scripts: Add 'container' subcommand., David Thompson, 2015/08/01