[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
03/09: build: file-systems: Allow for bind mounting regular files.
From: |
David Thompson |
Subject: |
03/09: build: file-systems: Allow for bind mounting regular files. |
Date: |
Sun, 02 Aug 2015 01:51:42 +0000 |
davexunit pushed a commit to branch wip-container
in repository guix.
commit 575e6e35d54bf34404eacb3069e48d3beb959aff
Author: David Thompson <address@hidden>
Date: Sat Aug 1 13:43:33 2015 -0400
build: file-systems: Allow for bind mounting regular files.
* gnu/build/file-systems.scm (regular-file?): New procedure.
(mount-file-system): Create a regular file instead of a directory when
bind
mounting a regular file.
---
gnu/build/file-systems.scm | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm
index c58d23c..f0d6f70 100644
--- a/gnu/build/file-systems.scm
+++ b/gnu/build/file-systems.scm
@@ -305,6 +305,10 @@ the following:
fsck code device)
(start-repl)))))
+(define (regular-file? file-name)
+ "Return #t if FILE-NAME is a regular file."
+ (eq? (stat:type (stat file-name)) 'regular))
+
(define (mount-flags->bit-mask flags)
"Return the number suitable for the 'flags' argument of 'mount' that
corresponds to the symbols listed in FLAGS."
@@ -339,7 +343,16 @@ run a file system check."
(flags (mount-flags->bit-mask flags)))
(when check?
(check-file-system source type))
- (mkdir-p mount-point)
+
+ ;; Create the mount point. Most of the time this is a directory, but
+ ;; in the case of a bind mount, a regular file may be needed.
+ (if (and (= MS_BIND (logand flags MS_BIND))
+ (regular-file? source))
+ (begin
+ (mkdir-p (dirname mount-point))
+ (call-with-output-file mount-point (const #t)))
+ (mkdir-p mount-point))
+
(mount source mount-point type flags options)
;; For read-only bind mounts, an extra remount is needed, as per
- 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, 2015/08/01
- 03/09: build: file-systems: Allow for bind mounting regular files.,
David Thompson <=
- 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