diff options
author | Gao Xiang <hsiangkao@linux.alibaba.com> | 2023-08-03 13:00:31 +0800 |
---|---|---|
committer | Gao Xiang <hsiangkao@linux.alibaba.com> | 2023-08-03 19:10:45 +0800 |
commit | 45b43e5d3c912210e82fe41ab37cd7bee7adfd39 (patch) | |
tree | 071bca84f64d8c4af0bc72c0a4a592701e796cc0 | |
parent | b6749839e710078187f2347dc29b7317cbb59d19 (diff) | |
download | erofs-utils-45b43e5d3c912210e82fe41ab37cd7bee7adfd39.tar.gz |
erofs-utils: dump: use a new subdir context for erofs_get_pathname()
It's absolutely unsafe to reuse struct erofs_dir_context. Also,
we'd like to refactor erofs_get_pathname() in the future.
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230803050031.130026-1-hsiangkao@linux.alibaba.com
-rw-r--r-- | lib/dir.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -217,10 +217,16 @@ static int erofs_get_pathname_iter(struct erofs_dir_context *ctx) } if (S_ISDIR(dir.i_mode)) { - ctx->dir = &dir; - pathctx->pos = pos + len + 1; - ret = erofs_iterate_dir(ctx, false); - pathctx->pos = pos; + struct erofs_get_pathname_context nctx = { + .ctx.flags = 0, + .ctx.dir = &dir, + .ctx.cb = erofs_get_pathname_iter, + .target_nid = pathctx->target_nid, + .buf = pathctx->buf, + .size = pathctx->size, + .pos = pos + len + 1, + }; + ret = erofs_iterate_dir(&nctx.ctx, false); if (ret == EROFS_PATHNAME_FOUND) { pathctx->buf[pos++] = '/'; strncpy(pathctx->buf + pos, dname, len); |