All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] wic/direct/ksparser: ensure fsuuid for vfat and msdos align with format
@ 2020-12-30  6:17 Lee Chee Yang
  2020-12-30 16:05 ` [OE-core] " Richard Purdie
  0 siblings, 1 reply; 2+ messages in thread
From: Lee Chee Yang @ 2020-12-30  6:17 UTC (permalink / raw)
  To: openembedded-core

From: Lee Chee Yang <chee.yang.lee@intel.com>

vfat/msdos filesystem should have fsuuid in format 0xYYYYYYYY where "0x"
in front follow with 8 hexadecimal number in uppercase. In wic, when using
custom fsuuid for vfat/msdos partition in wks, it is able to set the value
in any length, with or without leading "0x". This can cause fsuuid
missaligned when fstab updates, fstab expect exactly 10 character
fsuuid for vfat/msdos partition and all in uppercase.

if custom fsuuid for vfat/msdos is set, check the length and format,
error if it exceed the format size. Amend it so it is align with format
0xYYYYYYYY. This is done before image create and fstab update to ensure the
fsuuid are same in all followup process. if custom fsuuid length less than
expected, fill in "0".

[yocto #14161]

Signed-off-by: Lee Chee Yang <chee.yang.lee@intel.com>
---
 scripts/lib/wic/ksparser.py              | 16 ++++++++++++++++
 scripts/lib/wic/plugins/imager/direct.py |  7 +++++++
 2 files changed, 23 insertions(+)

diff --git a/scripts/lib/wic/ksparser.py b/scripts/lib/wic/ksparser.py
index 913e3283dc..884c1f9f8b 100644
--- a/scripts/lib/wic/ksparser.py
+++ b/scripts/lib/wic/ksparser.py
@@ -229,6 +229,22 @@ class KickStart():
                                 err = "%s:%d: SquashFS does not support LABEL" \
                                        % (confpath, lineno)
                                 raise KickStartError(err)
+                        if parsed.fstype == 'msdos' or parsed.fstype == 'vfat':
+                            if parsed.fsuuid.upper().startswith('0X'):
+                                if len(parsed.fsuuid) > 10:
+                                    err = "%s:%d: fsuuid %s given in wks kickstart file " \
+                                          "exceeds the length limit for %s filesystem. " \
+                                          "It should be in the form of a 32 bit hexadecimal" \
+                                          "number (for example, 0xABCD1234)." \
+                                          % (confpath, lineno, parsed.fsuuid, parsed.fstype)
+                                    raise KickStartError(err)
+                            elif len(parsed.fsuuid) > 8:
+                                err = "%s:%d: fsuuid %s given in wks kickstart file " \
+                                      "exceeds the length limit for %s filesystem. " \
+                                      "It should be in the form of a 32 bit hexadecimal" \
+                                      "number (for example, 0xABCD1234)." \
+                                      % (confpath, lineno, parsed.fsuuid, parsed.fstype)
+                                raise KickStartError(err)
                         if parsed.use_label and not parsed.label:
                             err = "%s:%d: Must set the label with --label" \
                                   % (confpath, lineno)
diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
index 55db826e93..0ca67b77d5 100644
--- a/scripts/lib/wic/plugins/imager/direct.py
+++ b/scripts/lib/wic/plugins/imager/direct.py
@@ -343,6 +343,13 @@ class PartitionedImage():
                     part.fsuuid = '0x' + str(uuid.uuid4())[:8].upper()
                 else:
                     part.fsuuid = str(uuid.uuid4())
+            else:
+                #make sure the fsuuid for vfat/msdos align with format 0xYYYYYYYY
+                if part.fstype == 'vfat' or part.fstype == 'msdos':
+                    if part.fsuuid.upper().startswith("0X"):
+                        part.fsuuid = '0x' + part.fsuuid.upper()[2:].rjust(8,"0")
+                    else:
+                        part.fsuuid = '0x' + part.fsuuid.upper().rjust(8,"0")
 
     def prepare(self, imager):
         """Prepare an image. Call prepare method of all image partitions."""
-- 
2.17.1


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

* Re: [OE-core] [PATCH] wic/direct/ksparser: ensure fsuuid for vfat and msdos align with format
  2020-12-30  6:17 [PATCH] wic/direct/ksparser: ensure fsuuid for vfat and msdos align with format Lee Chee Yang
@ 2020-12-30 16:05 ` Richard Purdie
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Purdie @ 2020-12-30 16:05 UTC (permalink / raw)
  To: Lee Chee Yang, openembedded-core, Naveen Saini

On Wed, 2020-12-30 at 14:17 +0800, Lee Chee Yang wrote:
From: Lee Chee Yang <chee.yang.lee@intel.com>

vfat/msdos filesystem should have fsuuid in format 0xYYYYYYYY where
"0x"
in front follow with 8 hexadecimal number in uppercase. In wic, when
using
custom fsuuid for vfat/msdos partition in wks, it is able to set the
value
in any length, with or without leading "0x". This can cause fsuuid
missaligned when fstab updates, fstab expect exactly 10 character
fsuuid for vfat/msdos partition and all in uppercase.

if custom fsuuid for vfat/msdos is set, check the length and format,
error if it exceed the format size. Amend it so it is align with format
0xYYYYYYYY. This is done before image create and fstab update to ensure
the
fsuuid are same in all followup process. if custom fsuuid length less
than
expected, fill in "0".

[yocto #14161]

Signed-off-by: Lee Chee Yang <chee.yang.lee@intel.com>

There is something not quite right in this change:

https://autobuilder.yoctoproject.org/typhoon/#/builders/23/builds/3109

Cheers,

Richard


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

end of thread, other threads:[~2020-12-30 16:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-30  6:17 [PATCH] wic/direct/ksparser: ensure fsuuid for vfat and msdos align with format Lee Chee Yang
2020-12-30 16:05 ` [OE-core] " Richard Purdie

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.