msdos: Fix file truncated to 0

Previously the first cluster of the file was not updated when
truncating to 0 but was in any case freed.
Now the first cluster of the file is updated during the truncation,
leaving the directory entry in a consistent state.

Closes #2757
This commit is contained in:
Loris Nardo
2024-08-02 06:56:48 +02:00
committed by Gedare Bloom
parent 73918bc788
commit 606584d032

View File

@@ -862,6 +862,13 @@ fat_file_truncate(
fat_fd->map.disk_cln = new_last_cln;
fat_fd->map.last_cln = new_last_cln;
}
else
{
fat_file_set_first_cluster_num(fat_fd, FAT_GENFAT_FREE);
fat_fd->map.file_cln = FAT_UNDEFINED_VALUE;
fat_fd->map.disk_cln = FAT_UNDEFINED_VALUE;
fat_fd->map.last_cln = FAT_UNDEFINED_VALUE;
}
return RC_OK;
}