* [PATCH] build: file-systems: Allow for bind mounting regular files.
@ 2015-08-01 19:17 David Thompson
2015-08-02 12:10 ` Alex Kost
2015-08-08 18:28 ` Thompson, David
0 siblings, 2 replies; 11+ messages in thread
From: David Thompson @ 2015-08-01 19:17 UTC (permalink / raw)
To: guix-devel
[-- 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
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] build: file-systems: Allow for bind mounting regular files.
2015-08-01 19:17 [PATCH] build: file-systems: Allow for bind mounting regular files David Thompson
@ 2015-08-02 12:10 ` Alex Kost
2015-08-02 12:43 ` Thompson, David
2015-08-08 18:28 ` Thompson, David
1 sibling, 1 reply; 11+ messages in thread
From: Alex Kost @ 2015-08-02 12:10 UTC (permalink / raw)
To: David Thompson; +Cc: guix-devel
David Thompson (2015-08-01 22:17 +0300) wrote:
> 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))
There are similar procedures in (guix build utils): 'directory-exists?',
'executable-file?' and 'symbolic-link?'. So I think it is better to put
'regular-file?' there. WDYT?
--
Alex
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] build: file-systems: Allow for bind mounting regular files.
2015-08-02 12:10 ` Alex Kost
@ 2015-08-02 12:43 ` Thompson, David
2015-08-02 12:51 ` Thompson, David
2015-08-18 15:52 ` Ludovic Courtès
0 siblings, 2 replies; 11+ messages in thread
From: Thompson, David @ 2015-08-02 12:43 UTC (permalink / raw)
To: Alex Kost; +Cc: guix-devel
[-- Attachment #1: Type: text/plain, Size: 767 bytes --]
On Sun, Aug 2, 2015 at 8:10 AM, Alex Kost <alezost@gmail.com> wrote:
> David Thompson (2015-08-01 22:17 +0300) wrote:
>
>> 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))
>
> There are similar procedures in (guix build utils): 'directory-exists?',
> 'executable-file?' and 'symbolic-link?'. So I think it is better to put
> 'regular-file?' there. WDYT?
Sure, that makes sense. Done.
- Dave
[-- Attachment #2: 0001-build-file-systems-Allow-for-bind-mounting-regular-f.patch --]
[-- Type: text/x-patch, Size: 2283 bytes --]
From 1b2413bd06b1e769edfbe4d170de41398015a67d 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.
* guix/build/utils.scm (regular-file?): New procedure.
* gnu/build/file-systems.scm (mount-file-system): Create a regular file
instead of a directory when bind mounting a regular file.
---
gnu/build/file-systems.scm | 11 ++++++++++-
guix/build/utils.scm | 5 +++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm
index c58d23c..f0b4b79 100644
--- a/gnu/build/file-systems.scm
+++ b/gnu/build/file-systems.scm
@@ -339,7 +339,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
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index 676a012..b9543ed 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -38,6 +38,7 @@
directory-exists?
executable-file?
symbolic-link?
+ regular-file?
call-with-ascii-input-file
elf-file?
ar-file?
@@ -110,6 +111,10 @@
"Return #t if FILE is a symbolic link (aka. \"symlink\".)"
(eq? (stat:type (lstat file)) 'symlink))
+(define (regular-file? file-name)
+ "Return #t if FILE-NAME is a regular file."
+ (eq? (stat:type (stat file-name)) 'regular))
+
(define (call-with-ascii-input-file file proc)
"Open FILE as an ASCII or binary file, and pass the resulting port to
PROC. FILE is closed when PROC's dynamic extent is left. Return the
--
2.4.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] build: file-systems: Allow for bind mounting regular files.
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-18 15:52 ` Ludovic Courtès
1 sibling, 2 replies; 11+ messages in thread
From: Thompson, David @ 2015-08-02 12:51 UTC (permalink / raw)
To: Alex Kost; +Cc: guix-devel
On Sun, Aug 2, 2015 at 8:43 AM, Thompson, David
<dthompson2@worcester.edu> wrote:
> On Sun, Aug 2, 2015 at 8:10 AM, Alex Kost <alezost@gmail.com> wrote:
>> David Thompson (2015-08-01 22:17 +0300) wrote:
>>
>>> 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))
>>
>> There are similar procedures in (guix build utils): 'directory-exists?',
>> 'executable-file?' and 'symbolic-link?'. So I think it is better to put
>> 'regular-file?' there. WDYT?
>
> Sure, that makes sense. Done.
Ah, of course, I forgot about something: This patch triggers a
rebuild of *everything* now! I guess it should be applied to
core-updates. Or, the first patch I submitted can be applied to
master, and then a patch that moves 'regular-file?' to (guix build
utils) can be applied to core-updates later.
Thoughts?
- Dave
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] build: file-systems: Allow for bind mounting regular files.
2015-08-02 12:51 ` Thompson, David
@ 2015-08-02 13:31 ` Andreas Enge
2015-08-03 12:47 ` Alex Kost
1 sibling, 0 replies; 11+ messages in thread
From: Andreas Enge @ 2015-08-02 13:31 UTC (permalink / raw)
To: Thompson, David; +Cc: guix-devel, Alex Kost
On Sun, Aug 02, 2015 at 08:51:46AM -0400, Thompson, David wrote:
> Ah, of course, I forgot about something: This patch triggers a
> rebuild of *everything* now! I guess it should be applied to
> core-updates.
I think it would be better to wait until hydra is done building the
security updates Mark is adding.
Andreas
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] build: file-systems: Allow for bind mounting regular files.
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
1 sibling, 1 reply; 11+ messages in thread
From: Alex Kost @ 2015-08-03 12:47 UTC (permalink / raw)
To: Thompson, David; +Cc: guix-devel
Thompson, David (2015-08-02 15:51 +0300) wrote:
> On Sun, Aug 2, 2015 at 8:43 AM, Thompson, David
> <dthompson2@worcester.edu> wrote:
>> On Sun, Aug 2, 2015 at 8:10 AM, Alex Kost <alezost@gmail.com> wrote:
>>> David Thompson (2015-08-01 22:17 +0300) wrote:
>>>
>>>> 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))
>>>
>>> There are similar procedures in (guix build utils): 'directory-exists?',
>>> 'executable-file?' and 'symbolic-link?'. So I think it is better to put
>>> 'regular-file?' there. WDYT?
>>
>> Sure, that makes sense. Done.
>
> Ah, of course, I forgot about something: This patch triggers a
> rebuild of *everything* now! I guess it should be applied to
> core-updates. Or, the first patch I submitted can be applied to
> master, and then a patch that moves 'regular-file?' to (guix build
> utils) can be applied to core-updates later.
>
> Thoughts?
In my opinion it is redundant to use another commit here, so I would
apply this patch to core-updates (taking into account Andreas' note).
But I don't really know how such situations are handled. Mark should
know better.
--
Alex
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] build: file-systems: Allow for bind mounting regular files.
2015-08-03 12:47 ` Alex Kost
@ 2015-08-06 12:22 ` Thompson, David
2015-08-07 7:06 ` Alex Kost
0 siblings, 1 reply; 11+ messages in thread
From: Thompson, David @ 2015-08-06 12:22 UTC (permalink / raw)
To: Alex Kost; +Cc: guix-devel
On Mon, Aug 3, 2015 at 8:47 AM, Alex Kost <alezost@gmail.com> wrote:
> Thompson, David (2015-08-02 15:51 +0300) wrote:
>
>> Ah, of course, I forgot about something: This patch triggers a
>> rebuild of *everything* now! I guess it should be applied to
>> core-updates. Or, the first patch I submitted can be applied to
>> master, and then a patch that moves 'regular-file?' to (guix build
>> utils) can be applied to core-updates later.
>>
>> Thoughts?
>
> In my opinion it is redundant to use another commit here, so I would
> apply this patch to core-updates (taking into account Andreas' note).
> But I don't really know how such situations are handled. Mark should
> know better.
The reason I want two commits is strategic. This first patch can go
into master *now*, without breaking anything or causing a full
rebuild. Moving that procedure into (guix build utils) is nice, but
not strictly necessary. I am trying to get basic container support in
shape and into master. Waiting on a core-updates cycle would just
stall the process.
- Dave
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] build: file-systems: Allow for bind mounting regular files.
2015-08-06 12:22 ` Thompson, David
@ 2015-08-07 7:06 ` Alex Kost
0 siblings, 0 replies; 11+ messages in thread
From: Alex Kost @ 2015-08-07 7:06 UTC (permalink / raw)
To: Thompson, David; +Cc: guix-devel
Thompson, David (2015-08-06 15:22 +0300) wrote:
> On Mon, Aug 3, 2015 at 8:47 AM, Alex Kost <alezost@gmail.com> wrote:
>> Thompson, David (2015-08-02 15:51 +0300) wrote:
>>
>>> Ah, of course, I forgot about something: This patch triggers a
>>> rebuild of *everything* now! I guess it should be applied to
>>> core-updates. Or, the first patch I submitted can be applied to
>>> master, and then a patch that moves 'regular-file?' to (guix build
>>> utils) can be applied to core-updates later.
>>>
>>> Thoughts?
>>
>> In my opinion it is redundant to use another commit here, so I would
>> apply this patch to core-updates (taking into account Andreas' note).
>> But I don't really know how such situations are handled. Mark should
>> know better.
>
> The reason I want two commits is strategic. This first patch can go
> into master *now*, without breaking anything or causing a full
> rebuild. Moving that procedure into (guix build utils) is nice, but
> not strictly necessary. I am trying to get basic container support in
> shape and into master. Waiting on a core-updates cycle would just
> stall the process.
Ah, OK, I don't mind then.
--
Alex
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] build: file-systems: Allow for bind mounting regular files.
2015-08-01 19:17 [PATCH] build: file-systems: Allow for bind mounting regular files David Thompson
2015-08-02 12:10 ` Alex Kost
@ 2015-08-08 18:28 ` Thompson, David
1 sibling, 0 replies; 11+ messages in thread
From: Thompson, David @ 2015-08-08 18:28 UTC (permalink / raw)
To: guix-devel
On Sat, Aug 1, 2015 at 3:17 PM, David Thompson <dthompson2@worcester.edu> wrote:
> 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.
I pushed this.
- Dave
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] build: file-systems: Allow for bind mounting regular files.
2015-08-02 12:43 ` Thompson, David
2015-08-02 12:51 ` Thompson, David
@ 2015-08-18 15:52 ` Ludovic Courtès
2015-08-18 16:43 ` Thompson, David
1 sibling, 1 reply; 11+ messages in thread
From: Ludovic Courtès @ 2015-08-18 15:52 UTC (permalink / raw)
To: Thompson, David; +Cc: guix-devel, Alex Kost
"Thompson, David" <dthompson2@worcester.edu> skribis:
> +(define (regular-file? file-name)
> + "Return #t if FILE-NAME is a regular file."
> + (eq? (stat:type (stat file-name)) 'regular))
I see you moved this procedure to (gnu build file-systems), which is
reasonable.
I wonder if it should use ‘lstat’ instead of ‘stat’?
Ludo’.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] build: file-systems: Allow for bind mounting regular files.
2015-08-18 15:52 ` Ludovic Courtès
@ 2015-08-18 16:43 ` Thompson, David
0 siblings, 0 replies; 11+ messages in thread
From: Thompson, David @ 2015-08-18 16:43 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guix-devel, Alex Kost
On Tue, Aug 18, 2015 at 11:52 AM, Ludovic Courtès <ludo@gnu.org> wrote:
> "Thompson, David" <dthompson2@worcester.edu> skribis:
>
>> +(define (regular-file? file-name)
>> + "Return #t if FILE-NAME is a regular file."
>> + (eq? (stat:type (stat file-name)) 'regular))
>
> I see you moved this procedure to (gnu build file-systems), which is
> reasonable.
I did this to avoid a full rebuild. A patch for core-updates could move it.
> I wonder if it should use ‘lstat’ instead of ‘stat’?
To follow symlinks or not? I guess the answer is "no". I can change
it to lstat.
- Dave
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2015-08-18 16:43 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-01 19:17 [PATCH] build: file-systems: Allow for bind mounting regular files David Thompson
2015-08-02 12:10 ` 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
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).