Re: [PATCH v4 3/4] fat: add renameat2 RENAME_EXCHANGE flag support

From: OGAWA Hirofumi
Date: Wed Jun 08 2022 - 10:34:02 EST


Javier Martinez Canillas <javierm@xxxxxxxxxx> writes:

> + /* update ".." directory entry info */
> + if (old_dotdot_de) {
> + err = vfat_update_dotdot_de(new_dir, old_inode, old_dotdot_bh,
> + old_dotdot_de);
> + if (err)
> + goto error_old_dotdot;
> + drop_nlink(old_dir);
> + inc_nlink(new_dir);
> + }
> +
> + if (new_dotdot_de) {
> + err = vfat_update_dotdot_de(old_dir, new_inode, new_dotdot_bh,
> + new_dotdot_de);
> + if (err)
> + goto error_new_dotdot;
> + drop_nlink(new_dir);
> + inc_nlink(old_dir);
> + }

Probably, we should change the nlink only if both of dotdot update are
succeed and different file type. Otherwise, we would have to revert the
nlink change on error path (and can remove unnecessary update as bonus).

Thanks.
--
OGAWA Hirofumi <hirofumi@xxxxxxxxxxxxxxxxxx>