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 v6:
- fix more char* => grub_uint8_t* issues

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         | 980 +++++++++++++++++++++++++++++++++++
 grub-core/kern/misc.c        |  14 +
 include/grub/misc.h          |   1 +
 tests/erofs_test.in          |  20 +
 tests/util/grub-fs-tester.in |  32 +-
 10 files changed, 1059 insertions(+), 12 deletions(-)
 create mode 100644 grub-core/fs/erofs.c
 create mode 100644 tests/erofs_test.in

Interdiff against v6:
diff --git a/grub-core/fs/erofs.c b/grub-core/fs/erofs.c
index 8d143dd1b..5b89b7924 100644
--- a/grub-core/fs/erofs.c
+++ b/grub-core/fs/erofs.c
@@ -454,7 +454,7 @@ erofs_map_blocks (grub_fshelp_node_t node, struct 
grub_erofs_map_blocks *map)
 }
 
 static grub_err_t
-erofs_read_raw_data (grub_fshelp_node_t node, char *buf, grub_uint64_t size,
+erofs_read_raw_data (grub_fshelp_node_t node, grub_uint8_t *buf, grub_uint64_t 
size,
                     grub_uint64_t offset, grub_uint64_t *bytes)
 {
   struct grub_erofs_map_blocks map = {0};
@@ -474,7 +474,7 @@ erofs_read_raw_data (grub_fshelp_node_t node, char *buf, 
grub_uint64_t size,
   cur = offset;
   while (cur < offset + size)
     {
-      char *const estart = buf + cur - offset;
+      grub_uint8_t *const estart = buf + cur - offset;
       grub_uint64_t eend, moff = 0;
 
       map.m_la = cur;
@@ -529,7 +529,7 @@ erofs_iterate_dir (grub_fshelp_node_t dir, 
grub_fshelp_iterate_dir_hook_t hook,
 {
   grub_uint64_t offset = 0, file_size;
   grub_uint32_t blocksz = erofs_blocksz (dir->data);
-  char *buf;
+  grub_uint8_t *buf;
   grub_err_t err;
 
   if (!dir->inode_loaded)
@@ -595,7 +595,7 @@ erofs_iterate_dir (grub_fshelp_node_t dir, 
grub_fshelp_iterate_dir_hook_t hook,
              goto not_found;
            }
 
-         de_name = buf + nameoff;
+         de_name = (char *) buf + nameoff;
          if (de + 1 >= end)
            de_namelen = grub_strnlen (de_name, maxsize - nameoff);
          else
@@ -674,7 +674,7 @@ erofs_read_symlink (grub_fshelp_node_t node)
   if (!symlink)
     return NULL;
 
-  err = erofs_read_raw_data (node, symlink, sz - 1, 0, NULL);
+  err = erofs_read_raw_data (node, (grub_uint8_t *) symlink, sz - 1, 0, NULL);
   if (err != GRUB_ERR_NONE)
     {
       grub_free (symlink);
@@ -876,7 +876,7 @@ grub_erofs_read (grub_file_t file, char *buf, grub_size_t 
len)
   if (off + len > file_size)
     len = file_size - off;
 
-  err = erofs_read_raw_data (inode, buf, len, off, &ret);
+  err = erofs_read_raw_data (inode, (grub_uint8_t *) buf, len, off, &ret);
   if (err != GRUB_ERR_NONE)
     {
       grub_error (GRUB_ERR_IO, "cannot read file @ inode %" PRIuGRUB_UINT64_T, 
inode->ino);
-- 
2.44.0


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

Reply via email to