grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: Yifan Zhao <zhaoyifan@sjtu.edu.cn>
To: grub-devel@gnu.org
Cc: development@efficientek.com, dkiper@net-space.pl,
	hsiangkao@linux.alibaba.com, zhaoyifan@sjtu.edu.cn
Subject: [PATCH v7 0/2] Introduce EROFS support
Date: Mon, 22 Apr 2024 12:22:19 +0800	[thread overview]
Message-ID: <20240422042221.20106-1-zhaoyifan@sjtu.edu.cn> (raw)

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	other threads:[~2024-04-22  4:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-22  4:22 Yifan Zhao [this message]
2024-04-22  4:22 ` [PATCH v7 1/2] fs/erofs: Add support for EROFS Yifan Zhao
2024-04-23 15:08   ` Daniel Axtens
2024-04-23 16:38     ` Yifan Zhao
2024-04-22  4:22 ` [PATCH v7 2/2] fs/erofs: Add tests for EROFS in grub-fs-tester Yifan Zhao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240422042221.20106-1-zhaoyifan@sjtu.edu.cn \
    --to=zhaoyifan@sjtu.edu.cn \
    --cc=development@efficientek.com \
    --cc=dkiper@net-space.pl \
    --cc=grub-devel@gnu.org \
    --cc=hsiangkao@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).