On Fri, May 17, 2024 at 12:40:53PM +0800, Gao Xiang wrote:
> From: Yifan Zhao <[email protected]>
>
> 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. 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
>
> Signed-off-by: Yifan Zhao <[email protected]>
> Tested-by: Daniel Axtens <[email protected]> # fuzz testing only
> Signed-off-by: Gao Xiang <[email protected]>
> ---
[...]
> +static grub_err_t
> +erofs_map_blocks_chunkmode (grub_fshelp_node_t node,
> + struct grub_erofs_map_blocks *map)
> +{
> + grub_uint16_t chunk_format = grub_le_to_cpu16 (node->inode.e.i_u.c.format);
> + grub_uint64_t unit, pos, chunknr, blkaddr;
> + grub_uint8_t chunkbits;
> + grub_err_t err;
> +
> + if (chunk_format & EROFS_CHUNK_FORMAT_INDEXES)
> + unit = sizeof (struct grub_erofs_inode_chunk_index);
> + else
> + unit = EROFS_BLOCK_MAP_ENTRY_SIZE;
> +
> + chunkbits = node->data->sb.log2_blksz + (chunk_format &
> EROFS_CHUNK_FORMAT_BLKBITS_MASK);
> + if (chunkbits > 63)
> + return grub_error (GRUB_ERR_BAD_FS, "invalid chunkbits %u @ inode %"
> PRIuGRUB_UINT64_T,
> + chunkbits, node->ino);
> +
> + chunknr = map->m_la >> chunkbits;
> +
> + if (grub_add (erofs_iloc (node), erofs_inode_size (node), &pos))
> + return grub_error (GRUB_ERR_OUT_OF_RANGE, "chunkmap position overflow
> when adding inode size");
> +
> + 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))
> + return grub_error (GRUB_ERR_OUT_OF_RANGE, "position overflow when
> seeking at the start of chunkmap");
> + pos &= ~(unit - 1);
Please create a macro as I asked you earlier. Be careful with underflows too.
Otherwise patch set LGTM...
Daniel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel