Re: [PATCH v3 2/2] hfsplus: extract hidden directory search into a helper function
From: Zilin Guan
Date: Sat Mar 21 2026 - 03:34:19 EST
On Fri, Mar 20, 2026 at 06:40:02PM +0000, Viacheslav Dubeyko wrote:
> On Fri, 2026-03-20 at 21:04 +0800, Zilin Guan wrote:
> > static int hfsplus_fill_super(struct super_block *sb, struct fs_context *fc)
> > {
> > struct hfsplus_vh *vhdr;
> > struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
> > hfsplus_cat_entry entry;
> > - struct hfs_find_data fd;
> > struct inode *root, *inode;
> > struct qstr str;
> > struct nls_table *nls;
> > @@ -565,16 +588,11 @@ static int hfsplus_fill_super(struct super_block *sb, struct fs_context *fc)
> >
> > str.len = sizeof(HFSP_HIDDENDIR_NAME) - 1;
> > str.name = HFSP_HIDDENDIR_NAME;
> > - err = hfs_find_init(sbi->cat_tree, &fd);
> > - if (err)
> > - goto out_put_root;
> > - err = hfsplus_cat_build_key(sb, fd.search_key, HFSPLUS_ROOT_CNID, &str);
> > - if (unlikely(err < 0)) {
> > - hfs_find_exit(&fd);
> > - goto out_put_root;
> > - }
> > - if (!hfs_brec_read(&fd, &entry, sizeof(entry))) {
> > - hfs_find_exit(&fd);
> > + err = hfsplus_get_hidden_dir_entry(sb, &str, &entry);
> > + if (err) {
> > + if (err != -ENOENT)
> > + goto out_put_root;
>
> I am slightly not happy about this pattern. :) Could we rework it in better
> shape?
>
> I am thinking about something like this:
>
> if (err == -ENOENT) {
> /*
> * Hidden directory is absent or it cannot be read.
> */
> } else if (unlikely(err)) {
> goto out_put_root;
> } else {
> <execute logic>
> }
>
> What do you think? Do you agree?
>
> Thanks,
> Slava.
Makes sense. This pattern is more readable. I will update it in v4.
Thanks,
Zilin