Skip to content

Commit

Permalink
erofs-utils: Sync upstream changes [240712]
Browse files Browse the repository at this point in the history
Signed-off-by: sekaiacg <[email protected]>
  • Loading branch information
sekaiacg committed Jan 26, 2025
1 parent e5f7fe6 commit beee646
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 27 deletions.
2 changes: 2 additions & 0 deletions build/cmake/lib/liberofs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ set(liberofs_function_list
if (CMAKE_SYSTEM_NAME MATCHES "Linux|Android")
list(APPEND liberofs_include_list
"sys/random.h"
"sys/sendfile.h"
)
list(APPEND liberofs_function_list
"copy_file_range"
Expand All @@ -34,6 +35,7 @@ if (CMAKE_SYSTEM_NAME MATCHES "Linux|Android")
"pread64"
"pwrite64"
"posix_fadvise"
"sendfile"
"tmpfile64"
)
if (NOT RUN_ON_WSL)
Expand Down
2 changes: 2 additions & 0 deletions build/cmake/lib/liberofs_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#cmakedefine HAVE_SYS_IOCTL_H 1
#cmakedefine HAVE_SYS_SYSMACROS_H 1
#cmakedefine HAVE_SYS_RANDOM_H 1
#cmakedefine HAVE_SYS_SENDFILE_H 1
#cmakedefine HAVE_UNISTD_H 1

// Functions
Expand All @@ -25,6 +26,7 @@
#cmakedefine HAVE_PREAD64 1
#cmakedefine HAVE_PWRITE64 1
#cmakedefine HAVE_POSIX_FADVISE 1
#cmakedefine HAVE_SENDFILE 1
#cmakedefine HAVE_TMPFILE64 1
#cmakedefine HAVE_SYSCONF 1
#cmakedefine HAVE_UTIMENSAT 1
Expand Down
10 changes: 5 additions & 5 deletions extract/ExtractHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ namespace skkk {
int ret;

struct erofs_inode inode = {
.sbi = &sbi,
.sbi = &g_sbi,
.nid = nid
};

Expand Down Expand Up @@ -155,8 +155,8 @@ namespace skkk {
bool ret = 0;
char pathnameBuf[PATH_MAX] = {0};
struct erofs_inode vi = {
.sbi = &sbi,
.nid = sbi.root_nid
.sbi = &g_sbi,
.nid = g_sbi.root_nid
};

ret = erofs_ilookup(path.c_str(), &vi);
Expand All @@ -165,7 +165,7 @@ namespace skkk {
goto out;
}

ret = erofs_get_pathname(&sbi, vi.nid, pathnameBuf, PATH_MAX);
ret = erofs_get_pathname(&g_sbi, vi.nid, pathnameBuf, PATH_MAX);
if (ret) {
goto out;
}
Expand Down Expand Up @@ -709,7 +709,7 @@ namespace skkk {
snprintf(eo->iter_path, PATH_MAX, "/");
eo->iter_pos = 0;

err = doInitNodeRecursive(sbi.root_nid);
err = doInitNodeRecursive(g_sbi.root_nid);
if (err) {
rc = RET_EXTRACT_INIT_NODE_FAIL;
LOGCE("failed to initialize ErofsNode!");
Expand Down
6 changes: 3 additions & 3 deletions extract/ExtractOperation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ namespace skkk {
if (!isExtractTargetConfig) {
fsOptionFile = fopen(fsOptionPath.c_str(), "wb");
if (fsOptionFile) {
auto time = (time_t) sbi.build_time;
erofs_uuid_unparse_lower(sbi.uuid, uuid);
auto time = (time_t) g_sbi.build_time;
erofs_uuid_unparse_lower(g_sbi.uuid, uuid);
fprintf(fsOptionFile, "Filesystem created: %s", ctime(&time));
fprintf(fsOptionFile, "Filesystem UUID: %s\n", uuid);
// The options are for reference only, please modify according to the actual situation.
Expand All @@ -226,7 +226,7 @@ namespace skkk {
"--file-contexts=%s "
"%s " //output image file
"%s", //input dir
sbi.build_time, uuid,
g_sbi.build_time, uuid,
imgBaseName.c_str(),
fsConfigPath.c_str(), fsSelinuxLabelsPath.c_str(),
(imgBaseName + "_repack.img").c_str(),
Expand Down
12 changes: 6 additions & 6 deletions extract/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ static int parseAndCheckExtractCfg(int argc, char **argv) {
char *endPtr;
uint64_t n = strtoull(optarg, &endPtr, 0);
if (*endPtr == '\0') {
sbi.diskoffset = n;
LOGCD("offset=%lu", sbi.diskoffset);
g_sbi.bdev.offset = n;
LOGCD("offset=%lu", g_sbi.bdev.offset);
}
}
break;
Expand Down Expand Up @@ -233,14 +233,14 @@ int main(int argc, char **argv) {
goto exit;
}

err = dev_open_ro(&sbi, eo->getImgPath().c_str());
err = erofs_dev_open(&g_sbi, eo->getImgPath().c_str(), O_RDONLY);
if (err) {
ret = RET_EXTRACT_INIT_FAIL;
LOGCE("failed to open '%s'", eo->getImgPath().c_str());
goto exit;
}

err = erofs_read_superblock(&sbi);
err = erofs_read_superblock(&g_sbi);
if (err) {
ret = RET_EXTRACT_INIT_FAIL;
LOGCE("failed to read superblock");
Expand Down Expand Up @@ -297,12 +297,12 @@ int main(int argc, char **argv) {
printOperationTime(&start, &end);

exit_dev_close:
dev_close(&sbi);
erofs_dev_close(&g_sbi);
LOGCD("ErofsNode size=%lu", eo->getErofsNodes().size());
LOGCD("main exit ret=%d", ret);

exit:
blob_closeall(&sbi);
erofs_blob_closeall(&g_sbi);
erofs_exit_configure();
ExtractOperation::erofsOperationExit();
return ret;
Expand Down
26 changes: 13 additions & 13 deletions fuse/main_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int erofsfuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
};
erofs_dbg("readdir:%s offset=%llu", path, (long long)offset);

dir.sbi = &sbi;
dir.sbi = &g_sbi;
ret = erofs_ilookup(path, &dir);
if (ret)
return ret;
Expand Down Expand Up @@ -89,7 +89,7 @@ static int erofsfuse_open(const char *path, struct fuse_file_info *fi)

static int erofsfuse_getattr(const char *path, struct stat *stbuf)
{
struct erofs_inode vi = { .sbi = &sbi };
struct erofs_inode vi = { .sbi = &g_sbi };
int ret;

erofs_dbg("getattr(%s)", path);
Expand Down Expand Up @@ -120,7 +120,7 @@ static int erofsfuse_read(const char *path, char *buffer,

erofs_dbg("path:%s size=%zd offset=%llu", path, size, (long long)offset);

vi.sbi = &sbi;
vi.sbi = &g_sbi;
ret = erofs_ilookup(path, &vi);
if (ret)
return ret;
Expand Down Expand Up @@ -161,7 +161,7 @@ static int erofsfuse_getxattr(const char *path, const char *name, char *value,

erofs_dbg("getxattr(%s): name=%s size=%llu", path, name, size);

vi.sbi = &sbi;
vi.sbi = &g_sbi;
ret = erofs_ilookup(path, &vi);
if (ret)
return ret;
Expand All @@ -176,7 +176,7 @@ static int erofsfuse_listxattr(const char *path, char *list, size_t size)

erofs_dbg("listxattr(%s): size=%llu", path, size);

vi.sbi = &sbi;
vi.sbi = &g_sbi;
ret = erofs_ilookup(path, &vi);
if (ret)
return ret;
Expand Down Expand Up @@ -256,10 +256,10 @@ static int optional_opt_func(void *data, const char *arg, int key,

switch (key) {
case 1:
ret = blob_open_ro(&sbi, arg + sizeof("--device=") - 1);
ret = erofs_blob_open_ro(&g_sbi, arg + sizeof("--device=") - 1);
if (ret)
return -1;
++sbi.extra_devices;
++g_sbi.extra_devices;
return 0;
case FUSE_OPT_KEY_NONOPT:
if (fusecfg.mountpoint)
Expand Down Expand Up @@ -334,27 +334,27 @@ int main(int argc, char *argv[])
if (fusecfg.odebug && cfg.c_dbg_lvl < EROFS_DBG)
cfg.c_dbg_lvl = EROFS_DBG;

sbi.diskoffset = fusecfg.offset;
g_sbi.bdev.offset = fusecfg.offset;

erofsfuse_dumpcfg();
ret = dev_open_ro(&sbi, fusecfg.disk);
ret = erofs_dev_open(&g_sbi, fusecfg.disk, O_RDONLY);
if (ret) {
fprintf(stderr, "failed to open: %s\n", fusecfg.disk);
goto err_fuse_free_args;
}

ret = erofs_read_superblock(&sbi);
ret = erofs_read_superblock(&g_sbi);
if (ret) {
fprintf(stderr, "failed to read erofs super block\n");
goto err_dev_close;
}

ret = fuse_main(args.argc, args.argv, &erofs_ops, NULL);

erofs_put_super(&sbi);
erofs_put_super(&g_sbi);
err_dev_close:
blob_closeall(&sbi);
dev_close(&sbi);
erofs_blob_closeall(&g_sbi);
erofs_dev_close(&g_sbi);
err_fuse_free_args:
fuse_opt_free_args(&args);
err:
Expand Down

0 comments on commit beee646

Please sign in to comment.