All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] wic: Introduce the --use-label partition parameter
@ 2018-09-06 13:11 Kevin Hao
  2018-09-06 13:27 ` Tom Rini
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Hao @ 2018-09-06 13:11 UTC (permalink / raw)
  To: openembedded-core

We can use this parameter to make the wic use the label to name a
partition in /etc/fstab.

Signed-off-by: Kevin Hao <kexin.hao@windriver.com>
---
 scripts/lib/wic/help.py                  | 18 +++++++++++++-----
 scripts/lib/wic/ksparser.py              |  7 ++++++-
 scripts/lib/wic/partition.py             |  1 +
 scripts/lib/wic/plugins/imager/direct.py |  2 ++
 4 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/scripts/lib/wic/help.py b/scripts/lib/wic/help.py
index 842b868a575a..e250e130ef46 100644
--- a/scripts/lib/wic/help.py
+++ b/scripts/lib/wic/help.py
@@ -866,11 +866,11 @@ DESCRIPTION
        Partitions with a <mountpoint> specified will be automatically mounted.
        This is achieved by wic adding entries to the fstab during image
        generation. In order for a valid fstab to be generated one of the
-       --ondrive, --ondisk or --use-uuid partition options must be used for
-       each partition that specifies a mountpoint.  Note that with --use-uuid
-       and non-root <mountpoint>, including swap, the mount program must
-       understand the PARTUUID syntax.  This currently excludes the busybox
-       versions of these applications.
+       --ondrive, --ondisk, --use-uuid or --use-label partition options must
+       be used for each partition that specifies a mountpoint.  Note that with
+       --use-{uuid,label} and non-root <mountpoint>, including swap, the mount
+       program must understand the PARTUUID or LABEL syntax.  This currently
+       excludes the busybox versions of these applications.
 
 
        The following are supported 'part' options:
@@ -945,6 +945,14 @@ DESCRIPTION
                         label is already in use by another filesystem,
                         a new label is created for the partition.
 
+         --use-label: This option is specific to wic. It makes wic to use the
+                      label in /etc/fstab to specify a partition. If the
+                      --use-label and --use-uuid are used at the same time,
+                      we prefer the uuid because it is less likely to cause
+                      name confliction. We don't support to use this parameter
+                      on a root partition since the kernel can't understand the
+                      LABEL syntax.
+
          --active: Marks the partition as active.
 
          --align (in KBytes): This option is specific to wic and says
diff --git a/scripts/lib/wic/ksparser.py b/scripts/lib/wic/ksparser.py
index e590b2fe3c0d..220495b76654 100644
--- a/scripts/lib/wic/ksparser.py
+++ b/scripts/lib/wic/ksparser.py
@@ -141,6 +141,7 @@ class KickStart():
                                    'squashfs', 'vfat', 'msdos', 'swap'))
         part.add_argument('--mkfs-extraopts', default='')
         part.add_argument('--label')
+        part.add_argument('--use-label', action='store_true')
         part.add_argument('--no-table', action='store_true')
         part.add_argument('--ondisk', '--ondrive', dest='disk', default='sda')
         part.add_argument("--overhead-factor", type=overheadtype)
@@ -197,10 +198,14 @@ class KickStart():
                                              (confpath, lineno, err))
                     if line.startswith('part'):
                         # SquashFS does not support UUID
-                        if parsed.fstype == 'squashfs' and parsed.use_uuid:
+                        if parsed.fstype == 'squashfs' and (parsed.use_uuid or parsed.use_label):
                             err = "%s:%d: SquashFS does not support UUID" \
                                   % (confpath, lineno)
                             raise KickStartError(err)
+                        if parsed.use_label and not parsed.label:
+                            err = "%s:%d: Must set the label with --label" \
+                                  % (confpath, lineno)
+                            raise KickStartError(err)
                         # using ArgumentParser one cannot easily tell if option
                         # was passed as argument, if said option has a default
                         # value; --overhead-factor/--extra-space cannot be used
diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
index 5054779b1b6b..3da7e23e617e 100644
--- a/scripts/lib/wic/partition.py
+++ b/scripts/lib/wic/partition.py
@@ -47,6 +47,7 @@ class Partition():
         self.fsopts = args.fsopts
         self.fstype = args.fstype
         self.label = args.label
+        self.use_label = args.use_label
         self.mkfs_extraopts = args.mkfs_extraopts
         self.mountpoint = args.mountpoint
         self.no_table = args.no_table
diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
index 81583e97b9f7..bb14a334b2ce 100644
--- a/scripts/lib/wic/plugins/imager/direct.py
+++ b/scripts/lib/wic/plugins/imager/direct.py
@@ -155,6 +155,8 @@ class DirectPlugin(ImagerPlugin):
                         device_name = "UUID=%s" % part.fsuuid
                 else:
                     device_name = "PARTUUID=%s" % part.uuid
+            elif part.use_label:
+                device_name = "LABEL=%s" % part.label
             else:
                 # mmc device partitions are named mmcblk0p1, mmcblk0p2..
                 prefix = 'p' if  part.disk.startswith('mmcblk') else ''
-- 
2.14.4



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] wic: Introduce the --use-label partition parameter
  2018-09-06 13:11 [PATCH] wic: Introduce the --use-label partition parameter Kevin Hao
@ 2018-09-06 13:27 ` Tom Rini
  2018-09-06 13:57   ` Kevin Hao
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Rini @ 2018-09-06 13:27 UTC (permalink / raw)
  To: Kevin Hao; +Cc: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 2154 bytes --]

On Thu, Sep 06, 2018 at 09:11:20PM +0800, Kevin Hao wrote:

> We can use this parameter to make the wic use the label to name a
> partition in /etc/fstab.
> 
> Signed-off-by: Kevin Hao <kexin.hao@windriver.com>

Reviewed-by: Tom Rini <trini@konsulko.com>

A few minor things below:

[snip]
> @@ -945,6 +945,14 @@ DESCRIPTION
>                          label is already in use by another filesystem,
>                          a new label is created for the partition.
>  
> +         --use-label: This option is specific to wic. It makes wic to use the
> +                      label in /etc/fstab to specify a partition. If the
> +                      --use-label and --use-uuid are used at the same time,
> +                      we prefer the uuid because it is less likely to cause
> +                      name confliction. We don't support to use this parameter
> +                      on a root partition since the kernel can't understand the
> +                      LABEL syntax.

I think we should have the last sentence read more like:
We don't support using this parameter on the root partition since it
requires an initramfs to parse this value and we do not currently
support that.

Only because while what you said is correct, this makes it clear what
would be needed to support it.

> @@ -197,10 +198,14 @@ class KickStart():
>                                               (confpath, lineno, err))
>                      if line.startswith('part'):
>                          # SquashFS does not support UUID
> -                        if parsed.fstype == 'squashfs' and parsed.use_uuid:
> +                        if parsed.fstype == 'squashfs' and (parsed.use_uuid or parsed.use_label):
>                              err = "%s:%d: SquashFS does not support UUID" \
>                                    % (confpath, lineno)
>                              raise KickStartError(err)

This hunk is going to conflict with Emmanuel's patch.  Further I think
it should be a separate check on fstype == squashfs and (label &&
use_label) with a label-specific error message.  Thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] wic: Introduce the --use-label partition parameter
  2018-09-06 13:27 ` Tom Rini
@ 2018-09-06 13:57   ` Kevin Hao
  0 siblings, 0 replies; 3+ messages in thread
From: Kevin Hao @ 2018-09-06 13:57 UTC (permalink / raw)
  To: Tom Rini; +Cc: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 2467 bytes --]

On Thu, Sep 06, 2018 at 09:27:39AM -0400, Tom Rini wrote:
> On Thu, Sep 06, 2018 at 09:11:20PM +0800, Kevin Hao wrote:
> 
> > We can use this parameter to make the wic use the label to name a
> > partition in /etc/fstab.
> > 
> > Signed-off-by: Kevin Hao <kexin.hao@windriver.com>
> 
> Reviewed-by: Tom Rini <trini@konsulko.com>
> 
> A few minor things below:
> 
> [snip]
> > @@ -945,6 +945,14 @@ DESCRIPTION
> >                          label is already in use by another filesystem,
> >                          a new label is created for the partition.
> >  
> > +         --use-label: This option is specific to wic. It makes wic to use the
> > +                      label in /etc/fstab to specify a partition. If the
> > +                      --use-label and --use-uuid are used at the same time,
> > +                      we prefer the uuid because it is less likely to cause
> > +                      name confliction. We don't support to use this parameter
> > +                      on a root partition since the kernel can't understand the
> > +                      LABEL syntax.
> 
> I think we should have the last sentence read more like:
> We don't support using this parameter on the root partition since it
> requires an initramfs to parse this value and we do not currently
> support that.
> 
> Only because while what you said is correct, this makes it clear what
> would be needed to support it.

Absolutely. I will rephrase it as what you suggested.

> 
> > @@ -197,10 +198,14 @@ class KickStart():
> >                                               (confpath, lineno, err))
> >                      if line.startswith('part'):
> >                          # SquashFS does not support UUID
> > -                        if parsed.fstype == 'squashfs' and parsed.use_uuid:
> > +                        if parsed.fstype == 'squashfs' and (parsed.use_uuid or parsed.use_label):
> >                              err = "%s:%d: SquashFS does not support UUID" \
> >                                    % (confpath, lineno)
> >                              raise KickStartError(err)
> 
> This hunk is going to conflict with Emmanuel's patch.  Further I think
> it should be a separate check on fstype == squashfs and (label &&
> use_label) with a label-specific error message.  Thanks!

Thanks for the notice. I will rebase on the Emmanuel's new version patch.

Thanks,
Kevin
> 
> -- 
> Tom



[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 499 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-09-06 13:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-06 13:11 [PATCH] wic: Introduce the --use-label partition parameter Kevin Hao
2018-09-06 13:27 ` Tom Rini
2018-09-06 13:57   ` Kevin Hao

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.