Skip to content

Commit b5b704b

Browse files
authored
Merge pull request #336 from hsiangkao/ddtaridx
Support Tar metaidx for EROFS
2 parents a2e8f00 + 4863191 commit b5b704b

File tree

4 files changed

+21
-16
lines changed

4 files changed

+21
-16
lines changed

src/overlaybd/tar/erofs/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ include(FetchContent)
22

33
FetchContent_Declare(
44
erofs-utils
5-
GIT_REPOSITORY https://gitee.com/anolis/erofs-utils.git
6-
GIT_TAG 6ae5eb64136aeea90bda46d286af4628ea35d974
5+
GIT_REPOSITORY git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git
6+
GIT_TAG 617d708925b3c5d1dd132853e47d9d9f51443e6f
77
)
88

99
FetchContent_MakeAvailable(erofs-utils)
@@ -38,4 +38,4 @@ target_include_directories(erofs_lib PRIVATE
3838
)
3939

4040
target_compile_options(erofs_lib PRIVATE "-include${EROFS_CONFIG_FILE}")
41-
target_link_libraries(erofs_lib PRIVATE ${EROFS_LIB_STATIC})
41+
target_link_libraries(erofs_lib PRIVATE ${EROFS_LIB_STATIC})

src/overlaybd/tar/erofs/liberofs.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "erofs/tar.h"
33
#include "erofs/io.h"
44
#include "erofs/cache.h"
5+
#include "erofs/blobchunk.h"
56
#include "erofs/block_list.h"
67
#include "erofs/inode.h"
78
#include "erofs/config.h"
@@ -423,11 +424,6 @@ int erofs_mkfs(struct erofs_mkfs_cfg *cfg)
423424
return -EINVAL;
424425
}
425426

426-
if (!erofstar->rvsp_mode) {
427-
LOG_ERROR("[erofs] Must be in RVSP mode.");
428-
return -EINVAL;
429-
}
430-
431427
if (!cfg->incremental) {
432428
sbi->bmgr = erofs_buffer_init(sbi, 0);
433429
if (!sbi->bmgr) {
@@ -475,6 +471,14 @@ int erofs_mkfs(struct erofs_mkfs_cfg *cfg)
475471
goto exit;
476472
}
477473

474+
if (!erofstar->rvsp_mode) {
475+
err = erofs_mkfs_dump_blobs(sbi);
476+
if (err) {
477+
LOG_ERROR("[erofs] Fail to dump blob", err);
478+
goto exit;
479+
}
480+
}
481+
478482
err = erofs_bflush(sbi->bmgr, NULL);
479483
if (err) {
480484
LOG_ERROR("[erofs] Bflush failed.");
@@ -521,7 +525,6 @@ static int erofs_init_tar(struct erofs_tarfile *erofstar,
521525
{
522526
erofstar->global.xattrs = LIST_HEAD_INIT(erofstar->global.xattrs);
523527
erofstar->aufs = true;
524-
erofstar->rvsp_mode = true;
525528
erofstar->dev = rebuild_src_count + 1;
526529

527530
erofstar->ios.feof = false;
@@ -630,6 +633,9 @@ int LibErofs::extract_tar(photon::fs::IFile *source, bool meta_only, bool first_
630633
goto exit;
631634
}
632635

636+
erofstar.rvsp_mode = true;
637+
if (ddtaridx)
638+
erofstar.ddtaridx_mode = true;
633639
cfg.sbi = &sbi;
634640
cfg.erofstar = &erofstar;
635641
cfg.incremental = !first_layer;
@@ -656,8 +662,8 @@ int LibErofs::extract_tar(photon::fs::IFile *source, bool meta_only, bool first_
656662
return err;
657663
}
658664

659-
LibErofs::LibErofs(photon::fs::IFile *target, uint64_t blksize)
660-
: target(target), blksize(blksize)
665+
LibErofs::LibErofs(photon::fs::IFile *target, uint64_t blksize, bool import_tar_headers)
666+
: target(target), blksize(blksize), ddtaridx(import_tar_headers)
661667
{
662668
}
663669

src/overlaybd/tar/erofs/liberofs.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
#include <photon/fs/fiemap.h>
66
#include <photon/common/string_view.h>
77

8-
class LibErofs{
8+
class LibErofs {
99
public:
10-
LibErofs(photon::fs::IFile *target, uint64_t blksize);
10+
LibErofs(photon::fs::IFile *target, uint64_t blksize, bool import_tar_headers = false);
1111
~LibErofs();
1212
int extract_tar(photon::fs::IFile *source, bool meta_only, bool first_layer);
1313
private:
1414
photon::fs::IFile * target= nullptr; /* output file */
1515
uint64_t blksize;
16+
bool ddtaridx;
1617
};
1718
#endif

src/tools/turboOCI-apply.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,13 @@ int main(int argc, char **argv) {
127127

128128
// for now, buffer_file can't be used with turboOCI
129129
if (fstype == "erofs") {
130-
photon::fs::IFile* base_file = raw ? nullptr : ((ImageFile *)imgfile)->get_base();
131-
132130
ImageConfigNS::ImageConfig cfg;
133131
if (!cfg.ParseJSON(image_config_path)) {
134132
fprintf(stderr, "failed to parse image config\n");
135133
exit(-1);
136134
}
137135

138-
auto tar = new LibErofs(imgfile, 4096);
136+
auto tar = new LibErofs(imgfile, 4096, import_tar_headers);
139137
if (tar->extract_tar(src_file, true, cfg.lowers().size() == 0) < 0) {
140138
fprintf(stderr, "failed to extract\n");
141139
exit(-1);

0 commit comments

Comments
 (0)