diff --git a/src/overlaybd/tar/erofs/CMakeLists.txt b/src/overlaybd/tar/erofs/CMakeLists.txt index 721e6dab..b7e123c0 100644 --- a/src/overlaybd/tar/erofs/CMakeLists.txt +++ b/src/overlaybd/tar/erofs/CMakeLists.txt @@ -2,8 +2,8 @@ include(FetchContent) FetchContent_Declare( erofs-utils - GIT_REPOSITORY https://gitee.com/anolis/erofs-utils.git - GIT_TAG 6ae5eb64136aeea90bda46d286af4628ea35d974 + GIT_REPOSITORY git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git + GIT_TAG 617d708925b3c5d1dd132853e47d9d9f51443e6f ) FetchContent_MakeAvailable(erofs-utils) @@ -38,4 +38,4 @@ target_include_directories(erofs_lib PRIVATE ) target_compile_options(erofs_lib PRIVATE "-include${EROFS_CONFIG_FILE}") -target_link_libraries(erofs_lib PRIVATE ${EROFS_LIB_STATIC}) \ No newline at end of file +target_link_libraries(erofs_lib PRIVATE ${EROFS_LIB_STATIC}) diff --git a/src/overlaybd/tar/erofs/liberofs.cpp b/src/overlaybd/tar/erofs/liberofs.cpp index 844269a5..52467481 100644 --- a/src/overlaybd/tar/erofs/liberofs.cpp +++ b/src/overlaybd/tar/erofs/liberofs.cpp @@ -2,6 +2,7 @@ #include "erofs/tar.h" #include "erofs/io.h" #include "erofs/cache.h" +#include "erofs/blobchunk.h" #include "erofs/block_list.h" #include "erofs/inode.h" #include "erofs/config.h" @@ -423,11 +424,6 @@ int erofs_mkfs(struct erofs_mkfs_cfg *cfg) return -EINVAL; } - if (!erofstar->rvsp_mode) { - LOG_ERROR("[erofs] Must be in RVSP mode."); - return -EINVAL; - } - if (!cfg->incremental) { sbi->bmgr = erofs_buffer_init(sbi, 0); if (!sbi->bmgr) { @@ -475,6 +471,14 @@ int erofs_mkfs(struct erofs_mkfs_cfg *cfg) goto exit; } + if (!erofstar->rvsp_mode) { + err = erofs_mkfs_dump_blobs(sbi); + if (err) { + LOG_ERROR("[erofs] Fail to dump blob", err); + goto exit; + } + } + err = erofs_bflush(sbi->bmgr, NULL); if (err) { LOG_ERROR("[erofs] Bflush failed."); @@ -521,7 +525,6 @@ static int erofs_init_tar(struct erofs_tarfile *erofstar, { erofstar->global.xattrs = LIST_HEAD_INIT(erofstar->global.xattrs); erofstar->aufs = true; - erofstar->rvsp_mode = true; erofstar->dev = rebuild_src_count + 1; erofstar->ios.feof = false; @@ -630,6 +633,9 @@ int LibErofs::extract_tar(photon::fs::IFile *source, bool meta_only, bool first_ goto exit; } + erofstar.rvsp_mode = true; + if (ddtaridx) + erofstar.ddtaridx_mode = true; cfg.sbi = &sbi; cfg.erofstar = &erofstar; cfg.incremental = !first_layer; @@ -656,8 +662,8 @@ int LibErofs::extract_tar(photon::fs::IFile *source, bool meta_only, bool first_ return err; } -LibErofs::LibErofs(photon::fs::IFile *target, uint64_t blksize) - : target(target), blksize(blksize) +LibErofs::LibErofs(photon::fs::IFile *target, uint64_t blksize, bool import_tar_headers) + : target(target), blksize(blksize), ddtaridx(import_tar_headers) { } diff --git a/src/overlaybd/tar/erofs/liberofs.h b/src/overlaybd/tar/erofs/liberofs.h index c1064d65..a509c637 100644 --- a/src/overlaybd/tar/erofs/liberofs.h +++ b/src/overlaybd/tar/erofs/liberofs.h @@ -5,13 +5,14 @@ #include #include -class LibErofs{ +class LibErofs { public: - LibErofs(photon::fs::IFile *target, uint64_t blksize); + LibErofs(photon::fs::IFile *target, uint64_t blksize, bool import_tar_headers = false); ~LibErofs(); int extract_tar(photon::fs::IFile *source, bool meta_only, bool first_layer); private: photon::fs::IFile * target= nullptr; /* output file */ uint64_t blksize; + bool ddtaridx; }; #endif diff --git a/src/tools/turboOCI-apply.cpp b/src/tools/turboOCI-apply.cpp index 340f3939..ca00c833 100644 --- a/src/tools/turboOCI-apply.cpp +++ b/src/tools/turboOCI-apply.cpp @@ -127,15 +127,13 @@ int main(int argc, char **argv) { // for now, buffer_file can't be used with turboOCI if (fstype == "erofs") { - photon::fs::IFile* base_file = raw ? nullptr : ((ImageFile *)imgfile)->get_base(); - ImageConfigNS::ImageConfig cfg; if (!cfg.ParseJSON(image_config_path)) { fprintf(stderr, "failed to parse image config\n"); exit(-1); } - auto tar = new LibErofs(imgfile, 4096); + auto tar = new LibErofs(imgfile, 4096, import_tar_headers); if (tar->extract_tar(src_file, true, cfg.lowers().size() == 0) < 0) { fprintf(stderr, "failed to extract\n"); exit(-1);