Aborted mounting when cannot access standard information of MFT

The standard information of the MFT must be its first attribute in the
base record. If it is not accessible initially, we end up searching it
in an extent before the MFT struct is ready for that.
edge.strict_endians^2
Jean-Pierre André 2021-07-12 08:31:18 +02:00
parent 68ead9b8fc
commit 32e858a87a
1 changed files with 9 additions and 2 deletions

View File

@ -221,10 +221,11 @@ static int __ntfs_volume_release(ntfs_volume *v)
return errno ? -1 : 0;
}
static void ntfs_attr_setup_flag(ntfs_inode *ni)
static int ntfs_attr_setup_flag(ntfs_inode *ni)
{
STANDARD_INFORMATION *si;
s64 lth;
int r;
si = (STANDARD_INFORMATION*)ntfs_attr_readall(ni,
AT_STANDARD_INFORMATION, AT_UNNAMED, 0, &lth);
@ -232,7 +233,12 @@ static void ntfs_attr_setup_flag(ntfs_inode *ni)
if ((u64)lth >= offsetof(STANDARD_INFORMATION, owner_id))
ni->flags = si->file_attributes;
free(si);
r = 0;
} else {
ntfs_log_error("Failed to get standard information of $MFT\n");
r = -1;
}
return (r);
}
/**
@ -317,7 +323,8 @@ static int ntfs_mft_load(ntfs_volume *vol)
mft_has_no_attr_list:
ntfs_attr_setup_flag(vol->mft_ni);
if (ntfs_attr_setup_flag(vol->mft_ni))
goto error_exit;
/* We now have a fully setup ntfs inode for $MFT in vol->mft_ni. */