linux-boot: Make /etc/mtab a symlink to /proc/self/mounts.

Fixes <http://bugs.gnu.org/19491>.

* gnu/build/linux-boot.scm (mount-root-file-system): Make /root/etc/mtab
  a symlink to /proc/self/mounts.
* gnu/build/file-systems.scm (mount-file-system): Don't update /etc/mtab.
* guix/build/syscalls.scm (mount, umount): Have #:update-mtab? default to
  #f.
This commit is contained in:
宋文武 2015-01-05 22:07:03 +08:00
parent 4379c35b73
commit 9331ba5dd9
3 changed files with 7 additions and 11 deletions

View File

@ -287,13 +287,6 @@ run a file system check."
(mount source mount-point type (mount-flags->bit-mask flags) (mount source mount-point type (mount-flags->bit-mask flags)
(if options (if options
(string->pointer 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 (or options "rw"))
(close-port port))))))
;;; file-systems.scm ends here ;;; file-systems.scm ends here

View File

@ -275,7 +275,10 @@ UNIONFS."
(check-file-system root type) (check-file-system root type)
(mount root "/root" type))) (mount root "/root" type)))
(copy-file "/proc/mounts" "/root/etc/mtab")) ;; Make sure /root/etc/mtab is a symlink to /proc/self/mounts.
(when (file-exists? "/root/etc/mtab")
(delete-file "/root/etc/mtab"))
(symlink "/proc/self/mounts" "/root/etc/mtab"))
(define (switch-root root) (define (switch-root root)
"Switch to ROOT as the root file system, in a way similar to what "Switch to ROOT as the root file system, in a way similar to what

View File

@ -130,7 +130,7 @@
(let* ((ptr (dynamic-func "mount" (dynamic-link))) (let* ((ptr (dynamic-func "mount" (dynamic-link)))
(proc (pointer->procedure int ptr `(* * * ,unsigned-long *)))) (proc (pointer->procedure int ptr `(* * * ,unsigned-long *))))
(lambda* (source target type #:optional (flags 0) options (lambda* (source target type #:optional (flags 0) options
#:key (update-mtab? #t)) #:key (update-mtab? #f))
"Mount device SOURCE on TARGET as a file system TYPE. Optionally, FLAGS "Mount device SOURCE on TARGET as a file system TYPE. Optionally, FLAGS
may be a bitwise-or of the MS_* <sys/mount.h> constants, and OPTIONS may be a may be a bitwise-or of the MS_* <sys/mount.h> constants, and OPTIONS may be a
string. When FLAGS contains MS_REMOUNT, SOURCE and TYPE are ignored. When string. When FLAGS contains MS_REMOUNT, SOURCE and TYPE are ignored. When
@ -159,7 +159,7 @@ error."
(let* ((ptr (dynamic-func "umount2" (dynamic-link))) (let* ((ptr (dynamic-func "umount2" (dynamic-link)))
(proc (pointer->procedure int ptr `(* ,int)))) (proc (pointer->procedure int ptr `(* ,int))))
(lambda* (target #:optional (flags 0) (lambda* (target #:optional (flags 0)
#:key (update-mtab? #t)) #:key (update-mtab? #f))
"Unmount TARGET. Optionally FLAGS may be one of the MNT_* or UMOUNT_* "Unmount TARGET. Optionally FLAGS may be one of the MNT_* or UMOUNT_*
constants from <sys/mount.h>." constants from <sys/mount.h>."
(let ((ret (proc (string->pointer target) flags)) (let ((ret (proc (string->pointer target) flags))