Skip to content

Commit ff37797

Browse files
Chi Zhilingnamjaejeon
authored andcommitted
exfat: fix incorrect directory checksum after rename to shorter name
When renaming a file in-place to a shorter name, exfat_remove_entries marks excess entries as DELETED, but es->num_entries is not updated accordingly. As a result, exfat_update_dir_chksum iterates over the deleted entries and computes an incorrect checksum. This does not lead to persistent corruption because mark_inode_dirty() is called afterward, and __exfat_write_inode later recomputes the checksum using the correct num_entries value. Fix by setting es->num_entries = num_entries in exfat_init_ext_entry. Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn> Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com> Reviewed-by: Yuezhang Mo <Yuezhang.Mo@sony.com> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
1 parent 4129a3a commit ff37797

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

fs/exfat/dir.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ void exfat_init_ext_entry(struct exfat_entry_set_cache *es, int num_entries,
490490
unsigned short *uniname = p_uniname->name;
491491
struct exfat_dentry *ep;
492492

493+
es->num_entries = num_entries;
493494
ep = exfat_get_dentry_cached(es, ES_IDX_FILE);
494495
ep->dentry.file.num_ext = (unsigned char)(num_entries - 1);
495496

0 commit comments

Comments
 (0)