Skip to content

Commit

Permalink
add targzToRef mode flag
Browse files Browse the repository at this point in the history
Signed-off-by: 伏鸾 <[email protected]>
  • Loading branch information
伏鸾 committed Nov 9, 2023
1 parent 9d42cb1 commit 77f8df7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
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

0 comments on commit 77f8df7

Please sign in to comment.