Re: [PATCH] fat: fix parent link count when replacing a sibling directory

From: Andrew Morton

Date: Thu Oct 29 2026 - 15:15:40 EST


On Thu, 29 Oct 2026 14:57:43 +0900 OGAWA Hirofumi <hirofumi@xxxxxxxxxxxxxxxxxx> wrote:

> Hungyu Lin <dennylin0707@xxxxxxxxx> writes:
>
> > vfat_rename() and do_msdos_rename() adjust parent link counts only when
> > updating the dotdot entry for a move between different parents. Replacing
> > an existing empty directory in the same parent also removes a
> > subdirectory, but leaves the parent's link count unchanged.
> >
> > For example, renaming one of two sibling directories over the other
> > leaves the parent with four links instead of three. stat and ls report
> > the stale count, and find -links 3 does not match the parent.
> >
> > Drop the parent's link count for this case after the source entry has
> > been removed successfully. Leave cross-parent renames, regular files
> > and the existing error paths unchanged.
> >
> > Signed-off-by: Hungyu Lin <dennylin0707@xxxxxxxxx>
>
> Looks good. Thanks.
>
> Acked-by: OGAWA Hirofumi <hirofumi@xxxxxxxxxxxxxxxxxx>

Thanks. Sashiko asked a thing:
https://sashiko.dev/#/patchset/20261028211626.26103-1-dennylin0707@xxxxxxxxx