From 92e6340a6fbc75f9f5b3e8d433a9e6e21f2d4676 Mon Sep 17 00:00:00 2001 From: Jiang Liu Date: Sat, 27 May 2023 15:44:38 +0800 Subject: [PATCH] builder: correctly generate nid for v6 inodes The `nid` is not actually used yet, but we should still generate it with correct value. Fixes: https://github.com/dragonflyoss/image-service/issues/1301 Signed-off-by: Jiang Liu --- rafs/src/builder/core/bootstrap.rs | 4 ++-- rafs/src/builder/core/v6.rs | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/rafs/src/builder/core/bootstrap.rs b/rafs/src/builder/core/bootstrap.rs index 1092a9f31b8..7e7b186d2a5 100644 --- a/rafs/src/builder/core/bootstrap.rs +++ b/rafs/src/builder/core/bootstrap.rs @@ -52,8 +52,8 @@ impl Bootstrap { Self::build_rafs(ctx, bootstrap_ctx, &mut self.tree)?; if ctx.fs_version.is_v6() { - // Sort directory entries to keep them ordered. - Self::v6_update_dirents(&self.tree, bootstrap_ctx.offset); + let root_offset = self.tree.node.lock().unwrap().v6_offset; + Self::v6_update_dirents(&self.tree, root_offset); } Ok(()) diff --git a/rafs/src/builder/core/v6.rs b/rafs/src/builder/core/v6.rs index a1a14ac9cda..d028dbc2f70 100644 --- a/rafs/src/builder/core/v6.rs +++ b/rafs/src/builder/core/v6.rs @@ -64,6 +64,8 @@ impl Node { if self.is_dir() || self.is_symlink() { self.v6_dirents_offset += meta_offset; } + let nid = calculate_nid(self.v6_offset, meta_addr); + self.inode.set_ino(nid); if self.is_dir() { self.v6_dump_dir(ctx, f_bootstrap, meta_addr, meta_offset, &mut inode)?;