On Sun, Mar 10, 2024 at 11:59:34PM +0900, OGAWA Hirofumi wrote: > Thadeu Lima de Souza Cascardo <cascardo@xxxxxxxxxx> writes: > > >> If we really want to accept this image, we have to change the fat driver > >> without affecting good image. And your patch affects to good image, > >> because that patch doesn't count directory correctly, so bad link count. > >> > > > > Well, it does behave the same on a correct image. It ignores the existence of > > ".." when counting subdirs, but always adds an extra link count. > > > > So, images that have both "." and ".." subdirs, will have the 2 links, both > > with the patch and without the patch. > > You are forgetting to count about normal dirs other than "." and ".."? > Yes, I was not counting those. The patch simply ignores ".." when counting dirs (which is used only for determining the number of links), and always adds one link. Then, when validating the inode, it also only requires that at least one link exists instead of two. There is only one other instance of fat_subdirs being called and that's when the root dir link count is determined. I left that one unchanged, as usually "." and ".." does not exist there and we always add two links there. Cascardo. > Thanks. > > > Images with neither dirs will be rejected before the patch and have a link > > count of 1 after the patch. Still, creating and removing subdirs will work. > > Removing the bad dir itself also works. > > > > Images with only "." or only ".." would have a link count of 1 and be rejected > > without the patch. > > > > With the patch, directories with only ".." should behave the same as if they > > had neither subdirs. That is, link count of 1. And directories with only "." > > will have a link count of 2. > -- > OGAWA Hirofumi <hirofumi@xxxxxxxxxxxxxxxxxx>