From: David Thompson <dthompson2@worcester.edu>
To: guix-devel@gnu.org
Subject: [PATCH] build: file-systems: Allow for bind mounting regular files.
Date: Sat, 01 Aug 2015 15:17:59 -0400 [thread overview]
Message-ID: <87a8uarf6g.fsf@izanagi.i-did-not-set--mail-host-address--so-tickle-me> (raw)
[-- Attachment #1: Type: text/plain, Size: 210 bytes --]
As I was working on my container implementation I noticed that
'mount-file-system' doesn't support bind mounting regular files because
it assumes that all mount points are directories. This patch fixes
that.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-build-file-systems-Allow-for-bind-mounting-regular-f.patch --]
[-- Type: text/x-patch, Size: 1799 bytes --]
From f94fec6cde3826f20c0d69a45c2aa1928c1d0a78 Mon Sep 17 00:00:00 2001
From: David Thompson <dthompson2@worcester.edu>
Date: Sat, 1 Aug 2015 13:43:33 -0400
Subject: [PATCH] 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 file changed, 14 insertions(+), 1 deletion(-)
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
--
2.4.3
[-- Attachment #3: Type: text/plain, Size: 38 bytes --]
--
David Thompson
GPG Key: 0FF1D807
next reply other threads:[~2015-08-01 19:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-01 19:17 David Thompson [this message]
2015-08-02 12:10 ` [PATCH] build: file-systems: Allow for bind mounting regular files Alex Kost
2015-08-02 12:43 ` Thompson, David
2015-08-02 12:51 ` Thompson, David
2015-08-02 13:31 ` Andreas Enge
2015-08-03 12:47 ` Alex Kost
2015-08-06 12:22 ` Thompson, David
2015-08-07 7:06 ` Alex Kost
2015-08-18 15:52 ` Ludovic Courtès
2015-08-18 16:43 ` Thompson, David
2015-08-08 18:28 ` Thompson, David
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a8uarf6g.fsf@izanagi.i-did-not-set--mail-host-address--so-tickle-me \
--to=dthompson2@worcester.edu \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.