EROFS [1] is a lightweight read-only filesystem designed for performance
which has already been shipped in most Linux distributions as well as widely
used in several scenarios, such as Android system partitions, container
images, and rootfs for embedded devices.

This patch brings EROFS uncompressed support together with related tests.
Now, it's possible to boot directly through GRUB with an EROFS rootfs.

EROFS compressed files will be supported later since it has more work to
polish.

[1] https://erofs.docs.kernel.org

changelog since v10:
- Fix coverity warnings reported by Daniel:
   
https://lore.kernel.org/grub-devel/20240509175714.fccferxvffylk...@tomti.i.net-space.pl

Tested-by Link (Commit 1): 
https://lists.gnu.org/archive/html/grub-devel/2024-05/msg00001.html
Reviewed-by Link (Commit 2): 
https://lists.gnu.org/archive/html/grub-devel/2024-04/msg00101.html

Yifan Zhao (2):
  fs/erofs: Add support for EROFS
  fs/erofs: Add tests for EROFS in grub-fs-tester

 .gitignore                   |    1 +
 INSTALL                      |    8 +-
 Makefile.util.def            |    7 +
 docs/grub.texi               |    3 +-
 grub-core/Makefile.core.def  |    5 +
 grub-core/fs/erofs.c         | 1008 ++++++++++++++++++++++++++++++++++
 tests/erofs_test.in          |   20 +
 tests/util/grub-fs-tester.in |   32 +-
 8 files changed, 1072 insertions(+), 12 deletions(-)
 create mode 100644 grub-core/fs/erofs.c
 create mode 100644 tests/erofs_test.in

Interdiff against v10:

diff --git a/grub-core/fs/erofs.c b/grub-core/fs/erofs.c
index b82212b16..14c86f435 100644
--- a/grub-core/fs/erofs.c
+++ b/grub-core/fs/erofs.c
@@ -396,7 +396,7 @@ erofs_map_blocks_chunkmode (grub_fshelp_node_t node,
     unit = EROFS_BLOCK_MAP_ENTRY_SIZE;
 
   chunkbits = node->data->sb.log2_blksz + (chunk_format & 
EROFS_CHUNK_FORMAT_BLKBITS_MASK);
-  if (chunkbits > 64)
+  if (chunkbits > 63)
     return grub_error (GRUB_ERR_BAD_FS, "invalid chunkbits %u @ inode %" 
PRIuGRUB_UINT64_T,
                       chunkbits, node->ino);
 
@@ -787,11 +787,13 @@ erofs_dir_iter (const char *filename, enum 
grub_fshelp_filetype filetype,
 {
   struct grub_erofs_dir_ctx *ctx = data;
   struct grub_dirhook_info info = {0};
+  grub_err_t err;
 
   if (!node->inode_loaded)
     {
-      erofs_read_inode (ctx->data, node);
-      grub_errno = GRUB_ERR_NONE;
+      err = erofs_read_inode (ctx->data, node);
+      if (err != GRUB_ERR_NONE)
+        return 0;
     }
 
   if (node->inode_loaded)
@@ -953,11 +955,10 @@ grub_erofs_label (grub_device_t device, char **label)
     }
 
   *label = grub_strndup ((char *) data->sb.volume_name, sizeof 
(data->sb.volume_name));
-  if (!*label)
-    return grub_errno;
-
   grub_free (data);
 
+  if (!*label)
+    return grub_errno;
   return GRUB_ERR_NONE;
 }
 
@@ -1004,4 +1005,4 @@ GRUB_MOD_INIT (erofs)
 GRUB_MOD_FINI (erofs)
 {
   grub_fs_unregister (&grub_erofs_fs);
 }

-- 
2.39.3


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to