oops, can't edit.. I didn't think either way, even if it had been resized... that running it would do anything, which is why as well, I just went ahead. I can find the $MFT, and know other tools can fix $MFT possibly? (GetDataBack?)... and have a tool lying around from some other time to get files back but the annoyance is they are all in random names/locations and all that mess.
by the way.. from
git://linux-ntfs.git.sourceforge.net/gi ... ntfsmasterntfsfix.c <- seems in git there is some code which attempts handling these things... I can't find those options in my ntfsprogs (even if I am a bleeding edge user on arch)... Would there be some relevant code for me in the git repo? ..
/**
* fix_mftmirr
*/
static int fix_mftmirr(ntfs_volume *vol)
{
s64 l, br;
unsigned char *m, *m2;
int i, ret = -1; /* failure */
BOOL done;
ntfs_log_info("\nProcessing $MFT and $MFTMirr...\n");
/* Load data from $MFT and $MFTMirr and compare the contents. */
m = (u8*)malloc(vol->mftmirr_size << vol->mft_record_size_bits);
if (!m) {
ntfs_log_perror("Failed to allocate memory");
return -1;
}
m2 = (u8*)malloc(vol->mftmirr_size << vol->mft_record_size_bits);
if (!m2) {
ntfs_log_perror("Failed to allocate memory");
free(m);
return -1;
}
ntfs_log_info("Reading $MFT... ");
l = ntfs_attr_mst_pread(vol->mft_na, 0, vol->mftmirr_size,
vol->mft_record_size, m);
if (l != vol->mftmirr_size) {
ntfs_log_info(FAILED);
if (l != -1)
errno = EIO;
ntfs_log_perror("Failed to read $MFT");
goto error_exit;
}
ntfs_log_info(OK);
ntfs_log_info("Reading $MFTMirr... ");
l = ntfs_attr_mst_pread(vol->mftmirr_na, 0, vol->mftmirr_size,
vol->mft_record_size, m2);
if (l != vol->mftmirr_size) {
ntfs_log_info(FAILED);
if (l != -1)
errno = EIO;
ntfs_log_perror("Failed to read $MFTMirr");
goto error_exit;
}
ntfs_log_info(OK);
/*
* FIXME: Need to actually check the $MFTMirr for being real. Otherwise
* we might corrupt the partition if someone is experimenting with
* software RAID and the $MFTMirr is not actually in the position we
* expect it to be... )-:
* FIXME: We should emit a warning it $MFTMirr is damaged and ask
* user whether to recreate it from $MFT or whether to abort. - The
* warning needs to include the danger of software RAID arrays.
* Maybe we should go as far as to detect whether we are running on a
* MD disk and if yes then bomb out right at the start of the program?
*/
ntfs_log_info("Comparing $MFTMirr to $MFT... ");
done = FALSE;
for (i = 0; i < vol->mftmirr_size; ++i) {
MFT_RECORD *mrec, *mrec2;
const char *ESTR[12] = { "$MFT", "$MFTMirr", "$LogFile",
"$Volume", "$AttrDef", "root directory", "$Bitmap",
"$Boot", "$BadClus", "$Secure", "$UpCase", "$Extend" };
const char *s;
BOOL use_mirr;
if (i < 12)
s = ESTR[i];
else if (i < 16)
s = "system file";
else
s = "mft record";
use_mirr = FALSE;
mrec = (MFT_RECORD*)(m + i * vol->mft_record_size);
if (mrec->flags & MFT_RECORD_IN_USE) {
if (ntfs_is_baad_record(mrec->magic)) {
ntfs_log_info(FAILED);
ntfs_log_error("$MFT error: Incomplete multi "
"sector transfer detected in "
"%s.\nCannot handle this yet. "
")-:\n", s);
goto error_exit;
}
if (!ntfs_is_mft_record(mrec->magic)) {
ntfs_log_info(FAILED);
ntfs_log_error("$MFT error: Invalid mft "
"record for %s.\nCannot "
"handle this yet. )-:\n", s);
goto error_exit;
}
}
mrec2 = (MFT_RECORD*)(m2 + i * vol->mft_record_size);
if (mrec2->flags & MFT_RECORD_IN_USE) {
if (ntfs_is_baad_record(mrec2->magic)) {
ntfs_log_info(FAILED);
ntfs_log_error("$MFTMirr error: Incomplete "
"multi sector transfer "
"detected in %s.\n", s);
goto error_exit;
}
if (!ntfs_is_mft_record(mrec2->magic)) {
ntfs_log_info(FAILED);
ntfs_log_error("$MFTMirr error: Invalid mft "
"record for %s.\n", s);
goto error_exit;
}
/* $MFT is corrupt but $MFTMirr is ok, use $MFTMirr. */
if (!(mrec->flags & MFT_RECORD_IN_USE) &&
!ntfs_is_mft_record(mrec->magic))
use_mirr = TRUE;
}
if (memcmp(mrec, mrec2, ntfs_mft_record_get_data_size(mrec))) {
if (!done) {
done = TRUE;
ntfs_log_info(FAILED);
}
ntfs_log_info("Correcting differences in $MFT%s "
"record %d...", use_mirr ? "" : "Mirr",
i);
br = ntfs_mft_record_write(vol, i,
use_mirr ? mrec2 : mrec);
if (br) {
ntfs_log_info(FAILED);
ntfs_log_perror("Error correcting $MFT%s",
use_mirr ? "" : "Mirr");
goto error_exit;
}
ntfs_log_info(OK);
}
}
if (!done)
ntfs_log_info(OK);
ntfs_log_info("Processing of $MFT and $MFTMirr completed "
"successfully.\n");
ret = 0;
error_exit:
free(m);
free(m2);
return ret;
}