linux-command-line
make-essential-device-nodes
configure-qemu-networking
+ check-file-system
mount-file-system
bind-mount
load-linux-module*
(lambda args
(format (current-error-port) "exception while mounting '~a': ~s~%"
root args)
- (start-repl))))
+ (start-repl)))
+
+ (copy-file "/proc/mounts" "/root/etc/mtab"))
(define (check-file-system device type)
"Run a file system check of TYPE on DEVICE."
(mount source mount-point type (flags->bit-mask flags)
(if options
(string->pointer options)
- %null-pointer))))))
+ %null-pointer))
+
+ ;; Update /etc/mtab.
+ (mkdir-p (string-append root "/etc"))
+ (let ((port (open-file (string-append root "/etc/mtab") "a")))
+ (format port "~a ~a ~a ~a 0 0~%"
+ source mount-point type options)
+ (close-port port))))))
(define (switch-root root)
"Switch to ROOT as the root file system, in a way similar to what
(when (file-exists? "/dev/console")
;; Close the standard file descriptors since they refer to the old
- ;; /dev/console.
- (for-each close-fdes '(0 1 2))
-
- ;; Reopen them.
- (let ((in (open-file "/dev/console" "rbl"))
- (out (open-file "/dev/console" "wbl")))
- (dup2 (fileno in) 0)
- (dup2 (fileno out) 1)
- (dup2 (fileno out) 2)
-
- ;; Safely close IN and OUT.
- (for-each (lambda (port)
- (if (memv (fileno port) '(0 1 2))
- (set-port-revealed! port 1)
- (close-port port)))
- (list in out)))))
+ ;; /dev/console, and reopen them.
+ (let ((console (open-file "/dev/console" "r+b0")))
+ (for-each close-fdes '(0 1 2))
+
+ (dup2 (fileno console) 0)
+ (dup2 (fileno console) 1)
+ (dup2 (fileno console) 2)
+
+ (close-port console))))
(define* (boot-system #:key
(linux-modules '())