From: Gao Xiang <xiang@kernel.org>
To: Sheng Yong <shengyong@oppo.com>
Cc: linux-erofs@lists.ozlabs.org
Subject: Re: [RFC PATCH 1/3] erofs-utils: fuse: set d_type for readdir
Date: Thu, 4 Aug 2022 03:43:04 +0800 [thread overview]
Message-ID: <YurPyAkkaHDD4Lih@debian> (raw)
In-Reply-To: <20220803142223.3962974-2-shengyong@oppo.com>
On Wed, Aug 03, 2022 at 10:22:21PM +0800, Sheng Yong wrote:
> Set inode mode for libfuse readdir filler so that readdir count get
> correct d_type.
>
> Signed-off-by: Sheng Yong <shengyong@oppo.com>
Reviewed-by: Gao Xiang <xiang@kernel.org>
Thanks,
Gao Xiang
> ---
> fuse/main.c | 5 ++++-
> include/erofs/inode.h | 1 +
> lib/inode.c | 19 +++++++++++++++++++
> 3 files changed, 24 insertions(+), 1 deletion(-)
>
> diff --git a/fuse/main.c b/fuse/main.c
> index 95f939e..345bcb5 100644
> --- a/fuse/main.c
> +++ b/fuse/main.c
> @@ -13,6 +13,7 @@
> #include "erofs/print.h"
> #include "erofs/io.h"
> #include "erofs/dir.h"
> +#include "erofs/inode.h"
>
> struct erofsfuse_dir_context {
> struct erofs_dir_context ctx;
> @@ -24,11 +25,13 @@ struct erofsfuse_dir_context {
> static int erofsfuse_fill_dentries(struct erofs_dir_context *ctx)
> {
> struct erofsfuse_dir_context *fusectx = (void *)ctx;
> + struct stat st = {0};
> char dname[EROFS_NAME_LEN + 1];
>
> strncpy(dname, ctx->dname, ctx->de_namelen);
> dname[ctx->de_namelen] = '\0';
> - fusectx->filler(fusectx->buf, dname, NULL, 0);
> + st.st_mode = erofs_ftype_to_dtype(ctx->de_ftype) << 12;
> + fusectx->filler(fusectx->buf, dname, &st, 0);
> return 0;
> }
>
> diff --git a/include/erofs/inode.h b/include/erofs/inode.h
> index 79b39b0..79b8d89 100644
> --- a/include/erofs/inode.h
> +++ b/include/erofs/inode.h
> @@ -16,6 +16,7 @@ extern "C"
> #include "erofs/internal.h"
>
> unsigned char erofs_mode_to_ftype(umode_t mode);
> +unsigned char erofs_ftype_to_dtype(unsigned int filetype);
> void erofs_inode_manager_init(void);
> unsigned int erofs_iput(struct erofs_inode *inode);
> erofs_nid_t erofs_lookupnid(struct erofs_inode *inode);
> diff --git a/lib/inode.c b/lib/inode.c
> index f192510..ce75014 100644
> --- a/lib/inode.c
> +++ b/lib/inode.c
> @@ -43,6 +43,25 @@ unsigned char erofs_mode_to_ftype(umode_t mode)
> return erofs_ftype_by_mode[(mode & S_IFMT) >> S_SHIFT];
> }
>
> +static const unsigned char erofs_dtype_by_ftype[EROFS_FT_MAX] = {
> + [EROFS_FT_UNKNOWN] = DT_UNKNOWN,
> + [EROFS_FT_REG_FILE] = DT_REG,
> + [EROFS_FT_DIR] = DT_DIR,
> + [EROFS_FT_CHRDEV] = DT_CHR,
> + [EROFS_FT_BLKDEV] = DT_BLK,
> + [EROFS_FT_FIFO] = DT_FIFO,
> + [EROFS_FT_SOCK] = DT_SOCK,
> + [EROFS_FT_SYMLINK] = DT_LNK
> +};
> +
> +unsigned char erofs_ftype_to_dtype(unsigned int filetype)
> +{
> + if (filetype >= EROFS_FT_MAX)
> + return DT_UNKNOWN;
> +
> + return erofs_dtype_by_ftype[filetype];
> +}
> +
> #define NR_INODE_HASHTABLE 16384
>
> struct list_head inode_hashtable[NR_INODE_HASHTABLE];
> --
> 2.25.1
>
> ________________________________
> OPPO
>
> 本电子邮件及其附件含有OPPO公司的保密信息,仅限于邮件指明的收件人使用(包含个人及群组)。禁止任何人在未经授权的情况下以任何形式使用。如果您错收了本邮件,请立即以电子邮件通知发件人并删除本邮件及其附件。
>
> This e-mail and its attachments contain confidential information from OPPO, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!
next prev parent reply other threads:[~2022-08-03 19:43 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-03 14:22 [RFC PATCH 0/3] erofs-utils: fuse: support get/list xattr Sheng Yong via Linux-erofs
2022-08-03 14:22 ` [RFC PATCH 1/3] erofs-utils: fuse: set d_type for readdir Sheng Yong via Linux-erofs
2022-08-03 19:43 ` Gao Xiang [this message]
2022-08-04 15:02 ` Gao Xiang
2022-08-04 15:14 ` Sheng Yong via Linux-erofs
2022-08-07 8:08 ` [PATCH v2] " Sheng Yong
2022-08-07 10:26 ` Chao Yu
2022-08-08 1:59 ` Gao Xiang
2022-08-03 14:22 ` [RFC PATCH 2/3] erofs-utils: fuse: export erofs_xattr_foreach Sheng Yong via Linux-erofs
2022-08-03 19:46 ` Gao Xiang
2022-08-09 3:58 ` Gao Xiang
2022-08-09 4:18 ` Sheng Yong via Linux-erofs
2022-08-09 4:27 ` Gao Xiang
2022-08-03 14:22 ` [RFC PATCH 3/3] erofs-utils: fuse: support get/list xattr Sheng Yong via Linux-erofs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YurPyAkkaHDD4Lih@debian \
--to=xiang@kernel.org \
--cc=linux-erofs@lists.ozlabs.org \
--cc=shengyong@oppo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.