[PATCH v3 02/11] erofs-utils: lib: scan devtable if extra_devices is not specified

Jingbo Xu jefflexu at linux.alibaba.com
Tue Aug 22 19:24:48 AEST 2023


Scan the devtable (if any) automatically when reading superblock from
disk if sbi->extra_devices is not specified, and initialize
sbi->extra_devices with the number of on-disk device slots.

Signed-off-by: Jingbo Xu <jefflexu at linux.alibaba.com>
---
 lib/super.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/super.c b/lib/super.c
index 4fe81c3..fc709fc 100644
--- a/lib/super.c
+++ b/lib/super.c
@@ -37,7 +37,8 @@ static int erofs_init_devices(struct erofs_sb_info *sbi,
 	else
 		ondisk_extradevs = le16_to_cpu(dsb->extra_devices);
 
-	if (ondisk_extradevs != sbi->extra_devices) {
+	if (sbi->extra_devices &&
+	    ondisk_extradevs != sbi->extra_devices) {
 		erofs_err("extra devices don't match (ondisk %u, given %u)",
 			  ondisk_extradevs, sbi->extra_devices);
 		return -EINVAL;
@@ -45,6 +46,7 @@ static int erofs_init_devices(struct erofs_sb_info *sbi,
 	if (!ondisk_extradevs)
 		return 0;
 
+	sbi->extra_devices = ondisk_extradevs;
 	sbi->device_id_mask = roundup_pow_of_two(ondisk_extradevs + 1) - 1;
 	sbi->devs = calloc(ondisk_extradevs, sizeof(*sbi->devs));
 	if (!sbi->devs)
-- 
2.19.1.6.gb485710b



More information about the Linux-erofs mailing list