Skip to contentSkip to conversation

erofs-utils: lib: add erofs_{rebuild_make_root,enable_sb_chksum}

PATCH New Hongzhen Luo 1 participant 1 message Jun 25, 2024 Library code

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 erofs-utils: lib: add erofs_{rebuild_make_root,enable_sb_chksum}

Move erofs_sb_csum_set() and erofs_mkfs_alloc_root() into liberofs for external use.

---
v3: Rebased the latest experimental branch.
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/

---
 include/erofs/inode.h    |  1 +
 include/erofs/internal.h |  1 +
 lib/inode.c              | 16 +++++++++
 lib/super.c              | 47 ++++++++++++++++++++++++
 mkfs/main.c              | 77 +++++-----------------------------------
 5 files changed, 73 insertions(+), 69 deletions(-)
include/erofs/inode.h +1 -0
index 2af8e6c..604161c 100644
@@ -45,6 +45,7 @@ struct erofs_inode *erofs_mkfs_build_tree_from_path(struct erofs_sb_info *sbi,
 struct erofs_inode *erofs_mkfs_build_special_from_fd(struct erofs_sb_info *sbi,
 						     int fd, const char *name);
 int erofs_fixup_root_inode(struct erofs_inode *root);
+struct erofs_inode *erofs_rebuild_make_root(struct erofs_sb_info *sbi);
 
 #ifdef __cplusplus
 }
include/erofs/internal.h +1 -0
index 61250d1..d5c5ce2 100644
@@ -403,6 +403,7 @@ void erofs_put_super(struct erofs_sb_info *sbi);
 int erofs_writesb(struct erofs_sb_info *sbi, struct erofs_buffer_head *sb_bh,
 		  erofs_blk_t *blocks);
 struct erofs_buffer_head *erofs_reserve_sb(void);
+int erofs_enable_sb_chksum(struct erofs_sb_info *sbi, u32 *crc);
 
 /* namei.c */
 int erofs_read_inode_from_disk(struct erofs_inode *vi);
lib/inode.c +16 -0
index 703dc63..3e82af7 100644
@@ -1978,3 +1978,19 @@ int erofs_fixup_root_inode(struct erofs_inode *root)
 	free(ibuf);
 	return err;
 }
+
+struct erofs_inode *erofs_rebuild_make_root(struct erofs_sb_info *sbi)
+{
+	struct erofs_inode *root;
+
+	root = erofs_new_inode(sbi);
+	if (IS_ERR(root))
+		return root;
+	root->i_srcpath = strdup("/");
+	root->i_mode = S_IFDIR | 0777;
+	root->i_parent = root;
+	root->i_mtime = root->sbi->build_time;
+	root->i_mtime_nsec = root->sbi->build_time_nsec;
+	erofs_init_empty_dir(root);
+	return root;
+}
lib/super.c +47 -0

50 lines not on this page · raw message

mkfs/main.c +8 -69

113 lines not on this page · raw message

Signature · 1 line
2.39.3