shithub: lwext4

Download patch

ref: 00c04858f25eb0d90eb98ec117b9ccca19dbb70a
parent: 9d667e4f5f732c994118fcd6303e6ff21c6669de
author: gkostka <[email protected]>
date: Sun Oct 11 06:57:21 EDT 2015

Add ext4_mkfs_read_info function

--- a/lwext4/ext4_mkfs.c
+++ b/lwext4/ext4_mkfs.c
@@ -67,12 +67,28 @@
 
 int ext4_mkfs_read_info(struct ext4_blockdev *bd, struct ext4_mkfs_info *info)
 {
-	(void)bd;
-	(void)info;
+	int r;
+	struct ext4_sblock *sb = NULL;
+	r = ext4_block_init(bd);
+	if (r != EOK)
+		return r;
 
-	ext4_mkfs_sb2info(0, 0);
+	sb = malloc(sizeof(struct ext4_sblock));
+	if (!sb)
+		goto Finish;
 
-	return EOK;
+
+	r = ext4_sb_read(bd, sb);
+	if (r != EOK)
+		goto Finish;
+
+	r = ext4_mkfs_sb2info(sb, info);
+
+Finish:
+	if (sb)
+		free(sb);
+	ext4_block_fini(bd);
+	return r;
 }
 
 int ext4_mkfs(struct ext4_blockdev *bd, struct ext4_mkfs_info *info)