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 v8: - raname grub_strnlen to grub_erofs_strnlen and move it to grub-core/fs/erofs.c 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 | 998 +++++++++++++++++++++++++++++++++++ tests/erofs_test.in | 20 + tests/util/grub-fs-tester.in | 32 +- 8 files changed, 1062 insertions(+), 12 deletions(-) create mode 100644 grub-core/fs/erofs.c create mode 100644 tests/erofs_test.in Interdiff against v8: diff --git a/grub-core/fs/erofs.c b/grub-core/fs/erofs.c index 13f92e71a..9c2678796 100644 --- a/grub-core/fs/erofs.c +++ b/grub-core/fs/erofs.c @@ -217,6 +217,20 @@ struct grub_erofs_data #define erofs_blocksz(data) (((grub_uint32_t) 1) << data->sb.log2_blksz) +static grub_size_t +grub_erofs_strnlen (const char *s, grub_size_t n) +{ + const char *p = s; + + if (n == 0) + return 0; + + while (n-- && *p) + p++; + + return p - s; +} + static grub_uint64_t erofs_iloc (grub_fshelp_node_t node) { @@ -599,7 +613,7 @@ erofs_iterate_dir (grub_fshelp_node_t dir, grub_fshelp_iterate_dir_hook_t hook, de_name = (char *) buf + nameoff; if (de + 1 >= end) - de_namelen = grub_strnlen (de_name, maxsize - nameoff); + de_namelen = grub_erofs_strnlen (de_name, maxsize - nameoff); else de_namelen = grub_le_to_cpu16 (de[1].nameoff) - nameoff; diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c index 67240d64d..7cee5d75c 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -594,20 +594,6 @@ grub_strlen (const char *s) return p - s; } -grub_size_t -grub_strnlen (const char *s, grub_size_t n) -{ - const char *p = s; - - if (n == 0) - return 0; - - while (n-- && *p) - p++; - - return p - s; -} - static inline void grub_reverse (char *str) { diff --git a/include/grub/misc.h b/include/grub/misc.h index eb4aa55c1..1b35a167f 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -335,7 +335,6 @@ char *EXPORT_FUNC(grub_strdup) (const char *s) WARN_UNUSED_RESULT; char *EXPORT_FUNC(grub_strndup) (const char *s, grub_size_t n) WARN_UNUSED_RESULT; void *EXPORT_FUNC(grub_memset) (void *s, int c, grub_size_t n); grub_size_t EXPORT_FUNC(grub_strlen) (const char *s) WARN_UNUSED_RESULT; -grub_size_t EXPORT_FUNC(grub_strnlen) (const char *s, grub_size_t n) WARN_UNUSED_RESULT; /* Replace all `ch' characters of `input' with `with' and copy the result into `output'; return EOS address of `output'. */ -- 2.44.0 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel