poky.lists.yoctoproject.org archive mirror
 help / color / mirror / Atom feed
* [PULL][PATCH 0/1] wic: Add support for F2FS in WIC rootfs plugin
@ 2023-02-23 12:11 Anna-Lena Marx
  2023-02-23 12:11 ` [PULL][PATCH 1/1] " Anna-Lena Marx
  0 siblings, 1 reply; 3+ messages in thread
From: Anna-Lena Marx @ 2023-02-23 12:11 UTC (permalink / raw)
  To: poky; +Cc: Anna-Lena Marx

Hi there,

Yocto supports generating F2FS rootfs in general for years but
WIC does not, yet.
The patch adds support to do so in the "rootfs" WIC plugin.

Generating the F2FS rootfs follows mostly the way it is implemented
in meta/classes-recipe/image_types.bbclass.
Thereby, F2FS needs a minimum size in order to work correctly as it
uses an overprovision functionality.

Pull from https://git.yoctoproject.org/poky-contrib/log/?h=amarx/wic-f2fs

-- Anna

Anna-Lena Marx (1):
  wic: Add support for F2FS in WIC rootfs plugin

 meta/classes-recipe/image_types_wic.bbclass |  2 +-
 meta/recipes-core/meta/wic-tools.bb         |  2 +-
 scripts/lib/wic/help.py                     |  1 +
 scripts/lib/wic/ksparser.py                 |  2 +-
 scripts/lib/wic/misc.py                     |  1 +
 scripts/lib/wic/partition.py                | 32 ++++++++++++++++++++-
 6 files changed, 36 insertions(+), 4 deletions(-)

-- 
2.39.2


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

* [PULL][PATCH 1/1] wic: Add support for F2FS in WIC rootfs plugin
  2023-02-23 12:11 [PULL][PATCH 0/1] wic: Add support for F2FS in WIC rootfs plugin Anna-Lena Marx
@ 2023-02-23 12:11 ` Anna-Lena Marx
  2023-02-23 12:28   ` [poky] " Alexander Kanavin
  0 siblings, 1 reply; 3+ messages in thread
From: Anna-Lena Marx @ 2023-02-23 12:11 UTC (permalink / raw)
  To: poky; +Cc: Anna-Lena Marx

Building F2FS rootfs is supported in Yocto - see
image_types.bbclass, but not in WIC.
This adds it as a nice convenience feature.

F2FS needs a minimum size of ~500M to operate correctly due to
an overprovision functionality.

Signed-off-by: Anna-Lena Marx <anna-lena.marx@inovex.de>
---
 meta/classes-recipe/image_types_wic.bbclass |  2 +-
 meta/recipes-core/meta/wic-tools.bb         |  2 +-
 scripts/lib/wic/help.py                     |  1 +
 scripts/lib/wic/ksparser.py                 |  2 +-
 scripts/lib/wic/misc.py                     |  1 +
 scripts/lib/wic/partition.py                | 32 ++++++++++++++++++++-
 6 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/meta/classes-recipe/image_types_wic.bbclass b/meta/classes-recipe/image_types_wic.bbclass
index c339b9bdfb..8ae5ecca4d 100644
--- a/meta/classes-recipe/image_types_wic.bbclass
+++ b/meta/classes-recipe/image_types_wic.bbclass
@@ -89,7 +89,7 @@ do_image_wic[recrdeptask] += "do_deploy"
 do_image_wic[deptask] += "do_image_complete"
 
 WKS_FILE_DEPENDS_DEFAULT = '${@bb.utils.contains_any("BUILD_ARCH", [ 'x86_64', 'i686' ], "syslinux-native", "",d)}'
-WKS_FILE_DEPENDS_DEFAULT += "bmap-tools-native cdrtools-native btrfs-tools-native squashfs-tools-native e2fsprogs-native erofs-utils-native"
+WKS_FILE_DEPENDS_DEFAULT += "bmap-tools-native cdrtools-native btrfs-tools-native squashfs-tools-native e2fsprogs-native erofs-utils-native f2fs-tools-native"
 # Unified kernel images need objcopy
 WKS_FILE_DEPENDS_DEFAULT += "virtual/${MLPREFIX}${TARGET_PREFIX}binutils"
 WKS_FILE_DEPENDS_BOOTLOADERS = ""
diff --git a/meta/recipes-core/meta/wic-tools.bb b/meta/recipes-core/meta/wic-tools.bb
index 9282d36a4d..d30ce66b56 100644
--- a/meta/recipes-core/meta/wic-tools.bb
+++ b/meta/recipes-core/meta/wic-tools.bb
@@ -7,7 +7,7 @@ DEPENDS = "\
            mtools-native bmap-tools-native grub-native cdrtools-native \
            btrfs-tools-native squashfs-tools-native pseudo-native \
            e2fsprogs-native util-linux-native tar-native erofs-utils-native \
-           virtual/${TARGET_PREFIX}binutils \
+           f2fs-tools-native virtual/${TARGET_PREFIX}binutils \
            "
 DEPENDS:append:x86 = " syslinux-native syslinux grub-efi systemd-boot"
 DEPENDS:append:x86-64 = " syslinux-native syslinux grub-efi systemd-boot"
diff --git a/scripts/lib/wic/help.py b/scripts/lib/wic/help.py
index 73e3380cde..0094065931 100644
--- a/scripts/lib/wic/help.py
+++ b/scripts/lib/wic/help.py
@@ -931,6 +931,7 @@ DESCRIPTION
              btrfs
              squashfs
              erofs
+             f2fs
              swap
 
          --fsoptions: Specifies a free-form string of options to be
diff --git a/scripts/lib/wic/ksparser.py b/scripts/lib/wic/ksparser.py
index d1e546b12d..e10ce6581d 100644
--- a/scripts/lib/wic/ksparser.py
+++ b/scripts/lib/wic/ksparser.py
@@ -159,7 +159,7 @@ class KickStart():
         part.add_argument('--fstype', default='vfat',
                           choices=('ext2', 'ext3', 'ext4', 'btrfs',
                                    'squashfs', 'vfat', 'msdos', 'erofs',
-                                   'swap', 'none'))
+                                   'f2fs', 'swap', 'none'))
         part.add_argument('--mkfs-extraopts', default='')
         part.add_argument('--label')
         part.add_argument('--use-label', action='store_true')
diff --git a/scripts/lib/wic/misc.py b/scripts/lib/wic/misc.py
index 2b90821b30..dc84a37423 100644
--- a/scripts/lib/wic/misc.py
+++ b/scripts/lib/wic/misc.py
@@ -41,6 +41,7 @@ NATIVE_RECIPES = {"bmaptool": "bmap-tools",
                   "mkfs.ext3": "e2fsprogs",
                   "mkfs.ext4": "e2fsprogs",
                   "mkfs.vfat": "dosfstools",
+                  "mkfs.f2fs": "f2fs-tools",
                   "mksquashfs": "squashfs-tools",
                   "mkswap": "util-linux",
                   "mmd": "mtools",
diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
index 382afa44bc..6adcaa041f 100644
--- a/scripts/lib/wic/partition.py
+++ b/scripts/lib/wic/partition.py
@@ -208,7 +208,7 @@ class Partition():
         Prepare content for a rootfs partition i.e. create a partition
         and fill it from a /rootfs dir.
 
-        Currently handles ext2/3/4, btrfs, vfat and squashfs.
+        Currently handles ext2/3/4, btrfs, vfat, squashfs and f2fs.
         """
 
         rootfs = "%s/rootfs_%s.%s.%s" % (cr_workdir, self.label,
@@ -351,6 +351,36 @@ class Partition():
              self.mkfs_extraopts, self.fsuuid, rootfs)
         exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo)
 
+    def prepare_rootfs_f2fs(self, rootfs, cr_workdir, oe_builddir, rootfs_dir,
+                            native_sysroot, pseudo):
+        """
+        Prepare content for a f2fs rootfs partition.
+        """
+        du_cmd = "du -ks %s" % rootfs_dir
+        out = exec_cmd(du_cmd)
+        actual_rootfs_size = int(out.split()[0])
+
+        min_f2fs_size = 524288
+        rootfs_size = self.get_rootfs_size(actual_rootfs_size)
+        if rootfs_size < min_f2fs_size:
+            rootfs_size = min_f2fs_size
+
+        with open(rootfs, 'w') as sparse:
+            os.ftruncate(sparse.fileno(), rootfs_size * 1024)
+
+        extraopts = self.mkfs_extraopts or "-O extra_attr,compression"
+
+        label_str = ""
+        if self.label:
+            label_str = "-l %s" % self.label
+
+        mkfs_f2fs_cmd = "mkfs.f2fs %s %s %s" % \
+                        (label_str, extraopts, rootfs)
+        exec_native_cmd(mkfs_f2fs_cmd, native_sysroot, pseudo=pseudo)
+
+        sload_f2fs_cmd = "sload.f2fs -f %s %s" % (rootfs_dir, rootfs)
+        exec_native_cmd(sload_f2fs_cmd, native_sysroot, pseudo=pseudo)
+
     def prepare_rootfs_msdos(self, rootfs, cr_workdir, oe_builddir, rootfs_dir,
                              native_sysroot, pseudo):
         """
-- 
2.39.2


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

* Re: [poky] [PULL][PATCH 1/1] wic: Add support for F2FS in WIC rootfs plugin
  2023-02-23 12:11 ` [PULL][PATCH 1/1] " Anna-Lena Marx
@ 2023-02-23 12:28   ` Alexander Kanavin
  0 siblings, 0 replies; 3+ messages in thread
From: Alexander Kanavin @ 2023-02-23 12:28 UTC (permalink / raw)
  To: anna-lena.marx; +Cc: poky

Hello Anna-Lena,

the correct mailing list is openembedded-core. Also, if you add
features to wic, you should also included tests for those features -
you can find existing tests in meta/lib/oeqa/selftest/cases/wic.py

Alex

On Thu, 23 Feb 2023 at 13:12, Anna-Lena Marx via
lists.yoctoproject.org
<anna-lena.marx=inovex.de@lists.yoctoproject.org> wrote:
>
> Building F2FS rootfs is supported in Yocto - see
> image_types.bbclass, but not in WIC.
> This adds it as a nice convenience feature.
>
> F2FS needs a minimum size of ~500M to operate correctly due to
> an overprovision functionality.
>
> Signed-off-by: Anna-Lena Marx <anna-lena.marx@inovex.de>
> ---
>  meta/classes-recipe/image_types_wic.bbclass |  2 +-
>  meta/recipes-core/meta/wic-tools.bb         |  2 +-
>  scripts/lib/wic/help.py                     |  1 +
>  scripts/lib/wic/ksparser.py                 |  2 +-
>  scripts/lib/wic/misc.py                     |  1 +
>  scripts/lib/wic/partition.py                | 32 ++++++++++++++++++++-
>  6 files changed, 36 insertions(+), 4 deletions(-)
>
> diff --git a/meta/classes-recipe/image_types_wic.bbclass b/meta/classes-recipe/image_types_wic.bbclass
> index c339b9bdfb..8ae5ecca4d 100644
> --- a/meta/classes-recipe/image_types_wic.bbclass
> +++ b/meta/classes-recipe/image_types_wic.bbclass
> @@ -89,7 +89,7 @@ do_image_wic[recrdeptask] += "do_deploy"
>  do_image_wic[deptask] += "do_image_complete"
>
>  WKS_FILE_DEPENDS_DEFAULT = '${@bb.utils.contains_any("BUILD_ARCH", [ 'x86_64', 'i686' ], "syslinux-native", "",d)}'
> -WKS_FILE_DEPENDS_DEFAULT += "bmap-tools-native cdrtools-native btrfs-tools-native squashfs-tools-native e2fsprogs-native erofs-utils-native"
> +WKS_FILE_DEPENDS_DEFAULT += "bmap-tools-native cdrtools-native btrfs-tools-native squashfs-tools-native e2fsprogs-native erofs-utils-native f2fs-tools-native"
>  # Unified kernel images need objcopy
>  WKS_FILE_DEPENDS_DEFAULT += "virtual/${MLPREFIX}${TARGET_PREFIX}binutils"
>  WKS_FILE_DEPENDS_BOOTLOADERS = ""
> diff --git a/meta/recipes-core/meta/wic-tools.bb b/meta/recipes-core/meta/wic-tools.bb
> index 9282d36a4d..d30ce66b56 100644
> --- a/meta/recipes-core/meta/wic-tools.bb
> +++ b/meta/recipes-core/meta/wic-tools.bb
> @@ -7,7 +7,7 @@ DEPENDS = "\
>             mtools-native bmap-tools-native grub-native cdrtools-native \
>             btrfs-tools-native squashfs-tools-native pseudo-native \
>             e2fsprogs-native util-linux-native tar-native erofs-utils-native \
> -           virtual/${TARGET_PREFIX}binutils \
> +           f2fs-tools-native virtual/${TARGET_PREFIX}binutils \
>             "
>  DEPENDS:append:x86 = " syslinux-native syslinux grub-efi systemd-boot"
>  DEPENDS:append:x86-64 = " syslinux-native syslinux grub-efi systemd-boot"
> diff --git a/scripts/lib/wic/help.py b/scripts/lib/wic/help.py
> index 73e3380cde..0094065931 100644
> --- a/scripts/lib/wic/help.py
> +++ b/scripts/lib/wic/help.py
> @@ -931,6 +931,7 @@ DESCRIPTION
>               btrfs
>               squashfs
>               erofs
> +             f2fs
>               swap
>
>           --fsoptions: Specifies a free-form string of options to be
> diff --git a/scripts/lib/wic/ksparser.py b/scripts/lib/wic/ksparser.py
> index d1e546b12d..e10ce6581d 100644
> --- a/scripts/lib/wic/ksparser.py
> +++ b/scripts/lib/wic/ksparser.py
> @@ -159,7 +159,7 @@ class KickStart():
>          part.add_argument('--fstype', default='vfat',
>                            choices=('ext2', 'ext3', 'ext4', 'btrfs',
>                                     'squashfs', 'vfat', 'msdos', 'erofs',
> -                                   'swap', 'none'))
> +                                   'f2fs', 'swap', 'none'))
>          part.add_argument('--mkfs-extraopts', default='')
>          part.add_argument('--label')
>          part.add_argument('--use-label', action='store_true')
> diff --git a/scripts/lib/wic/misc.py b/scripts/lib/wic/misc.py
> index 2b90821b30..dc84a37423 100644
> --- a/scripts/lib/wic/misc.py
> +++ b/scripts/lib/wic/misc.py
> @@ -41,6 +41,7 @@ NATIVE_RECIPES = {"bmaptool": "bmap-tools",
>                    "mkfs.ext3": "e2fsprogs",
>                    "mkfs.ext4": "e2fsprogs",
>                    "mkfs.vfat": "dosfstools",
> +                  "mkfs.f2fs": "f2fs-tools",
>                    "mksquashfs": "squashfs-tools",
>                    "mkswap": "util-linux",
>                    "mmd": "mtools",
> diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
> index 382afa44bc..6adcaa041f 100644
> --- a/scripts/lib/wic/partition.py
> +++ b/scripts/lib/wic/partition.py
> @@ -208,7 +208,7 @@ class Partition():
>          Prepare content for a rootfs partition i.e. create a partition
>          and fill it from a /rootfs dir.
>
> -        Currently handles ext2/3/4, btrfs, vfat and squashfs.
> +        Currently handles ext2/3/4, btrfs, vfat, squashfs and f2fs.
>          """
>
>          rootfs = "%s/rootfs_%s.%s.%s" % (cr_workdir, self.label,
> @@ -351,6 +351,36 @@ class Partition():
>               self.mkfs_extraopts, self.fsuuid, rootfs)
>          exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo)
>
> +    def prepare_rootfs_f2fs(self, rootfs, cr_workdir, oe_builddir, rootfs_dir,
> +                            native_sysroot, pseudo):
> +        """
> +        Prepare content for a f2fs rootfs partition.
> +        """
> +        du_cmd = "du -ks %s" % rootfs_dir
> +        out = exec_cmd(du_cmd)
> +        actual_rootfs_size = int(out.split()[0])
> +
> +        min_f2fs_size = 524288
> +        rootfs_size = self.get_rootfs_size(actual_rootfs_size)
> +        if rootfs_size < min_f2fs_size:
> +            rootfs_size = min_f2fs_size
> +
> +        with open(rootfs, 'w') as sparse:
> +            os.ftruncate(sparse.fileno(), rootfs_size * 1024)
> +
> +        extraopts = self.mkfs_extraopts or "-O extra_attr,compression"
> +
> +        label_str = ""
> +        if self.label:
> +            label_str = "-l %s" % self.label
> +
> +        mkfs_f2fs_cmd = "mkfs.f2fs %s %s %s" % \
> +                        (label_str, extraopts, rootfs)
> +        exec_native_cmd(mkfs_f2fs_cmd, native_sysroot, pseudo=pseudo)
> +
> +        sload_f2fs_cmd = "sload.f2fs -f %s %s" % (rootfs_dir, rootfs)
> +        exec_native_cmd(sload_f2fs_cmd, native_sysroot, pseudo=pseudo)
> +
>      def prepare_rootfs_msdos(self, rootfs, cr_workdir, oe_builddir, rootfs_dir,
>                               native_sysroot, pseudo):
>          """
> --
> 2.39.2
>
>
> 
>

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

end of thread, other threads:[~2023-02-23 12:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-23 12:11 [PULL][PATCH 0/1] wic: Add support for F2FS in WIC rootfs plugin Anna-Lena Marx
2023-02-23 12:11 ` [PULL][PATCH 1/1] " Anna-Lena Marx
2023-02-23 12:28   ` [poky] " Alexander Kanavin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).