erofs-utils: lib: introduce liberofs_global_{init,exit}
PATCH 1/7 erofs-utils: lib: introduce liberofs_global_{init,exit}
Currently, our codebase only correctly supports a single instance during its entire lifetime. However, this will be changed so that at least 3rd-party applications can formally use liberofs with multiple instances simultaneously. Therefore, it is necessary to separate global initialization from per-instance initialization.
Another point is that libcurl will be used for other remote backends, so it also needs to be separated from the current S3 backend.
--- include/erofs/internal.h | 3 ++ include/erofs/lock.h | 3 ++ lib/Makefile.am | 5 ++-- lib/global.c | 55 ++++++++++++++++++++++++++++++++++ lib/liberofs_s3.h | 1 + lib/remotes/s3.c | 65 ++++++++++++++++++---------------------- mkfs/main.c | 22 +++++++------- 7 files changed, 106 insertions(+), 48 deletions(-) create mode 100644 lib/global.c
include/erofs/internal.h +3 -0
@@ -426,6 +426,9 @@ struct erofs_map_dev {unsigned int m_deviceid; }; +int liberofs_global_init (void ); +void liberofs_global_exit (void ); +/* super.c */ int erofs_read_superblock (struct erofs_sb_info *sbi);void erofs_put_super (struct erofs_sb_info *sbi);
include/erofs/lock.h +3 -0
@@ -16,6 +16,9 @@ static inline void erofs_mutex_init(erofs_mutex_t *lock)#define erofs_mutex_lock pthread_mutex_lock#define erofs_mutex_unlock pthread_mutex_unlock +#define EROFS_DEFINE_MUTEX (lock) \ + erofs_mutex_t lock = PTHREAD_MUTEX_INITIALIZER +typedef pthread_rwlock_t erofs_rwsem_t ;static inline void erofs_init_rwsem (erofs_rwsem_t *lock)
lib/Makefile.am +3 -2
@@ -29,7 +29,8 @@ noinst_HEADERS = $(top_srcdir)/include/erofs_fs.h \ $(top_srcdir)/include/erofs/rebuild.h \ $(top_srcdir)/lib/liberofs_private.h \ $(top_srcdir)/lib/liberofs_xxhash.h \ - $(top_srcdir)/lib/liberofs_metabox.h + $(top_srcdir)/lib/liberofs_metabox.h \ + $(top_srcdir)/lib/liberofs_s3.h noinst_HEADERS += compressor.h liberofs_la_SOURCES = config.c io.c cache.c super.c inode.c xattr.c exclude.c \
@@ -37,7 +38,7 @@ liberofs_la_SOURCES = config.c io.c cache.c super.c inode.c xattr.c exclude.c \ compress_hints.c hashmap.c sha256.c blobchunk.c dir.c \ fragments.c dedupe.c uuid_unparse.c uuid.c tar.c \ block_list.c rebuild.c diskbuf.c bitops.c dedupe_ext.c \ - vmdk.c metabox.c + vmdk.c metabox.c global.c liberofs_la_CFLAGS = -Wall ${libuuid_CFLAGS} -I$(top_srcdir)/include if ENABLE_LZ4
lib/global.c new file +55 -0
55 lines not on this page · raw message
lib/liberofs_s3.h +1 -0
@@ -25,6 +25,7 @@ enum s3erofs_signature_version {#define S3_SECRET_KEY_LEN 256struct erofs_s3 { +void *easy_curl;const char *endpoint;char access_key[S3_ACCESS_KEY_LEN +1 ];char secret_key[S3_SECRET_KEY_LEN +1 ];
lib/remotes/s3.c +29 -36
131 lines not on this page · raw message
mkfs/main.c +12 -10
@@ -1481,10 +1481,12 @@ int main(int argc, char **argv)struct timeval t;FILE *blklst =NULL ;s64 mkfs_time =0 ; -int err =0 ; +int err;u32 crc; -erofs_init_configure (); + err =liberofs_global_init (); +if (err) +return 1 ;erofs_mkfs_default_options (); err =mkfs_parse_options_cfg (argc, argv);
@@ -1492,13 +1494,13 @@ int main(int argc, char **argv)if (err) {if (err == -EINVAL )fprintf (stderr,"Try '%s --help' for more information.\n" , argv[0 ]); -return 1 ; + goto exit; } err =parse_source_date_epoch ();if (err) {fprintf (stderr,"Try '%s --help' for more information.\n" , argv[0 ]); -return 1 ; + goto exit; } g_sbi.fixed_nsec =0 ;
@@ -1521,14 +1523,14 @@ int main(int argc, char **argv) (incremental_mode ? 0 : O_TRUNC));if (err) {fprintf (stderr,"Try '%s --help' for more information.\n" , argv[0 ]); -return 1 ; + goto exit; }#ifdef WITH_ANDROID if (cfg.fs_config_file &&load_canned_fs_config (cfg.fs_config_file) <0 ) {erofs_err ("failed to load fs config %s" , cfg.fs_config_file); -return 1 ; + goto exit; }#endif erofs_show_config ();
@@ -1540,7 +1542,7 @@ int main(int argc, char **argv)if (err) {erofs_err ("failed to initialize packedfile: %s" ,strerror (-err)); -return 1 ; + goto exit; } }
@@ -1549,7 +1551,7 @@ int main(int argc, char **argv)if (err) {erofs_err ("failed to initialize metabox: %s" ,erofs_strerror (err)); -return 1 ; + goto exit; } }
@@ -1687,7 +1689,7 @@ int main(int argc, char **argv)if (cfg.c_chunkbits) { err =erofs_blob_init (cfg.c_blobdev_path,1 << cfg.c_chunkbits);if (err) -return 1 ; + goto exit; }if (tar_index_512b || cfg.c_blobdev_path) {
@@ -1851,7 +1853,6 @@ exit:erofs_xattr_cleanup_name_prefixes ();erofs_rebuild_cleanup ();erofs_diskbuf_exit (); -erofs_exit_configure ();if (source_mode ==EROFS_MKFS_SOURCE_TAR ) {erofs_iostream_close (&erofstar.ios);if (erofstar.ios.dumpfd >=0 )
@@ -1866,5 +1867,6 @@ exit:erofs_update_progressinfo ("Build completed.\n" );erofs_mkfs_showsummaries ();erofs_put_super (&g_sbi); +liberofs_global_exit ();return 0 ; }
Signature · 1 line
2.43.5
PATCH 2/7 erofs-utils: lib: introduce an importer framework
Introduce a generic importer mechanism to import data into the EROFS filesystem tree using specific configuration parameters.
This allows mkfs parameters to be moved out of struct erofs_configure and configured per instance.
--- include/erofs/importer.h | 31 ++++++++++++++++ lib/Makefile.am | 3 +- lib/importer.c | 79 ++++++++++++++++++++++++++++++++++++++++ mkfs/main.c | 44 ++++++---------------- 4 files changed, 123 insertions(+), 34 deletions(-) create mode 100644 include/erofs/importer.h create mode 100644 lib/importer.c
include/erofs/importer.h new file +31 -0
@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0+ OR Apache-2.0 */ +/* +* Copyright (C) 2025 Alibaba Cloud +*/ +#ifndef __EROFS_IMPORTER_H +#define __EROFS_IMPORTER_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "internal.h" + +struct erofs_importer_params { +}; + +struct erofs_importer { +struct erofs_importer_params *params; +struct erofs_sb_info *sbi; +}; + +void erofs_importer_preset (struct erofs_importer_params *params); +int erofs_importer_init (struct erofs_importer *im); +void erofs_importer_exit (struct erofs_importer *im); + +#ifdef __cplusplus +} +#endif + +#endif
lib/Makefile.am +2 -1
@@ -27,6 +27,7 @@ noinst_HEADERS = $(top_srcdir)/include/erofs_fs.h \ $(top_srcdir)/include/erofs/compress_hints.h \ $(top_srcdir)/include/erofs/fragments.h \ $(top_srcdir)/include/erofs/rebuild.h \ + $(top_srcdir)/include/erofs/importer.h \ $(top_srcdir)/lib/liberofs_private.h \ $(top_srcdir)/lib/liberofs_xxhash.h \ $(top_srcdir)/lib/liberofs_metabox.h \
@@ -38,7 +39,7 @@ liberofs_la_SOURCES = config.c io.c cache.c super.c inode.c xattr.c exclude.c \ compress_hints.c hashmap.c sha256.c blobchunk.c dir.c \ fragments.c dedupe.c uuid_unparse.c uuid.c tar.c \ block_list.c rebuild.c diskbuf.c bitops.c dedupe_ext.c \ - vmdk.c metabox.c global.c + vmdk.c metabox.c global.c importer.c liberofs_la_CFLAGS = -Wall ${libuuid_CFLAGS} -I$(top_srcdir)/include if ENABLE_LZ4
lib/importer.c new file +79 -0
79 lines not on this page · raw message
mkfs/main.c +11 -33
101 lines not on this page · raw message
Signature · 1 line
2.43.5
PATCH 3/7 erofs-utils: lib: adapt importer for filesystem tree dumping
In reply to Gao XiangConvert erofs_mkfs_build_tree_from_path() and erofs_rebuild_dump_tree() to erofs_importer_load_tree().
--- include/erofs/importer.h | 2 ++ include/erofs/inode.h | 7 ++-- lib/inode.c | 76 ++++++++++++++-------------------------- mkfs/main.c | 16 +++++---- 4 files changed, 43 insertions(+), 58 deletions(-)
include/erofs/importer.h +2 -0
@@ -13,11 +13,13 @@ extern "C"#include "internal.h" struct erofs_importer_params { +char *source; };struct erofs_importer {struct erofs_importer_params *params;struct erofs_sb_info *sbi; +struct erofs_inode *root; };void erofs_importer_preset (struct erofs_importer_params *params);
include/erofs/inode.h +4 -3
@@ -23,6 +23,8 @@ static inline struct erofs_inode *erofs_igrab(struct erofs_inode *inode)return inode; } +struct erofs_importer ; +u32 erofs_new_encode_dev (dev_t dev);unsigned char erofs_mode_to_ftype (umode_t mode);umode_t erofs_ftype_to_mode (unsigned int ftype,unsigned int perm);
@@ -38,12 +40,11 @@ struct erofs_dentry *erofs_d_alloc(struct erofs_inode *parent, const char *name);int erofs_allocate_inode_bh_data (struct erofs_inode *inode,erofs_blk_t nblocks);bool erofs_dentry_is_wht (struct erofs_sb_info *sbi,struct erofs_dentry *d); -int erofs_rebuild_dump_tree (struct erofs_inode *dir,bool incremental);int __erofs_fill_inode (struct erofs_inode *inode,struct stat *st,const char *path);struct erofs_inode *erofs_new_inode (struct erofs_sb_info *sbi); -struct erofs_inode *erofs_mkfs_build_tree_from_path (struct erofs_sb_info *sbi, -const char *path); +int erofs_importer_load_tree (struct erofs_importer *im,bool rebuild, +bool incremental);struct erofs_inode *erofs_mkfs_build_special_from_fd (struct erofs_sb_info *sbi,int fd,const char *name);int erofs_fixup_root_inode (struct erofs_inode *root);
lib/inode.c +27 -49
131 lines not on this page · raw message
mkfs/main.c +10 -6
@@ -1542,6 +1542,7 @@ int main(int argc, char **argv)#endif erofs_show_config (); + importer_params.source = cfg.c_src_path; err =erofs_importer_init (&importer);if (err) goto exit;
@@ -1694,12 +1695,12 @@ int main(int argc, char **argv)if (cfg.c_extra_ea_name_prefixes)erofs_xattr_flush_name_prefixes (&g_sbi); - root =erofs_mkfs_build_tree_from_path (&g_sbi, cfg.c_src_path); + root =erofs_new_inode (&g_sbi);if (IS_ERR (root)) { err =PTR_ERR (root); - root =NULL ; goto exit; } + incremental_mode = false; }else { root =erofs_rebuild_make_root (&g_sbi);if (IS_ERR (root)) {
@@ -1740,12 +1741,15 @@ int main(int argc, char **argv) goto exit;#endif } - - err =erofs_rebuild_dump_tree (root, incremental_mode); -if (err) - goto exit; } + importer.root = root; + err =erofs_importer_load_tree (&importer, + source_mode !=EROFS_MKFS_SOURCE_LOCALDIR , + incremental_mode); +if (err) + goto exit; +if (tar_index_512b) {if (!g_sbi.extra_devices) {DBG_BUGON (1 );
Signature · 1 line
2.43.5
PATCH 4/7 erofs-utils: lib: make `c_inline_data` an importer parameter
In reply to Gao XiangMove c_inline_data from the global configuration structure to an importer-specific parameter.
--- include/erofs/config.h | 1 - include/erofs/fragments.h | 4 +- include/erofs/importer.h | 1 + include/erofs/inode.h | 2 +- include/erofs/tar.h | 4 +- lib/fragments.c | 6 ++- lib/inode.c | 88 +++++++++++++++++++++------------------ lib/liberofs_metabox.h | 4 +- lib/liberofs_s3.h | 2 +- lib/metabox.c | 6 ++- lib/remotes/s3.c | 13 +++--- lib/tar.c | 11 +++-- mkfs/main.c | 17 ++++---- 13 files changed, 92 insertions(+), 67 deletions(-)
include/erofs/config.h +0 -1
@@ -54,7 +54,6 @@ struct erofs_configure {bool c_legacy_compress;char c_timeinherit;char c_chunkbits; -bool c_inline_data;bool c_ztailpacking;bool c_fragments;bool c_all_fragments;
include/erofs/fragments.h +3 -1
@@ -20,6 +20,8 @@ static inline bool erofs_is_packed_inode(struct erofs_inode *inode)return inode->i_srcpath ==EROFS_PACKED_INODE ; } +struct erofs_importer ; +u32 z_erofs_fragments_tofh (struct erofs_inode *inode,int fd,erofs_off_t fpos);int erofs_fragment_findmatch (struct erofs_inode *inode,int fd,u32 tofh);
@@ -27,7 +29,7 @@ int erofs_pack_file_from_fd(struct erofs_inode *inode, int fd, u32 tofcrc);int erofs_fragment_pack (struct erofs_inode *inode,void *data,erofs_off_t pos,erofs_off_t len,u32 tofh,bool tail);int erofs_fragment_commit (struct erofs_inode *inode,u32 tofh); -int erofs_flush_packed_inode (struct erofs_sb_info *sbi); +int erofs_flush_packed_inode (struct erofs_importer *im);int erofs_packedfile (struct erofs_sb_info *sbi);int erofs_packedfile_init (struct erofs_sb_info *sbi,bool fragments_mkfs);
include/erofs/importer.h +1 -0
@@ -14,6 +14,7 @@ extern "C"struct erofs_importer_params {char *source; +bool no_datainline; };struct erofs_importer {
include/erofs/inode.h +1 -1
@@ -45,7 +45,7 @@ int __erofs_fill_inode(struct erofs_inode *inode, struct stat *st,struct erofs_inode *erofs_new_inode (struct erofs_sb_info *sbi);int erofs_importer_load_tree (struct erofs_importer *im,bool rebuild,bool incremental); -struct erofs_inode *erofs_mkfs_build_special_from_fd (struct erofs_sb_info *sbi, +struct erofs_inode *erofs_mkfs_build_special_from_fd (struct erofs_importer *im,int fd,const char *name);int erofs_fixup_root_inode (struct erofs_inode *root);struct erofs_inode *erofs_rebuild_make_root (struct erofs_sb_info *sbi);
include/erofs/tar.h +3 -1
@@ -55,9 +55,11 @@ struct erofs_tarfile {bool try_no_reorder; }; +struct erofs_importer ; +void erofs_iostream_close (struct erofs_iostream *ios);int erofs_iostream_open (struct erofs_iostream *ios,int fd,int decoder); -int tarerofs_parse_tar (struct erofs_inode *root,struct erofs_tarfile *tar); +int tarerofs_parse_tar (struct erofs_importer *im,struct erofs_tarfile *tar); #ifdef __cplusplus }
lib/fragments.c +4 -2
@@ -20,6 +20,7 @@#include "erofs/fragments.h" #include "erofs/bitops.h" #include "erofs/lock.h" +#include "erofs/importer.h" #include "liberofs_private.h" #ifdef HAVE_SYS_SENDFILE_H #include <sys/sendfile.h>
@@ -370,8 +371,9 @@ int erofs_fragment_commit(struct erofs_inode *inode, u32 tofh)return 0 ; } -int erofs_flush_packed_inode (struct erofs_sb_info *sbi) +int erofs_flush_packed_inode (struct erofs_importer *im) { +struct erofs_sb_info *sbi = im->sbi;struct erofs_packed_inode *epi = sbi->packedinode;struct erofs_inode *inode;
@@ -380,7 +382,7 @@ int erofs_flush_packed_inode(struct erofs_sb_info *sbi)if (lseek (epi->fd,0 ,SEEK_CUR ) <=0 )return 0 ; - inode =erofs_mkfs_build_special_from_fd (sbi, epi->fd, + inode =erofs_mkfs_build_special_from_fd (im, epi->fd,EROFS_PACKED_INODE ); sbi->packed_nid =erofs_lookupnid (inode);erofs_iput (inode);
lib/inode.c +47 -41
252 lines not on this page · raw message
lib/liberofs_metabox.h +3 -1
@@ -12,9 +12,11 @@ static inline bool erofs_is_metabox_inode(struct erofs_inode *inode) return inode->i_srcpath == EROFS_METABOX_INODE; } +struct erofs_importer ; +void erofs_metabox_exit (struct erofs_sb_info *sbi);int erofs_metabox_init (struct erofs_sb_info *sbi);struct erofs_bufmgr *erofs_metabox_bmgr (struct erofs_sb_info *sbi); -int erofs_metabox_iflush (struct erofs_sb_info *sbi); +int erofs_metabox_iflush (struct erofs_importer *im);#endif
lib/liberofs_s3.h +1 -1
@@ -34,7 +34,7 @@ struct erofs_s3 {enum s3erofs_signature_version sig; }; -int s3erofs_build_trees (struct erofs_inode *root,struct erofs_s3 *s3, +int s3erofs_build_trees (struct erofs_importer *im,struct erofs_s3 *s3,const char *path,bool fillzero);#ifdef __cplusplus
lib/metabox.c +4 -2
@@ -2,6 +2,7 @@#include <stdlib.h> #include "erofs/cache.h" #include "erofs/inode.h" +#include "erofs/importer.h" #include "liberofs_private.h" #include "liberofs_metabox.h"
@@ -55,8 +56,9 @@ struct erofs_bufmgr *erofs_metabox_bmgr(struct erofs_sb_info *sbi)return sbi->m2gr ? sbi->m2gr->bmgr :NULL ; } -int erofs_metabox_iflush (struct erofs_sb_info *sbi) +int erofs_metabox_iflush (struct erofs_importer *im) { +struct erofs_sb_info *sbi = im->sbi;struct erofs_metaboxmgr *m2gr = sbi->m2gr;struct erofs_inode *inode;int err;
@@ -70,7 +72,7 @@ int erofs_metabox_iflush(struct erofs_sb_info *sbi)if (erofs_io_lseek (&m2gr->vf,0 ,SEEK_END ) <=0 )return 0 ; - inode =erofs_mkfs_build_special_from_fd (sbi, m2gr->vf.fd, + inode =erofs_mkfs_build_special_from_fd (im, m2gr->vf.fd,EROFS_METABOX_INODE ); sbi->metabox_nid =erofs_lookupnid (inode);erofs_iput (inode);
lib/remotes/s3.c +8 -5
@@ -17,6 +17,7 @@#include "erofs/blobchunk.h" #include "erofs/diskbuf.h" #include "erofs/rebuild.h" +#include "erofs/importer.h" #include "liberofs_s3.h" #define S3EROFS_PATH_MAX 1024
@@ -598,7 +599,8 @@ static size_t s3erofs_remote_getobject_cb(void *contents, size_t size,return realsize; } -static int s3erofs_remote_getobject (struct erofs_s3 *s3, +static int s3erofs_remote_getobject (struct erofs_importer *im, +struct erofs_s3 *s3,struct erofs_inode *inode,const char *bucket,const char *key) {
@@ -621,7 +623,7 @@ static int s3erofs_remote_getobject(struct erofs_s3 *s3,return -EIO ; resp.pos =0 ; -if (!cfg.c_compr_opts[0 ].alg && !cfg.c_inline_data) { +if (!cfg.c_compr_opts[0 ].alg && im->params->no_datainline) { inode->datalayout =EROFS_INODE_FLAT_PLAIN ; inode->idata_size =0 ; ret = erofs_allocate_inode_bh_data(inode,
@@ -666,10 +668,11 @@ static int s3erofs_remote_getobject(struct erofs_s3 *s3,return resp.pos != resp.end ? -EIO :0 ; } -int s3erofs_build_trees (struct erofs_inode *root,struct erofs_s3 *s3, +int s3erofs_build_trees (struct erofs_importer *im,struct erofs_s3 *s3,const char *path,bool fillzero) { -struct erofs_sb_info *sbi = root->sbi; +struct erofs_sb_info *sbi = im->sbi; +struct erofs_inode *root = im->root;struct s3erofs_object_iterator *iter;struct s3erofs_object_info *obj;struct erofs_dentry *d;
@@ -747,7 +750,7 @@ int s3erofs_build_trees(struct erofs_inode *root, struct erofs_s3 *s3,if (fillzero) ret =erofs_write_zero_inode (inode);else - ret =s3erofs_remote_getobject (s3, inode, + ret =s3erofs_remote_getobject (im, s3, inode, iter->bucket, obj->key); }if (ret)
lib/tar.c +7 -4
@@ -12,6 +12,7 @@#include "erofs/xattr.h" #include "erofs/blobchunk.h" #include "erofs/rebuild.h" +#include "erofs/importer.h" #if defined(HAVE_ZLIB )#include <zlib.h> #endif
@@ -704,12 +705,14 @@ static int tarerofs_write_file_data(struct erofs_inode *inode,return 0 ; } -int tarerofs_parse_tar (struct erofs_inode *root,struct erofs_tarfile *tar) +int tarerofs_parse_tar (struct erofs_importer *im,struct erofs_tarfile *tar) { -char path[PATH_MAX ];struct erofs_pax_header eh = tar->global; -struct erofs_sb_info *sbi = root->sbi; +struct erofs_importer_params *params = im->params; +struct erofs_sb_info *sbi = im->sbi; +struct erofs_inode *root = im->root;bool whout, opq, e = false; +char path[PATH_MAX ];struct stat st;mode_t mode;erofs_off_t tar_offset, dataoff;
@@ -1112,7 +1115,7 @@ new_inode: ret = -EIO ; }else if (tar->try_no_reorder && !cfg.c_compr_opts[0 ].alg && - !cfg.c_inline_data) { + params->no_datainline) { ret =tarerofs_write_uncompressed_file (inode, tar); }else { ret =tarerofs_write_file_data (inode, tar);
mkfs/main.c +10 -7
@@ -397,6 +397,8 @@ static struct { {NULL, NULL}, }; +static bool mkfs_no_datainline; +static int parse_extended_opts (const char *opts) {#define MATCH_EXTENTED_OPT (opt, token, keylen) \
@@ -455,11 +457,11 @@ static int parse_extended_opts(const char *opts) }else if (MATCH_EXTENTED_OPT ("noinline_data" , token, keylen)) {if (vallen)return -EINVAL ; - cfg.c_inline_data = false; + mkfs_no_datainline = true; }else if (MATCH_EXTENTED_OPT ("inline_data" , token, keylen)) {if (vallen)return -EINVAL ; - cfg.c_inline_data = !clear; + mkfs_no_datainline = !!clear; }else if (MATCH_EXTENTED_OPT ("force-inode-blockmap" , token, keylen)) {if (vallen)return -EINVAL ;
@@ -1328,7 +1330,6 @@ static void erofs_mkfs_default_options(void) { cfg.c_showprogress = true; cfg.c_legacy_compress = false; - cfg.c_inline_data = true; cfg.c_xattr_name_filter = true;#ifdef EROFS_MT_ENABLED cfg.c_mt_workers =erofs_get_available_processors ();
@@ -1543,6 +1544,8 @@ int main(int argc, char **argv)erofs_show_config (); importer_params.source = cfg.c_src_path; + importer_params.no_datainline = mkfs_no_datainline; + err =erofs_importer_init (&importer);if (err) goto exit;
@@ -1709,7 +1712,7 @@ int main(int argc, char **argv) }if (source_mode ==EROFS_MKFS_SOURCE_TAR ) { -while (!(err =tarerofs_parse_tar (root, &erofstar))) +while (!(err =tarerofs_parse_tar (&importer, &erofstar))) ;if (err <0 ) goto exit;
@@ -1734,7 +1737,7 @@ int main(int argc, char **argv) dataimport_mode == EROFS_MKFS_DATA_IMPORT_RVSP) err = -EOPNOTSUPP ; else - err =s3erofs_build_trees (root, &s3cfg, + err =s3erofs_build_trees (&importer, &s3cfg, cfg.c_src_path, dataimport_mode ==EROFS_MKFS_DATA_IMPORT_ZEROFILL );if (err)
@@ -1763,7 +1766,7 @@ int main(int argc, char **argv)if (erofs_sb_has_metabox (&g_sbi)) {erofs_update_progressinfo ("Handling metabox ..." ); -erofs_metabox_iflush (&g_sbi); +erofs_metabox_iflush (&importer);if (err) goto exit; }
@@ -1771,7 +1774,7 @@ int main(int argc, char **argv)if ((cfg.c_fragments || cfg.c_extra_ea_name_prefixes) &&erofs_sb_has_fragments (&g_sbi)) {erofs_update_progressinfo ("Handling packed data ..." ); - err =erofs_flush_packed_inode (&g_sbi); + err =erofs_flush_packed_inode (&importer);if (err) goto exit; }
Signature · 1 line
2.43.5
PATCH 5/7 erofs-utils: lib: migrate `c_mt_async_queue_limit`
In reply to Gao Xiang--- include/erofs/config.h | 1 - include/erofs/importer.h | 1 + lib/inode.c | 9 +++++++-- mkfs/main.c | 7 ++++--- 4 files changed, 12 insertions(+), 6 deletions(-)
include/erofs/config.h +0 -1
@@ -94,7 +94,6 @@ struct erofs_configure {#ifdef EROFS_MT_ENABLED u64 c_mkfs_segment_size;u32 c_mt_workers; -u32 c_mt_async_queue_limit;#endif #ifdef WITH_ANDROID char *target_out_path;
include/erofs/importer.h +1 -0
@@ -14,6 +14,7 @@ extern "C"struct erofs_importer_params {char *source; +u32 mt_async_queue_limit;bool no_datainline; };
lib/inode.c +7 -2
@@ -2023,6 +2023,7 @@ static int erofs_get_fdlimit(void)static int erofs_mkfs_build_tree (struct erofs_mkfs_buildtree_ctx *ctx) {struct erofs_importer *im = ctx->im; +struct erofs_importer_params *params = im->params;struct erofs_sb_info *sbi = im->sbi;struct erofs_mkfs_dfops *q;int err, err2;
@@ -2032,8 +2033,12 @@ static int erofs_mkfs_build_tree(struct erofs_mkfs_buildtree_ctx *ctx)if (!q)return -ENOMEM ; -if (cfg.c_mt_async_queue_limit) { - q->entries = cfg.c_mt_async_queue_limit; +if (params->mt_async_queue_limit) { + q->entries = params->mt_async_queue_limit; +if (q->entries & (q->entries -1 )) { +free (q); +return -EINVAL ; + } }else { err =roundup_pow_of_two (erofs_get_fdlimit ()) >>1 ; q->entries = err && err <32768 ? err :32768 ;
mkfs/main.c +4 -3
@@ -860,7 +860,8 @@ static int mkfs_parse_sources(int argc, char *argv[], int optind)return 0 ; } -static int mkfs_parse_options_cfg (int argc,char *argv[]) +static int mkfs_parse_options_cfg (struct erofs_importer_params *params, +int argc,char *argv[]) {char *endptr;int opt, i, err;
@@ -1195,7 +1196,7 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])break ;#ifdef EROFS_MT_ENABLED case 530 : - cfg.c_mt_async_queue_limit =strtoul (optarg, &endptr,0 ); + params->mt_async_queue_limit =strtoul (optarg, &endptr,0 );if (*endptr !='\0' ) {erofs_err ("invalid async-queue-limit %s" , optarg);return -EINVAL ;
@@ -1497,7 +1498,7 @@ int main(int argc, char **argv)erofs_mkfs_default_options ();erofs_importer_preset (&importer_params); - err =mkfs_parse_options_cfg (argc, argv); + err =mkfs_parse_options_cfg (&importer_params, argc, argv);erofs_show_progs (argc, argv);if (err) {if (err == -EINVAL )
Signature · 1 line
2.43.5
PATCH 6/7 erofs-utils: lib: migrate `c_[ug]id` and `c_[ug]id_offset`
In reply to Gao Xiang--- include/erofs/config.h | 2 -- include/erofs/importer.h | 4 ++++ include/erofs/inode.h | 4 ++-- lib/config.c | 2 -- lib/importer.c | 5 ++++- lib/inode.c | 40 +++++++++++++++++++++------------------- lib/remotes/s3.c | 2 +- lib/tar.c | 2 +- mkfs/main.c | 14 +++++++------- 9 files changed, 40 insertions(+), 35 deletions(-)
include/erofs/config.h +0 -2
@@ -87,9 +87,7 @@ struct erofs_configure {s32 c_mkfs_pclustersize_metabox;u32 c_max_decompressed_extent_bytes;u64 c_unix_timestamp; -u32 c_uid, c_gid;const char *mount_point; -long long c_uid_offset, c_gid_offset;u32 c_root_xattr_isize;#ifdef EROFS_MT_ENABLED u64 c_mkfs_segment_size;
include/erofs/importer.h +4 -0
@@ -15,6 +15,10 @@ extern "C"struct erofs_importer_params {char *source;u32 mt_async_queue_limit; +u32 fixed_uid; +u32 fixed_gid; +u32 uid_offset; +u32 gid_offset;bool no_datainline; };
include/erofs/inode.h +2 -2
@@ -40,8 +40,8 @@ struct erofs_dentry *erofs_d_alloc(struct erofs_inode *parent, const char *name);int erofs_allocate_inode_bh_data (struct erofs_inode *inode,erofs_blk_t nblocks);bool erofs_dentry_is_wht (struct erofs_sb_info *sbi,struct erofs_dentry *d); -int __erofs_fill_inode (struct erofs_inode *inode,struct stat *st, -const char *path); +int __erofs_fill_inode (struct erofs_importer *im,struct erofs_inode *inode, +struct stat *st,const char *path);struct erofs_inode *erofs_new_inode (struct erofs_sb_info *sbi);int erofs_importer_load_tree (struct erofs_importer *im,bool rebuild,bool incremental);
lib/config.c +0 -2
@@ -33,8 +33,6 @@ void erofs_init_configure(void) cfg.c_force_inodeversion =0 ; cfg.c_inline_xattr_tolerance =2 ; cfg.c_unix_timestamp =-1 ; - cfg.c_uid =-1 ; - cfg.c_gid =-1 ; cfg.c_max_decompressed_extent_bytes =-1 ; cfg.c_mkfs_pclustersize_metabox =-1 ; erofs_stdout_tty =isatty (STDOUT_FILENO );
lib/importer.c +4 -1
@@ -16,7 +16,10 @@ static bool erofs_importer_global_initialized;void erofs_importer_preset (struct erofs_importer_params *params) { - *params = (struct erofs_importer_params ) {}; + *params = (struct erofs_importer_params ) { + .fixed_uid =-1 , + .fixed_gid =-1 , + }; }void erofs_importer_global_init (void )
lib/inode.c +21 -19
@@ -1160,25 +1160,27 @@ static int erofs_droid_inode_fsconfig(struct erofs_inode *inode, }#endif -int __erofs_fill_inode (struct erofs_inode *inode,struct stat *st, -const char *path) +int __erofs_fill_inode (struct erofs_importer *im,struct erofs_inode *inode, +struct stat *st,const char *path) { -int err =erofs_droid_inode_fsconfig (inode, st, path); +struct erofs_importer_params *params = im->params;struct erofs_sb_info *sbi = inode->sbi; +int err; + err =erofs_droid_inode_fsconfig (inode, st, path);if (err)return err; - inode->i_uid = cfg.c_uid ==-1 ? st->st_uid : cfg.c_uid; - inode->i_gid = cfg.c_gid ==-1 ? st->st_gid : cfg.c_gid; + inode->i_uid = params->fixed_uid ==-1 ? st->st_uid : params->fixed_uid; + inode->i_gid = params->fixed_gid ==-1 ? st->st_gid : params->fixed_gid; -if (inode->i_uid + cfg.c_uid_offset <0 ) +if ((u32)(inode->i_uid + params->uid_offset) < inode->i_uid)erofs_err ("uid overflow @ %s" , path); - inode->i_uid += cfg.c_uid_offset; + inode->i_uid += params->uid_offset; -if (inode->i_gid + cfg.c_gid_offset <0 ) +if ((u32)(inode->i_gid + params->gid_offset) < inode->i_gid)erofs_err ("gid overflow @ %s" , path); - inode->i_gid += cfg.c_gid_offset; + inode->i_gid += params->gid_offset;if (erofs_is_special_identifier (path)) { inode->i_mtime = sbi->epoch + sbi->build_time;
@@ -1201,10 +1203,10 @@ int __erofs_fill_inode(struct erofs_inode *inode, struct stat *st,return 0 ; } -static int erofs_fill_inode (struct erofs_inode *inode,struct stat *st, -const char *path) +static int erofs_fill_inode (struct erofs_importer *im,struct erofs_inode *inode, +struct stat *st,const char *path) { -int err =__erofs_fill_inode (inode, st, path); +int err =__erofs_fill_inode (im, inode, st, path);if (err)return err;
@@ -1278,11 +1280,12 @@ struct erofs_inode *erofs_new_inode(struct erofs_sb_info *sbi)return inode; } -static struct erofs_inode *erofs_iget_from_local (struct erofs_sb_info *sbi, +static struct erofs_inode *erofs_iget_from_local (struct erofs_importer *im,const char *path) { -struct stat st; +struct erofs_sb_info *sbi = im->sbi;struct erofs_inode *inode; +struct stat st;int ret; ret =lstat (path, &st);
@@ -1305,7 +1308,7 @@ static struct erofs_inode *erofs_iget_from_local(struct erofs_sb_info *sbi,if (IS_ERR (inode))return inode; - ret =erofs_fill_inode (inode, &st, path); + ret =erofs_fill_inode (im, inode, &st, path);if (ret) {erofs_iput (inode);return ERR_PTR (ret);
@@ -1597,7 +1600,6 @@ static void erofs_mkfs_flushjobs(struct erofs_sb_info *sbi)static int erofs_mkfs_handle_directory (struct erofs_importer *im,struct erofs_inode *dir) { -struct erofs_sb_info *sbi = im->sbi;DIR *_dir;struct dirent *dp;struct erofs_dentry *d;
@@ -1649,7 +1651,7 @@ static int erofs_mkfs_handle_directory(struct erofs_importer *im, struct erofs_iif (ret <0 || ret >=PATH_MAX ) goto err_closedir; - inode =erofs_iget_from_local (sbi, buf); + inode =erofs_iget_from_local (im, buf);if (IS_ERR (inode)) { ret =PTR_ERR (inode); goto err_closedir;
@@ -1990,7 +1992,7 @@ static int __erofs_mkfs_build_tree(struct erofs_mkfs_buildtree_ctx *ctx)if (err)return -errno; - err =erofs_fill_inode (im->root, &st, params->source); + err =erofs_fill_inode (im, im->root, &st, params->source);if (err)return err; }
@@ -2118,7 +2120,7 @@ struct erofs_inode *erofs_mkfs_build_special_from_fd(struct erofs_importer *im, st.st_nlink =0 ; } - ret =erofs_fill_inode (inode, &st, name); + ret =erofs_fill_inode (im, inode, &st, name);if (ret) {free (inode);return ERR_PTR (ret);
lib/remotes/s3.c +1 -1
@@ -744,7 +744,7 @@ int s3erofs_build_trees(struct erofs_importer *im, struct erofs_s3 *s3, st.st_mtime = obj->mtime;ST_MTIM_NSEC_SET (&st, obj->mtime_ns); - ret =__erofs_fill_inode (inode, &st, obj->key); + ret =__erofs_fill_inode (im, inode, &st, obj->key);if (!ret &&S_ISREG (inode->i_mode)) { inode->i_size = obj->size;if (fillzero)
lib/tar.c +1 -1
@@ -1079,7 +1079,7 @@ new_inode: goto out; } - ret =__erofs_fill_inode (inode, &st, eh.path); + ret =__erofs_fill_inode (im, inode, &st, eh.path);if (ret) goto out; inode->i_size = st.st_size;
mkfs/main.c +7 -7
@@ -963,21 +963,21 @@ static int mkfs_parse_options_cfg(struct erofs_importer_params *params,return opt;break ;case 5 : - cfg.c_uid =strtoul (optarg, &endptr,0 ); -if (cfg.c_uid ==-1 || *endptr !='\0' ) { + params->fixed_uid =strtoul (optarg, &endptr,0 ); +if (params->fixed_uid ==-1 || *endptr !='\0' ) {erofs_err ("invalid uid %s" , optarg);return -EINVAL ; }break ;case 6 : - cfg.c_gid =strtoul (optarg, &endptr,0 ); -if (cfg.c_gid ==-1 || *endptr !='\0' ) { + params->fixed_gid =strtoul (optarg, &endptr,0 ); +if (params->fixed_gid ==-1 || *endptr !='\0' ) {erofs_err ("invalid gid %s" , optarg);return -EINVAL ; }break ;case 7 : - cfg.c_uid = cfg.c_gid =0 ; + params->fixed_uid = params->fixed_gid =0 ;break ;#ifndef NDEBUG case 8 :
@@ -1070,7 +1070,7 @@ static int mkfs_parse_options_cfg(struct erofs_importer_params *params,break ;case 16 : errno =0 ; - cfg.c_uid_offset =strtoll (optarg, &endptr,0 ); + params->uid_offset =strtoul (optarg, &endptr,0 );if (errno || *endptr !='\0' ) {erofs_err ("invalid uid offset %s" , optarg);return -EINVAL ;
@@ -1078,7 +1078,7 @@ static int mkfs_parse_options_cfg(struct erofs_importer_params *params,break ;case 17 : errno =0 ; - cfg.c_gid_offset =strtoll (optarg, &endptr,0 ); + params->gid_offset =strtoul (optarg, &endptr,0 );if (errno || *endptr !='\0' ) {erofs_err ("invalid gid offset %s" , optarg);return -EINVAL ;
Signature · 1 line
2.43.5
PATCH 7/7 erofs-utils: lib: migrate `c_{ovlfs_strip,hard_dereference,dot_omitted}`
In reply to Gao Xiang--- include/erofs/config.h | 3 --- include/erofs/importer.h | 3 +++ lib/inode.c | 23 ++++++++++++----------- mkfs/main.c | 17 ++++++++--------- 4 files changed, 23 insertions(+), 23 deletions(-)
include/erofs/config.h +0 -3
@@ -63,9 +63,6 @@ struct erofs_configure {bool c_showprogress;bool c_extra_ea_name_prefixes;bool c_xattr_name_filter; -bool c_ovlfs_strip; -bool c_hard_dereference; -bool c_dot_omitted;#ifdef HAVE_LIBSELINUX struct selabel_handle *sehnd;
include/erofs/importer.h +3 -0
@@ -20,6 +20,9 @@ struct erofs_importer_params {u32 uid_offset;u32 gid_offset;bool no_datainline; +bool hard_dereference; +bool ovlfs_strip; +bool dot_omitted; };struct erofs_importer {
lib/inode.c +12 -11
@@ -297,15 +297,15 @@ static void erofs_dentry_mergesort(struct list_head *entries, int k)list_add_tail (great, entries); } -static int erofs_prepare_dir_file (struct erofs_inode *dir, -unsigned int nr_subdirs) +static int erofs_prepare_dir_file (struct erofs_importer *im, +struct erofs_inode *dir,unsigned int nr_subdirs) { -bool dot_omitted = cfg.c_dot_omitted; +const struct erofs_importer_params *params = im->params;struct erofs_sb_info *sbi = dir->sbi;struct erofs_dentry *d;unsigned int d_size =0 ; -if (!dot_omitted) { +if (!params->dot_omitted) {/* dot is pointed to the current dir inode */ d =erofs_d_alloc (dir,"." );if (IS_ERR (d))
@@ -313,7 +313,7 @@ static int erofs_prepare_dir_file(struct erofs_inode *dir, d->inode =erofs_igrab (dir); d->type =EROFS_FT_DIR ; } - dir->dot_omitted = dot_omitted; + dir->dot_omitted = params->dot_omitted;/* dotdot is pointed to the parent dir */ d =erofs_d_alloc (dir,".." );
@@ -324,7 +324,7 @@ static int erofs_prepare_dir_file(struct erofs_inode *dir,if (nr_subdirs)erofs_dentry_mergesort (&dir->i_subdirs,0 ); - nr_subdirs +=1 + !dot_omitted; + nr_subdirs +=1 + !params->dot_omitted;/* let's calculate dir size */ list_for_each_entry (d, &dir->i_subdirs, d_child) {
@@ -1297,7 +1297,7 @@ static struct erofs_inode *erofs_iget_from_local(struct erofs_importer *im,* hard-link, just return it. Also don't lookup for directories * since hard-link directory isn't allowed. */ -if (!S_ISDIR (st.st_mode) && (!cfg.c_hard_dereference)) { +if (!S_ISDIR (st.st_mode) && !im->params->hard_dereference) { inode =erofs_iget (st.st_dev, st.st_ino);if (inode)return inode;
@@ -1664,7 +1664,7 @@ static int erofs_mkfs_handle_directory(struct erofs_importer *im, struct erofs_i }closedir (_dir); - ret =erofs_prepare_dir_file (dir, nr_subdirs);/* sort subdirs */ + ret =erofs_prepare_dir_file (im, dir, nr_subdirs);/* sort subdirs */ if (ret)return ret;
@@ -1725,7 +1725,7 @@ static int erofs_rebuild_handle_directory(struct erofs_importer *im,struct erofs_sb_info *sbi = im->sbi;struct erofs_dentry *d, *n;unsigned int nr_subdirs, i_nlink; -bool delwht = cfg.c_ovlfs_strip && dir->whiteouts; +bool delwht = im->params->ovlfs_strip && dir->whiteouts;int ret; nr_subdirs =0 ;
@@ -1746,7 +1746,7 @@ static int erofs_rebuild_handle_directory(struct erofs_importer *im, ++nr_subdirs; }DBG_BUGON (nr_subdirs +2 < i_nlink); - ret =erofs_prepare_dir_file (dir, nr_subdirs); + ret =erofs_prepare_dir_file (im, dir, nr_subdirs);if (ret)return ret;
@@ -1813,6 +1813,7 @@ static int erofs_mkfs_handle_inode(struct erofs_importer *im,static int erofs_rebuild_handle_inode (struct erofs_importer *im,struct erofs_inode *inode,bool incremental) { +struct erofs_importer_params *params = im->params;char *trimmed;int ret;
@@ -1840,7 +1841,7 @@ static int erofs_rebuild_handle_inode(struct erofs_importer *im, }/* strip all unnecessary overlayfs xattrs when ovlfs_strip is enabled */ -if (cfg.c_ovlfs_strip) +if (params->ovlfs_strip)erofs_clear_opaque_xattr (inode);else if (inode->whiteouts)erofs_set_origin_xattr (inode);
mkfs/main.c +8 -9
@@ -372,13 +372,15 @@ static int erofs_mkfs_feat_set_48bit(bool en, const char *val,return 0 ; } +static bool mkfs_dot_omitted; +static int erofs_mkfs_feat_set_dot_omitted (bool en,const char *val,unsigned int vallen) {if (vallen)return -EINVAL ; - cfg.c_dot_omitted = en; + mkfs_dot_omitted = en;return 0 ; }
@@ -1101,10 +1103,7 @@ static int mkfs_parse_options_cfg(struct erofs_importer_params *params, erofstar.aufs = true;break ;case 516 : -if (!optarg || !strcmp (optarg,"1" )) - cfg.c_ovlfs_strip = true; -else - cfg.c_ovlfs_strip = false; + params->ovlfs_strip = !optarg || !strcmp (optarg,"1" );break ;case 517 : g_sbi.bdev.offset =strtoull (optarg, &endptr,0 );
@@ -1185,7 +1184,7 @@ static int mkfs_parse_options_cfg(struct erofs_importer_params *params, erofstar.try_no_reorder = true;break ;case 528 : - cfg.c_hard_dereference = true; + params->hard_dereference = true;break ;case 529 : dsunit =strtoul (optarg, &endptr,0 );
@@ -1525,9 +1524,6 @@ int main(int argc, char **argv) g_sbi.epoch = mkfs_time; } -if (cfg.c_dot_omitted) -erofs_sb_set_48bit (&g_sbi); - err =erofs_dev_open (&g_sbi, cfg.c_img_path,O_RDWR | (incremental_mode ?0 :O_TRUNC ));if (err) {
@@ -1546,6 +1542,9 @@ int main(int argc, char **argv) importer_params.source = cfg.c_src_path; importer_params.no_datainline = mkfs_no_datainline; + importer_params.dot_omitted = mkfs_dot_omitted; +if (importer_params.dot_omitted) +erofs_sb_set_48bit (&g_sbi); err =erofs_importer_init (&importer);if (err)
Signature · 1 line
2.43.5
PATCH v2 1/7 erofs-utils: lib: introduce liberofs_global_{init,exit}
In reply to Gao XiangCurrently, the codebase only supports a single instance during the entire running time. This will be extended to allow 3rd-party applications to formally use liberofs with multiple instances simultaneously. Therefore, it is necessary to separate global initialization from per-instance initialization.
Another point is that libcurl will be used for other remote backends, so it also needs to be separated from the current S3 backend.
---
v2:
- update the commit message;
- fix non-MT compile error.
include/erofs/internal.h | 3 ++ include/erofs/lock.h | 6 ++++ lib/Makefile.am | 5 ++-- lib/global.c | 55 ++++++++++++++++++++++++++++++++++ lib/liberofs_s3.h | 1 + lib/remotes/s3.c | 65 ++++++++++++++++++---------------------- mkfs/main.c | 22 +++++++------- 7 files changed, 109 insertions(+), 48 deletions(-) create mode 100644 lib/global.c
include/erofs/internal.h +3 -0
@@ -426,6 +426,9 @@ struct erofs_map_dev {unsigned int m_deviceid; }; +int liberofs_global_init (void ); +void liberofs_global_exit (void ); +/* super.c */ int erofs_read_superblock (struct erofs_sb_info *sbi);void erofs_put_super (struct erofs_sb_info *sbi);
include/erofs/lock.h +6 -0
@@ -16,6 +16,9 @@ static inline void erofs_mutex_init(erofs_mutex_t *lock)#define erofs_mutex_lock pthread_mutex_lock#define erofs_mutex_unlock pthread_mutex_unlock +#define EROFS_DEFINE_MUTEX (lock) \ + erofs_mutex_t lock = PTHREAD_MUTEX_INITIALIZER +typedef pthread_rwlock_t erofs_rwsem_t ;static inline void erofs_init_rwsem (erofs_rwsem_t *lock)
@@ -33,6 +36,9 @@ static inline void erofs_mutex_init(erofs_mutex_t *lock) {}static inline void erofs_mutex_lock (erofs_mutex_t *lock) {}static inline void erofs_mutex_unlock (erofs_mutex_t *lock) {} +#define EROFS_DEFINE_MUTEX (lock) \ + erofs_mutex_t lock = {} +typedef struct {}erofs_rwsem_t ;static inline void erofs_init_rwsem (erofs_rwsem_t *lock) {}static inline void erofs_down_read (erofs_rwsem_t *lock) {}
lib/Makefile.am +3 -2
@@ -29,7 +29,8 @@ noinst_HEADERS = $(top_srcdir)/include/erofs_fs.h \ $(top_srcdir)/include/erofs/rebuild.h \ $(top_srcdir)/lib/liberofs_private.h \ $(top_srcdir)/lib/liberofs_xxhash.h \ - $(top_srcdir)/lib/liberofs_metabox.h + $(top_srcdir)/lib/liberofs_metabox.h \ + $(top_srcdir)/lib/liberofs_s3.h noinst_HEADERS += compressor.h liberofs_la_SOURCES = config.c io.c cache.c super.c inode.c xattr.c exclude.c \
@@ -37,7 +38,7 @@ liberofs_la_SOURCES = config.c io.c cache.c super.c inode.c xattr.c exclude.c \ compress_hints.c hashmap.c sha256.c blobchunk.c dir.c \ fragments.c dedupe.c uuid_unparse.c uuid.c tar.c \ block_list.c rebuild.c diskbuf.c bitops.c dedupe_ext.c \ - vmdk.c metabox.c + vmdk.c metabox.c global.c liberofs_la_CFLAGS = -Wall ${libuuid_CFLAGS} -I$(top_srcdir)/include if ENABLE_LZ4
lib/global.c new file +55 -0
55 lines not on this page · raw message
lib/liberofs_s3.h +1 -0
@@ -25,6 +25,7 @@ enum s3erofs_signature_version {#define S3_SECRET_KEY_LEN 256struct erofs_s3 { +void *easy_curl;const char *endpoint;char access_key[S3_ACCESS_KEY_LEN +1 ];char secret_key[S3_SECRET_KEY_LEN +1 ];
lib/remotes/s3.c +29 -36
131 lines not on this page · raw message
mkfs/main.c +12 -10
@@ -1481,10 +1481,12 @@ int main(int argc, char **argv)struct timeval t;FILE *blklst =NULL ;s64 mkfs_time =0 ; -int err =0 ; +int err;u32 crc; -erofs_init_configure (); + err =liberofs_global_init (); +if (err) +return 1 ;erofs_mkfs_default_options (); err =mkfs_parse_options_cfg (argc, argv);
@@ -1492,13 +1494,13 @@ int main(int argc, char **argv)if (err) {if (err == -EINVAL )fprintf (stderr,"Try '%s --help' for more information.\n" , argv[0 ]); -return 1 ; + goto exit; } err =parse_source_date_epoch ();if (err) {fprintf (stderr,"Try '%s --help' for more information.\n" , argv[0 ]); -return 1 ; + goto exit; } g_sbi.fixed_nsec =0 ;
@@ -1521,14 +1523,14 @@ int main(int argc, char **argv) (incremental_mode ? 0 : O_TRUNC));if (err) {fprintf (stderr,"Try '%s --help' for more information.\n" , argv[0 ]); -return 1 ; + goto exit; }#ifdef WITH_ANDROID if (cfg.fs_config_file &&load_canned_fs_config (cfg.fs_config_file) <0 ) {erofs_err ("failed to load fs config %s" , cfg.fs_config_file); -return 1 ; + goto exit; }#endif erofs_show_config ();
@@ -1540,7 +1542,7 @@ int main(int argc, char **argv)if (err) {erofs_err ("failed to initialize packedfile: %s" ,strerror (-err)); -return 1 ; + goto exit; } }
@@ -1549,7 +1551,7 @@ int main(int argc, char **argv)if (err) {erofs_err ("failed to initialize metabox: %s" ,erofs_strerror (err)); -return 1 ; + goto exit; } }
@@ -1687,7 +1689,7 @@ int main(int argc, char **argv)if (cfg.c_chunkbits) { err =erofs_blob_init (cfg.c_blobdev_path,1 << cfg.c_chunkbits);if (err) -return 1 ; + goto exit; }if (tar_index_512b || cfg.c_blobdev_path) {
@@ -1851,7 +1853,6 @@ exit:erofs_xattr_cleanup_name_prefixes ();erofs_rebuild_cleanup ();erofs_diskbuf_exit (); -erofs_exit_configure ();if (source_mode ==EROFS_MKFS_SOURCE_TAR ) {erofs_iostream_close (&erofstar.ios);if (erofstar.ios.dumpfd >=0 )
@@ -1866,5 +1867,6 @@ exit:erofs_update_progressinfo ("Build completed.\n" );erofs_mkfs_showsummaries ();erofs_put_super (&g_sbi); +liberofs_global_exit ();return 0 ; }
Signature · 1 line
2.43.5