diff mbox series

[wic,v2] wic: Fix updating fstab for nvme devices

Message ID 20260525162711.282346-1-aleksandar.nikolic22@pm.me
State New
Headers show
Series [wic,v2] wic: Fix updating fstab for nvme devices | expand

Commit Message

Aleksandar Nikolic May 25, 2026, 4:27 p.m. UTC
From: Aleksandar Nikolic <aleksandar.nikolic@zeiss.com>

In case wks file references nvme, update_fstab() function will not add
prefix 'p' before the partition number, as the if condition only takes
mmcblk into consideration.

In case of nvme0n1 this leads that following entries are added to fstab:

    /dev/nvme0n11
    /dev/nvme0n13

instead of:

    /dev/nvme0n1p1
    /dev/nvme0n1p3

The patch fixes this as it extends the if condition and adds prefix 'p' for
both mmcblk and nvme.

Signed-off-by: Aleksandar Nikolic <aleksandar.nikolic@zeiss.com>
---
 src/wic/plugins/imager/direct.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Trevor Woerner May 25, 2026, 5:47 p.m. UTC | #1
Thank you, all review comments addressed.

On Mon 2026-05-25 @ 06:27:11 PM, Aleksandar Nikolic wrote:
> From: Aleksandar Nikolic <aleksandar.nikolic@zeiss.com>
> 
> In case wks file references nvme, update_fstab() function will not add
> prefix 'p' before the partition number, as the if condition only takes
> mmcblk into consideration.
> 
> In case of nvme0n1 this leads that following entries are added to fstab:
> 
>     /dev/nvme0n11
>     /dev/nvme0n13
> 
> instead of:
> 
>     /dev/nvme0n1p1
>     /dev/nvme0n1p3
> 
> The patch fixes this as it extends the if condition and adds prefix 'p' for
> both mmcblk and nvme.
> 
> Signed-off-by: Aleksandar Nikolic <aleksandar.nikolic@zeiss.com>
> ---

Process note for future spins: adding a short changelog block in this
location (delimited by '---') makes it easier for me and for tools like
b4/Patchwork to see at a glance what moved between revisions. Not a
blocker here; just a habit worth building.

See: https://docs.yoctoproject.org/contributor-guide/submit-changes.html#taking-patch-review-into-account


---
>  src/wic/plugins/imager/direct.py | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/src/wic/plugins/imager/direct.py b/src/wic/plugins/imager/direct.py
> index 832d0e6..76d0f73 100644
> --- a/src/wic/plugins/imager/direct.py
> +++ b/src/wic/plugins/imager/direct.py
> @@ -134,8 +134,8 @@ class DirectPlugin(ImagerPlugin):
>              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 ''
> +                # mmc and nvme device partitions start with prefix 'p'
> +                prefix = 'p' if part.disk.startswith(('mmcblk', 'nvme')) else ''
>                  device_name = "/dev/%s%s%d" % (part.disk, prefix, part.realnum)
>  
>              opts = part.fsopts if part.fsopts else "defaults"
> @@ -269,7 +269,8 @@ class DirectPlugin(ImagerPlugin):
>                  elif part.label and self.ptable_format != 'msdos':
>                      return "PARTLABEL=%s" % part.label
>                  else:
> -                    suffix = 'p' if part.disk.startswith('mmcblk') else ''
> +                    # mmc and nvme device partitions start with prefix 'p'
> +                    suffix = 'p' if part.disk.startswith(('mmcblk', 'nvme')) else ''
>                      return "/dev/%s%s%-d" % (part.disk, suffix, part.realnum)
>  
>      def cleanup(self):
> -- 
> 2.43.0
>
diff mbox series

Patch

diff --git a/src/wic/plugins/imager/direct.py b/src/wic/plugins/imager/direct.py
index 832d0e6..76d0f73 100644
--- a/src/wic/plugins/imager/direct.py
+++ b/src/wic/plugins/imager/direct.py
@@ -134,8 +134,8 @@  class DirectPlugin(ImagerPlugin):
             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 ''
+                # mmc and nvme device partitions start with prefix 'p'
+                prefix = 'p' if part.disk.startswith(('mmcblk', 'nvme')) else ''
                 device_name = "/dev/%s%s%d" % (part.disk, prefix, part.realnum)
 
             opts = part.fsopts if part.fsopts else "defaults"
@@ -269,7 +269,8 @@  class DirectPlugin(ImagerPlugin):
                 elif part.label and self.ptable_format != 'msdos':
                     return "PARTLABEL=%s" % part.label
                 else:
-                    suffix = 'p' if part.disk.startswith('mmcblk') else ''
+                    # mmc and nvme device partitions start with prefix 'p'
+                    suffix = 'p' if part.disk.startswith(('mmcblk', 'nvme')) else ''
                     return "/dev/%s%s%-d" % (part.disk, suffix, part.realnum)
 
     def cleanup(self):