Re: [PATCH 2/3] fat: add the msdos_format_name() filename cache

From: Al Viro
Date: Sun Aug 29 2021 - 17:23:38 EST


On Sun, Aug 29, 2021 at 05:11:56PM +0000, Caleb D.S. Brzezinski wrote:

> My understanding was that the maximum length of the name considered when
> passed to msdos_format_name() was eight characters; see:
>
> while (walk - res < 8)
>
> and
>
> for (walk = res; len && walk - res < 8; walk++) {

Err... You have noticed that the function does not end on that loop,
haven't you? Exercise: figure out what that function does. I.e.
what inputs are allowed and what outputs are produced. You might
find some description of FAT directory layout to be useful...

> > * your find_fname_in_cache() assumes that hash collisions
> > are impossible, which is... unlikely, considering the nature of
> > that hash function
>
> If the names are 8 character limited, then logically any name with the
> exact same set of characters would "collide" into the same formatted
> name.

Huh? Collision is when two *different* values of argument yield the
same result. What makes you assume that yours won't have any such
pairs shorter than 8 bytes?