GNU bug report logs - #56880
[PATCH] gnu: system: file-systems: Add shared flag.

Previous Next

Package: guix-patches;

Reported by: Oleg Pykhalov <go.wigust <at> gmail.com>

Date: Tue, 2 Aug 2022 11:24:01 UTC

Severity: normal

Tags: patch

Done: Oleg Pykhalov <go.wigust <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 56880 in the body.
You can then email your comments to 56880 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#56880; Package guix-patches. (Tue, 02 Aug 2022 11:24:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Oleg Pykhalov <go.wigust <at> gmail.com>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Tue, 02 Aug 2022 11:24:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Oleg Pykhalov <go.wigust <at> gmail.com>
To: guix-patches <at> gnu.org
Cc: Oleg Pykhalov <go.wigust <at> gmail.com>
Subject: [PATCH] gnu: system: file-systems: Add shared flag.
Date: Tue,  2 Aug 2022 14:23:09 +0300
* gnu/build/file-systems.scm (mount-flags->bit-mask, mount-file-system):
Handle shared flag.
* gnu/system/file-systems.scm (invalid-file-system-flags): Add shared to known
flags.
* guix/build/syscalls.scm (MS_SHARED): New variable.
(option-string->mount-flags): Handle shared flag.
* doc/guix.texi (File Systems): Document shared flag.
---
 doc/guix.texi               | 5 +++--
 gnu/build/file-systems.scm  | 6 ++++++
 gnu/system/file-systems.scm | 4 +++-
 guix/build/syscalls.scm     | 6 +++++-
 4 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 9d17050ffc..106ab428d9 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -16376,8 +16376,9 @@ include @code{read-only}, @code{bind-mount}, @code{no-dev} (disallow
 access to special files), @code{no-suid} (ignore setuid and setgid
 bits), @code{no-atime} (do not update file access times),
 @code{strict-atime} (update file access time), @code{lazy-time} (only
-update time on the in-memory version of the file inode), and
-@code{no-exec} (disallow program execution).
+update time on the in-memory version of the file inode),
+@code{no-exec} (disallow program execution), and @code{shared} (make the
+mount shared).
 @xref{Mount-Unmount-Remount,,, libc, The GNU C Library Reference
 Manual}, for more information on these flags.
 
diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm
index 1d3b33e7bd..b9d46c9350 100644
--- a/gnu/build/file-systems.scm
+++ b/gnu/build/file-systems.scm
@@ -6,6 +6,7 @@
 ;;; Copyright © 2019–2021 Tobias Geerinckx-Rice <me <at> tobias.gr>
 ;;; Copyright © 2019 David C. Trudgian <dave <at> trudgian.net>
 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
+;;; Copyright © 2022 Oleg Pykhalov <go.wigust <at> gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1123,6 +1124,8 @@ (define (mount-flags->bit-mask flags)
        (logior MS_STRICTATIME (loop rest)))
       (('lazy-time rest ...)
        (logior MS_LAZYTIME (loop rest)))
+      (('shared rest ...)
+       (loop rest))
       (()
        0))))
 
@@ -1186,6 +1189,9 @@ (define (mount-nfs source mount-point type flags options)
         (cond
          ((string-prefix? "nfs" type)
           (mount-nfs source target type flags options))
+         ((memq 'shared (file-system-flags fs))
+          (mount source target type flags options)
+          (mount "none" target #f MS_SHARED))
          (else
           (mount source target type flags options)))
 
diff --git a/gnu/system/file-systems.scm b/gnu/system/file-systems.scm
index f8f4276283..464b76a2ca 100644
--- a/gnu/system/file-systems.scm
+++ b/gnu/system/file-systems.scm
@@ -4,6 +4,7 @@
 ;;; Copyright © 2020 Jakub Kądziołka <kuba <at> kadziolka.net>
 ;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
 ;;; Copyright © 2021 Tobias Geerinckx-Rice <me <at> tobias.gr>
+;;; Copyright © 2022 Oleg Pykhalov <go.wigust <at> gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -121,7 +122,8 @@ (define invalid-file-system-flags
     ;; Note: Keep in sync with 'mount-flags->bit-mask'.
     (let ((known-flags '(read-only
                          bind-mount no-suid no-dev no-exec
-                         no-atime strict-atime lazy-time)))
+                         no-atime strict-atime lazy-time
+                         shared)))
       (lambda (flags)
         "Return the subset of FLAGS that is invalid."
         (remove (cut memq <> known-flags) flags))))
diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm
index a7401fd73f..ef0b1d67fd 100644
--- a/guix/build/syscalls.scm
+++ b/guix/build/syscalls.scm
@@ -8,6 +8,7 @@
 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke <at> gnu.org>
 ;;; Copyright © 2021 Chris Marusich <cmmarusich <at> gmail.com>
 ;;; Copyright © 2021 Tobias Geerinckx-Rice <me <at> tobias.gr>
+;;; Copyright © 2022 Oleg Pykhalov <go.wigust <at> gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -49,6 +50,7 @@ (define-module (guix build syscalls)
             MS_RELATIME
             MS_BIND
             MS_MOVE
+            MS_SHARED
             MS_LAZYTIME
             MNT_FORCE
             MNT_DETACH
@@ -537,6 +539,7 @@ (define MS_REMOUNT           32)
 (define MS_NOATIME         1024)
 (define MS_BIND            4096)
 (define MS_MOVE            8192)
+(define MS_SHARED       1048576)
 (define MS_RELATIME     2097152)
 (define MS_STRICTATIME 16777216)
 (define MS_LAZYTIME    33554432)
@@ -637,7 +640,8 @@ (define lst
                         ("nodev"      => MS_NODEV)
                         ("noexec"     => MS_NOEXEC)
                         ("relatime"   => MS_RELATIME)
-                        ("noatime"    => MS_NOATIME)))))))
+                        ("noatime"    => MS_NOATIME)
+                        ("shared"     => MS_SHARED)))))))
 
 (define (mount-flags mount)
   "Return the mount flags of MOUNT, a <mount> record, as an inclusive or of
-- 
2.37.0





Information forwarded to guix-patches <at> gnu.org:
bug#56880; Package guix-patches. (Wed, 03 Aug 2022 15:22:01 GMT) Full text and rfc822 format available.

Message #8 received at 56880 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Oleg Pykhalov <go.wigust <at> gmail.com>
Cc: 56880 <at> debbugs.gnu.org
Subject: Re: bug#56880: [PATCH] gnu: system: file-systems: Add shared flag.
Date: Wed, 03 Aug 2022 17:21:26 +0200
Hi Oleg,

Oleg Pykhalov <go.wigust <at> gmail.com> skribis:

> * gnu/build/file-systems.scm (mount-flags->bit-mask, mount-file-system):
> Handle shared flag.
> * gnu/system/file-systems.scm (invalid-file-system-flags): Add shared to known
> flags.
> * guix/build/syscalls.scm (MS_SHARED): New variable.
> (option-string->mount-flags): Handle shared flag.
> * doc/guix.texi (File Systems): Document shared flag.

LGTM, thanks!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#56880; Package guix-patches. (Thu, 04 Aug 2022 13:21:02 GMT) Full text and rfc822 format available.

Message #11 received at 56880 <at> debbugs.gnu.org (full text, mbox):

From: Oleg Pykhalov <go.wigust <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 56880 <at> debbugs.gnu.org
Subject: Re: bug#56880: [PATCH] gnu: system: file-systems: Add shared flag.
Date: Thu, 04 Aug 2022 16:20:16 +0300
[Message part 1 (text/plain, inline)]
Hi Ludovic,

Thank you for the review.

Ludovic Courtès <ludo <at> gnu.org> writes:

[…]

>> (option-string->mount-flags): Handle shared flag.

I looked again on this procedure before merge.  With applied patch it
will return a wrong bitmask according to the manual page:

mount(2)

    The  only other flags that can be specified while changing the propaga‐
    tion type are MS_REC (described below)  and  MS_SILENT  (which  is  ig‐
    nored).

Also I tried to invoke 'mount' from C code, if MS_SHARED specified and
mountpoint does not exist (not mounted without MS_SHARED before), then
nothing will happen.
 
The procedure is out of the scope adding a shared flag support to
file-system record.  I see two variants:

1. Remove the modification from option-string->mount-flags and merge,
someone will add when required.

2. Modify option-string->mount-flags in such way, that it will return
multiple bitmasks or in some other way.


Oleg.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#56880; Package guix-patches. (Fri, 05 Aug 2022 09:42:01 GMT) Full text and rfc822 format available.

Message #14 received at 56880 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Oleg Pykhalov <go.wigust <at> gmail.com>
Cc: 56880 <at> debbugs.gnu.org
Subject: Re: bug#56880: [PATCH] gnu: system: file-systems: Add shared flag.
Date: Fri, 05 Aug 2022 11:41:38 +0200
Hi,

Oleg Pykhalov <go.wigust <at> gmail.com> skribis:

> Ludovic Courtès <ludo <at> gnu.org> writes:
>
> […]
>
>>> (option-string->mount-flags): Handle shared flag.
>
> I looked again on this procedure before merge.  With applied patch it
> will return a wrong bitmask according to the manual page:
>
> mount(2)
>
>     The  only other flags that can be specified while changing the propaga‐
>     tion type are MS_REC (described below)  and  MS_SILENT  (which  is  ig‐
>     nored).
>
> Also I tried to invoke 'mount' from C code, if MS_SHARED specified and
> mountpoint does not exist (not mounted without MS_SHARED before), then
> nothing will happen.

Hmm not sure I follow.

> The procedure is out of the scope adding a shared flag support to
> file-system record.  I see two variants:
>
> 1. Remove the modification from option-string->mount-flags and merge,
> someone will add when required.
>
> 2. Modify option-string->mount-flags in such way, that it will return
> multiple bitmasks or in some other way.

I understand option #1 and it sounds reasonable to me.

I’m not sure what option #2 means concretely?

Thanks,
Ludo’.




Reply sent to Oleg Pykhalov <go.wigust <at> gmail.com>:
You have taken responsibility. (Wed, 10 Aug 2022 04:20:03 GMT) Full text and rfc822 format available.

Notification sent to Oleg Pykhalov <go.wigust <at> gmail.com>:
bug acknowledged by developer. (Wed, 10 Aug 2022 04:20:03 GMT) Full text and rfc822 format available.

Message #19 received at 56880-done <at> debbugs.gnu.org (full text, mbox):

From: Oleg Pykhalov <go.wigust <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 56880-done <at> debbugs.gnu.org
Subject: Re: bug#56880: [PATCH] gnu: system: file-systems: Add shared flag.
Date: Wed, 10 Aug 2022 07:19:38 +0300
[Message part 1 (text/plain, inline)]
Ludovic Courtès <ludo <at> gnu.org> writes:

[…]

>> I looked again on this procedure before merge.  With applied patch it
>> will return a wrong bitmask according to the manual page:
>>
>> mount(2)
>>
>>     The  only other flags that can be specified while changing the propaga‐
>>     tion type are MS_REC (described below)  and  MS_SILENT  (which  is  ig‐
>>     nored).
>>
>> Also I tried to invoke 'mount' from C code, if MS_SHARED specified and
>> mountpoint does not exist (not mounted without MS_SHARED before), then
>> nothing will happen.
>
> Hmm not sure I follow.

[…]

>> 2. Modify option-string->mount-flags in such way, that it will return
>> multiple bitmasks or in some other way.

[…]

> I’m not sure what option #2 means concretely?

We need to call mount(2) two times, which is not handled by
option-string->mount-flags which returns only one mount(2) bitmask.

I pushed #1 as 4b494878380920c8c7eecccd1f299164dd4a2c3f to master.


Oleg.
[signature.asc (application/pgp-signature, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 07 Sep 2022 11:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 291 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.