Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: #1423 zran check fail, because validate_header zran_count > chunk_count #1437

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add targzToRef mode flag
Signed-off-by: 伏鸾 <liuppengcheng.lpc@antgroup.com>
  • Loading branch information
伏鸾 committed Nov 9, 2023
commit 77f8df78c0285070d16c9d423c59edb1848eaba6
3 changes: 3 additions & 0 deletions builder/src/core/v6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,9 @@ impl Bootstrap {
if ctx.conversion_type == ConversionType::TarToTarfs {
ext_sb.set_tarfs_mode();
}
if ctx.conversion_type == ConversionType::TargzToRef {
ext_sb.set_targz_ref_mode();
}
bootstrap_ctx
.writer
.seek_offset((EROFS_SUPER_OFFSET + EROFS_SUPER_BLOCK_SIZE) as u64)
Expand Down
6 changes: 5 additions & 1 deletion rafs/src/metadata/direct_v6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ impl DirectMappingState {
self.meta.flags.contains(RafsSuperFlags::TARTFS_MODE)
}

fn is_zran(&self) -> bool {
self.meta.flags.contains(RafsSuperFlags::TARGZ_REF_MODE)
}

fn block_size(&self) -> u64 {
if self.is_tarfs() {
EROFS_BLOCK_SIZE_512
Expand Down Expand Up @@ -1349,7 +1353,7 @@ impl RafsInodeExt for OndiskInodeWrapper {
blob_index, chunk_index
))
})
} else if state.is_tarfs() || state.meta.has_inlined_chunk_digest() {
} else if state.is_tarfs() || state.is_zran() {
let size = if idx == self.get_chunk_count() - 1 {
(self.size() % self.chunk_size() as u64) as u32
} else {
Expand Down
4 changes: 4 additions & 0 deletions rafs/src/metadata/layout/v6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,10 @@ impl RafsV6SuperBlockExt {
self.s_flags |= RafsSuperFlags::TARTFS_MODE.bits();
}

pub fn set_targz_ref_mode(&mut self) {
self.s_flags |= RafsSuperFlags::TARGZ_REF_MODE.bits();
}

/// Set message digest algorithm to handle chunk of the Rafs filesystem.
pub fn set_digester(&mut self, digester: digest::Algorithm) {
let c: RafsSuperFlags = digester.into();
Expand Down
3 changes: 3 additions & 0 deletions rafs/src/metadata/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ bitflags! {
const INLINED_CHUNK_DIGEST = 0x0000_0100;
/// RAFS works in Tarfs mode, which directly uses tar streams as data blobs.
const TARTFS_MODE = 0x0000_0200;

const TARGZ_REF_MODE = 0x0000_0400;

/// Data chunks are not encrypted.
const ENCRYPTION_NONE = 0x0100_0000;
/// Data chunks are encrypted with AES-128-XTS.
Expand Down