[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAOQ4uxiYdbr8X5uFxTdqw6ba7E+6KZY0mhQYw2_t875gw4vfiw@mail.gmail.com>
Date: Thu, 14 Aug 2025 15:20:33 +0200
From: Amir Goldstein <amir73il@...il.com>
To: André Almeida <andrealmeid@...lia.com>
Cc: Miklos Szeredi <miklos@...redi.hu>, Theodore Tso <tytso@....edu>,
Gabriel Krisman Bertazi <krisman@...nel.org>, linux-unionfs@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
Alexander Viro <viro@...iv.linux.org.uk>, Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>,
kernel-dev@...lia.com
Subject: Re: [PATCH v4 3/9] ovl: Create ovl_casefold() to support casefolded strncmp()
On Thu, Aug 14, 2025 at 3:02 PM André Almeida <andrealmeid@...lia.com> wrote:
>
> Hi Amir,
>
> Em 14/08/2025 09:53, Amir Goldstein escreveu:
> > On Thu, Aug 14, 2025 at 12:37 AM André Almeida <andrealmeid@...lia.com> wrote:
> >>
> >> To add overlayfs support casefold filesystems, create a new function
> >> ovl_casefold(), to be able to do case-insensitive strncmp().
> >>
> >> ovl_casefold() allocates a new buffer and stores the casefolded version
> >> of the string on it. If the allocation or the casefold operation fails,
> >> fallback to use the original string.
> >>
> >> The case-insentive name is then used in the rb-tree search/insertion
> >> operation. If the name is found in the rb-tree, the name can be
> >> discarded and the buffer is freed. If the name isn't found, it's then
> >> stored at struct ovl_cache_entry to be used later.
> >>
> >> Signed-off-by: André Almeida <andrealmeid@...lia.com>
> >> ---
>
> [...]
>
> >> + }
> >>
> >> INIT_LIST_HEAD(list);
> >> }
> >> @@ -260,12 +311,28 @@ static bool ovl_fill_merge(struct dir_context *ctx, const char *name,
> >> {
> >> struct ovl_readdir_data *rdd =
> >> container_of(ctx, struct ovl_readdir_data, ctx);
> >> + struct ovl_fs *ofs = OVL_FS(rdd->dentry->d_sb);
> >> + const char *aux = NULL;
> >
> > It looks strange to me that you need aux
> > and it looks strange to pair <aux, cf_len>
> > neither here or there...
> >
>
> The reason behind this `aux` var is because I need a `const char`
> pointer to point to the `name` argument, and `cf_name` can't be const
> because it goes through ovl_casefold(). I tried a couple approaches here
> to get rid of the compiler warning regarding const, and the only way I
> managed to was using a third variable like that.
>
I see. In that case, I'd just use these cleaner var names:
@@ -260,12 +311,28 @@ static bool ovl_fill_merge(struct dir_context
*ctx, const char *name,
{
struct ovl_readdir_data *rdd =
container_of(ctx, struct ovl_readdir_data, ctx);
+ struct ovl_fs *ofs = OVL_FS(rdd->dentry->d_sb);
+ char *cf_name = NULL;
+ const char *c_name;
+ int c_len = 0;
+
+ if (ofs->casefold)
+ c_len = ovl_casefold(rdd->map, name, namelen, &cf_name);
+
+ if (c_len <= 0) {
+ c_name = name;
+ c_len = namelen;
+ } else {
+ c_name = cf_name;
+ }
Thanks,
Amir.
Powered by blists - more mailing lists