Kept the name of a deleted file in place for easier undeletion

When a file is deleted, there is no need to remove its last name in
the deleted MFT record. The name may be useful for undeleting the file
later (Windows also does not delete the name).
edge.strict_endians
Jean-Pierre André 2012-03-21 19:14:03 +01:00
parent 37ae85a9d5
commit 4e29280cb2
1 changed files with 12 additions and 2 deletions

View File

@ -1878,8 +1878,18 @@ search:
if (ntfs_index_remove(dir_ni, ni, fn, le32_to_cpu(actx->attr->value_length)))
goto err_out;
if (ntfs_attr_record_rm(actx))
goto err_out;
/*
* Keep the last name in place, this is useful for undeletion
* (Windows also does so), however delete the name if it were
* in an extent, to avoid leaving an attribute list.
*/
if ((ni->mrec->link_count == cpu_to_le16(1)) && !actx->base_ntfs_ino) {
/* make sure to not loop to another search */
looking_for_dos_name = FALSE;
} else {
if (ntfs_attr_record_rm(actx))
goto err_out;
}
ni->mrec->link_count = cpu_to_le16(le16_to_cpu(
ni->mrec->link_count) - 1);