Hi Kelvin, On Sat, Nov 20, 2021 at 09:39:17PM -0800, Kelvin Zhang wrote: > EROFS-utils contains several usage of global variables, namely > > 1. int erofs_devfd, stores the file descriptor to open'ed block devices. > This is referened in many places. > 2. struct erofs_sb_info sbi; Stores parsed super block. > > These global variables make embedding erofs library diffcult. To make > library usage easier, a series of 3 patches are drafted to refactor away > the global variables. Each patch has been built and tested by calling > mkfs.erofs and ensure the same output is generated.
Agreed, that is mainly due to fast iterative development. If we consider to export liberofs as a real library, these all needs to be resolved in advance, and it'd be better to stablize all liberofs APIs as well. However, let's postpone this work until 1.4 is out, I have to admit I'm a bit delay of releasing v1.4 due to my busy work. Now I'm working on pre-releasing.. Thanks, Gao Xiang > > Kelvin Zhang (3): > Make erofs_devfd a parameter for most functions > Mark certain callback function pointers as const > Make super block info struct a paramater instead of globals > > Android.bp | 44 +++++++- > dump/main.c | 84 ++++++++------ > fsck/main.c | 90 +++++++++------ > fuse/dir.c | 8 +- > fuse/main.c | 19 ++-- > include/erofs/blobchunk.h | 7 +- > include/erofs/cache.h | 15 +-- > include/erofs/compress.h | 10 +- > include/erofs/config.h | 15 +-- > include/erofs/decompress.h | 5 +- > include/erofs/defs.h | 21 ++++ > include/erofs/inode.h | 9 +- > include/erofs/internal.h | 72 ++++++------ > include/erofs/io.h | 48 +++++--- > include/erofs/iterate.h | 35 ++++++ > include/erofs/xattr.h | 2 +- > iterate/main.c | 51 +++++++++ > lib/blobchunk.c | 11 +- > lib/cache.c | 33 +++--- > lib/compress.c | 104 ++++++++++------- > lib/compressor.c | 9 +- > lib/compressor.h | 13 ++- > lib/compressor_liblzma.c | 4 +- > lib/compressor_lz4.c | 8 +- > lib/compressor_lz4hc.c | 6 +- > lib/config.c | 64 ++++++----- > lib/data.c | 54 +++++---- > lib/decompress.c | 12 +- > lib/inode.c | 129 ++++++++++++--------- > lib/io.c | 74 ++++++------ > lib/iterate.c | 223 +++++++++++++++++++++++++++++++++++++ > lib/namei.c | 44 +++++--- > lib/super.c | 28 ++--- > lib/xattr.c | 10 +- > lib/zmap.c | 92 +++++++++------ > mkfs/main.c | 92 +++++++-------- > 36 files changed, 1069 insertions(+), 476 deletions(-) > create mode 100644 include/erofs/iterate.h > create mode 100644 iterate/main.c > create mode 100644 lib/iterate.c > > -- > 2.34.0.rc2.393.gf8c9666880-goog
