grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v13 0/3] Introduce EROFS support


From: Gao Xiang
Subject: [PATCH v13 0/3] Introduce EROFS support
Date: Fri, 17 May 2024 20:17:25 +0800

Hi folks,

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

v12: 
20240517044054.2752375-1-hsiangkao@linux.alibaba.com">https://lore.kernel.org/grub-devel/20240517044054.2752375-1-hsiangkao@linux.alibaba.com
changelog since v12:
- Address ALIGN_UP_OVF() suggested by Daniel:
   Zkcv7G7MJBg8sKiE@tomti.i.net-space.pl">https://lore.kernel.org/grub-devel/Zkcv7G7MJBg8sKiE@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
Reviewed-by Link (Commit 2): 
ZkZ8fdd+ZCkT+t7n@tomti.i.net-space.pl/">https://lore.kernel.org/grub-devel/ZkZ8fdd+ZCkT+t7n@tomti.i.net-space.pl/

Gao Xiang (1):
  safemath: Add ALIGN_UP_OVF() that checks for {over,under}flow

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         | 1000 ++++++++++++++++++++++++++++++++++
 include/grub/safemath.h      |   16 +
 tests/erofs_test.in          |   20 +
 tests/util/grub-fs-tester.in |   32 +-
 9 files changed, 1080 insertions(+), 12 deletions(-)
 create mode 100644 grub-core/fs/erofs.c
 create mode 100644 tests/erofs_test.in

Interdiff against v12:
diff --git a/grub-core/fs/erofs.c b/grub-core/fs/erofs.c
index 630f95e75..005d975de 100644
--- a/grub-core/fs/erofs.c
+++ b/grub-core/fs/erofs.c
@@ -405,10 +405,8 @@ erofs_map_blocks_chunkmode (grub_fshelp_node_t node,
   if (grub_add (pos, erofs_inode_xattr_ibody_size (node), &pos))
     return grub_error (GRUB_ERR_OUT_OF_RANGE, "chunkmap position overflow when 
adding xattr size");
 
-  /* pos = ALIGN_UP(pos, unit) */
-  if (grub_add (pos, unit - 1, &pos))
+  if (ALIGN_UP_OVF (pos, unit - 1, &pos))
     return grub_error (GRUB_ERR_OUT_OF_RANGE, "position overflow when seeking 
at the start of chunkmap");
-  pos &= ~(unit - 1);
 
   /* No overflow for multiplication as chunkbits >= 9 and sizeof(unit) <= 8. */
   if (grub_add (pos, chunknr * unit, &pos))
diff --git a/include/grub/safemath.h b/include/grub/safemath.h
index fbd9b5925..baaea0ef4 100644
--- a/include/grub/safemath.h
+++ b/include/grub/safemath.h
@@ -32,6 +32,22 @@
 
 #define grub_cast(a, res)      grub_add ((a), 0, (res))
 
+#define ALIGN_UP_OVF(v, align, res)                    \
+({                                                     \
+  bool __failed;                                       \
+  typeof(v) a;                                         \
+                                                       \
+  __failed = grub_sub ((typeof(v))(align), 1, &a);     \
+  if (__failed == false)                               \
+    {                                                  \
+    __failed = grub_add (v, a, res);                   \
+    if (__failed == false)                             \
+      {                                                        \
+        *(res) &= ~a;                                  \
+      }                                                        \
+    }                                                  \
+__failed;})
+
 #else
 #error gcc 5.1 or newer or clang 8.0 or newer is required
 #endif
-- 
2.39.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]