[PATCH v5 2/2] Add API to iterate over inodes in EROFS
Gao Xiang
hsiangkao at linux.alibaba.com
Wed Dec 15 18:14:13 AEDT 2021
Hi Kelvin,
On Tue, Dec 14, 2021 at 09:35:20AM -0800, Kelvin Zhang wrote:
> Change-Id: Ia35708080a72ee204eaaddfc670d3cb8023a078c
> Signed-off-by: Kelvin Zhang <zhangkelvin at google.com>
> ---
In brief, I've taken some time to clean up / polish / enhance such
logic and convert erofsfuse to use it:
https://lore.kernel.org/linux-erofs/20211215070017.83846-1-hsiangkao@linux.alibaba.com
PTAL and check if it helps your own scenario. I didn't update
the original author name, also I updated the license into
GPL-2.0+ OR Apache-2.0 dual license
since Apache-2.0 is incompatible with GPL.
If you have some other concerns, please drop me a word, thanks.
Some minor comments below.
> include/erofs/iterate.h | 46 ++++++++++++
> include/erofs_fs.h | 4 +-
> lib/Makefile.am | 2 +-
> lib/iterate.c | 154 ++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 203 insertions(+), 3 deletions(-)
> create mode 100644 include/erofs/iterate.h
> create mode 100644 lib/iterate.c
>
> diff --git a/include/erofs/iterate.h b/include/erofs/iterate.h
> new file mode 100644
> index 0000000..4e2c783
> --- /dev/null
> +++ b/include/erofs/iterate.h
> @@ -0,0 +1,46 @@
> +// SPDX-License-Identifier: Apache-2.0
> +
> +#ifndef ITERATE_ITERATE
> +#define ITERATE_ITERATE
> +
> +#ifdef __cplusplus
> +extern "C"
> +{
> +#endif
> +
> +
> +#include "erofs/io.h"
> +#include "erofs/print.h"
> +
> +
> +struct erofs_inode_info {
> + const char* name;
const char *name;
> + enum erofs_ftype ftype;
> + struct erofs_inode* inode;
struct erofs_inode *inode;
> + void* arg;
> +};
> +// Callback function for iterating over inodes of EROFS
> +
> +typedef bool (*erofs_readdir_cb)(struct erofs_inode_info*);
> +
> +// Iterate over inodes that are in directory specified by |nid|.
> +// |parent_nid| is optional, if specified, additional sanity checks will
> +// be performed.
> +// |cb| will be called for every inode, regardless of type of inode.
> +// |arg| will be passed to the callback in |erofs_readdir_cb| struct's
> +// |arg| field.
erofs-utils follows linux kernel coding style, so apart from SPDX,
it'd be better to use C-style comments only.
Also you could run scripts/checkpatch.pl in advance to avoid most
style problems..
I'd be many thanks if code could follow the correct coding style,
so I could have much less extra work to do.
> +int erofs_iterate_dir(const struct erofs_sb_info* sbi,
> + erofs_nid_t nid,
> + erofs_nid_t parent_nid,
> + erofs_readdir_cb cb,
> + void* arg);
1 tab equals to 8 spaces in the kernel coding style.
So the indentation is somewhat weird for me.
Thanks,
Gao Xiang
More information about the Linux-erofs
mailing list