On Thu, Aug 14, 2025 at 3:02 PM André Almeida <andrealmeid@xxxxxxxxxx> wrote: > > Hi Amir, > > Em 14/08/2025 09:53, Amir Goldstein escreveu: > > On Thu, Aug 14, 2025 at 12:37 AM André Almeida <andrealmeid@xxxxxxxxxx> 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@xxxxxxxxxx> > >> --- > > [...] > > >> + } > >> > >> 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.