[PATCH 1/3] catalyst: Rename shmfs -> shm

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 1/3] catalyst: Rename shmfs -> shm

Matt Turner-5
This will allow us to factor out the ['source', 'target'] from each
case.

Signed-off-by: Matt Turner <[hidden email]>
---
 catalyst/base/stagebase.py | 4 ++--
 catalyst/defaults.py       | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 68945da8..52f9cd5b 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -864,9 +864,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
                         target]
             elif source == 'tmpfs':
                 _cmd = ['mount', '-t', 'tmpfs', source, target]
-            elif source == 'shmfs':
+            elif source == 'shm':
                 _cmd = ['mount', '-t', 'tmpfs', '-o', 'noexec,nosuid,nodev',
-                        'shm', target]
+                        source, target]
             else:
                 _cmd = ['mount', source, target]
 
diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index 9d5771d5..404f4892 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -99,7 +99,7 @@ MOUNT_DEFAULTS = OrderedDict([
     }),
     ('shm', {
         'enable': True,
-        'source': 'shmfs',
+        'source': 'shm',
         'target': '/dev/shm',
     }),
     ('run', {
--
2.26.2


Reply | Threaded
Open this post in threaded view
|

[PATCH 2/3] catalyst: Factor out mount/source/target in bind()

Matt Turner-5
This simplifies things, and lets us only append to the end of the list.
It also enables us to simply add multiple args (in the next commit).

Signed-off-by: Matt Turner <[hidden email]>
---
 catalyst/base/stagebase.py | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 52f9cd5b..55d1032d 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -852,6 +852,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
 
             source = str(self.mount[x]['source'])
             target = self.settings['chroot_path'] + str(self.mount[x]['target'])
+            mount = ['mount']
 
             log.debug('bind %s: "%s" -> "%s"', x, source, target)
 
@@ -859,29 +860,25 @@ class StageBase(TargetBase, ClearBase, GenBase):
                 if 'var_tmpfs_portage' not in self.settings:
                     continue
 
-                _cmd = ['mount', '-t', 'tmpfs', '-o', 'size=' +
-                        self.settings['var_tmpfs_portage'] + 'G', source,
-                        target]
+                mount += ['-t', 'tmpfs', '-o', 'size=' +
+                          self.settings['var_tmpfs_portage'] + 'G']
             elif source == 'tmpfs':
-                _cmd = ['mount', '-t', 'tmpfs', source, target]
+                mount += ['-t', 'tmpfs']
             elif source == 'shm':
-                _cmd = ['mount', '-t', 'tmpfs', '-o', 'noexec,nosuid,nodev',
-                        source, target]
+                mount += ['-t', 'tmpfs', '-o', 'noexec,nosuid,nodev']
             else:
-                _cmd = ['mount', source, target]
-
-                source = Path(self.mount[x]['source'])
-                if source.suffix != '.sqfs':
-                    _cmd.insert(1, '--bind')
+                source_path = Path(self.mount[x]['source'])
+                if source_path.suffix != '.sqfs':
+                    mount.append('--bind')
 
                     # We may need to create the source of the bind mount. E.g., in the
                     # case of an empty package cache we must create the directory that
                     # the binary packages will be stored into.
-                    source.mkdir(mode=0o755, exist_ok=True)
+                    source_path.mkdir(mode=0o755, exist_ok=True)
 
             Path(target).mkdir(mode=0o755, parents=True, exist_ok=True)
 
-            cmd(_cmd, env=self.env, fail_func=self.unbind)
+            cmd(mount + [source, target], env=self.env, fail_func=self.unbind)
 
     def unbind(self):
         ouch = 0
--
2.26.2


Reply | Threaded
Open this post in threaded view
|

[PATCH 3/3] catalyst: Mount squashfs with -o ro

Matt Turner-5
In reply to this post by Matt Turner-5
Even though squashfs is not writeable, it must be mounted with -o ro in
order to be mounted multiple times. This allows, for example, the same
snapshot to be mounted simultaneously in multiple catalyst chroots.

Signed-off-by: Matt Turner <[hidden email]>
---
 catalyst/base/stagebase.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 55d1032d..651bf4e4 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -868,7 +868,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
                 mount += ['-t', 'tmpfs', '-o', 'noexec,nosuid,nodev']
             else:
                 source_path = Path(self.mount[x]['source'])
-                if source_path.suffix != '.sqfs':
+                if source_path.suffix == '.sqfs':
+                    mount += ['-o', 'ro']
+                else:
                     mount.append('--bind')
 
                     # We may need to create the source of the bind mount. E.g., in the
--
2.26.2


Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 1/3] catalyst: Rename shmfs -> shm

Brian Dolbec-3
In reply to this post by Matt Turner-5
On Thu, 14 May 2020 23:37:28 -0700
Matt Turner <[hidden email]> wrote:

> This will allow us to factor out the ['source', 'target'] from each
> case.
>
> Signed-off-by: Matt Turner <[hidden email]>
> ---
>  catalyst/base/stagebase.py | 4 ++--
>  catalyst/defaults.py       | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
> index 68945da8..52f9cd5b 100644
> --- a/catalyst/base/stagebase.py
> +++ b/catalyst/base/stagebase.py
> @@ -864,9 +864,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
>                          target]
>              elif source == 'tmpfs':
>                  _cmd = ['mount', '-t', 'tmpfs', source, target]
> -            elif source == 'shmfs':
> +            elif source == 'shm':
>                  _cmd = ['mount', '-t', 'tmpfs', '-o',
> 'noexec,nosuid,nodev',
> -                        'shm', target]
> +                        source, target]
>              else:
>                  _cmd = ['mount', source, target]
>  
> diff --git a/catalyst/defaults.py b/catalyst/defaults.py
> index 9d5771d5..404f4892 100644
> --- a/catalyst/defaults.py
> +++ b/catalyst/defaults.py
> @@ -99,7 +99,7 @@ MOUNT_DEFAULTS = OrderedDict([
>      }),
>      ('shm', {
>          'enable': True,
> -        'source': 'shmfs',
> +        'source': 'shm',
>          'target': '/dev/shm',
>      }),
>      ('run', {

Looks fine

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 3/3] catalyst: Mount squashfs with -o ro

Brian Dolbec-3
In reply to this post by Matt Turner-5
On Thu, 14 May 2020 23:37:30 -0700
Matt Turner <[hidden email]> wrote:

> Even though squashfs is not writeable, it must be mounted with -o ro
> in order to be mounted multiple times. This allows, for example, the
> same snapshot to be mounted simultaneously in multiple catalyst
> chroots.
>
> Signed-off-by: Matt Turner <[hidden email]>
> ---
>  catalyst/base/stagebase.py | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
> index 55d1032d..651bf4e4 100644
> --- a/catalyst/base/stagebase.py
> +++ b/catalyst/base/stagebase.py
> @@ -868,7 +868,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
>                  mount += ['-t', 'tmpfs', '-o', 'noexec,nosuid,nodev']
>              else:
>                  source_path = Path(self.mount[x]['source'])
> -                if source_path.suffix != '.sqfs':
> +                if source_path.suffix == '.sqfs':
> +                    mount += ['-o', 'ro']
> +                else:
>                      mount.append('--bind')
>  
>                      # We may need to create the source of the bind
> mount. E.g., in the

Yes to patch #2 and #3

Please make a header email for multiple commits series, Is easier to
approve all with one email ;)

I don't know why but I'm getting yours out of numerical order in
claws-mail...