Skip to content

Commit 77f8df7

Browse files
author
伏鸾
committed
add targzToRef mode flag
Signed-off-by: 伏鸾 <[email protected]>
1 parent 9d42cb1 commit 77f8df7

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

builder/src/core/v6.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,9 @@ impl Bootstrap {
831831
if ctx.conversion_type == ConversionType::TarToTarfs {
832832
ext_sb.set_tarfs_mode();
833833
}
834+
if ctx.conversion_type == ConversionType::TargzToRef {
835+
ext_sb.set_targz_ref_mode();
836+
}
834837
bootstrap_ctx
835838
.writer
836839
.seek_offset((EROFS_SUPER_OFFSET + EROFS_SUPER_BLOCK_SIZE) as u64)

rafs/src/metadata/direct_v6.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ impl DirectMappingState {
8383
self.meta.flags.contains(RafsSuperFlags::TARTFS_MODE)
8484
}
8585

86+
fn is_zran(&self) -> bool {
87+
self.meta.flags.contains(RafsSuperFlags::TARGZ_REF_MODE)
88+
}
89+
8690
fn block_size(&self) -> u64 {
8791
if self.is_tarfs() {
8892
EROFS_BLOCK_SIZE_512
@@ -1349,7 +1353,7 @@ impl RafsInodeExt for OndiskInodeWrapper {
13491353
blob_index, chunk_index
13501354
))
13511355
})
1352-
} else if state.is_tarfs() || state.meta.has_inlined_chunk_digest() {
1356+
} else if state.is_tarfs() || state.is_zran() {
13531357
let size = if idx == self.get_chunk_count() - 1 {
13541358
(self.size() % self.chunk_size() as u64) as u32
13551359
} else {

rafs/src/metadata/layout/v6.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,10 @@ impl RafsV6SuperBlockExt {
559559
self.s_flags |= RafsSuperFlags::TARTFS_MODE.bits();
560560
}
561561

562+
pub fn set_targz_ref_mode(&mut self) {
563+
self.s_flags |= RafsSuperFlags::TARGZ_REF_MODE.bits();
564+
}
565+
562566
/// Set message digest algorithm to handle chunk of the Rafs filesystem.
563567
pub fn set_digester(&mut self, digester: digest::Algorithm) {
564568
let c: RafsSuperFlags = digester.into();

rafs/src/metadata/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ bitflags! {
301301
const INLINED_CHUNK_DIGEST = 0x0000_0100;
302302
/// RAFS works in Tarfs mode, which directly uses tar streams as data blobs.
303303
const TARTFS_MODE = 0x0000_0200;
304+
305+
const TARGZ_REF_MODE = 0x0000_0400;
306+
304307
/// Data chunks are not encrypted.
305308
const ENCRYPTION_NONE = 0x0100_0000;
306309
/// Data chunks are encrypted with AES-128-XTS.

0 commit comments

Comments
 (0)