Double-checked whether record 15 is an extent of MFT

When extents are needed to store the runlist of the MFT, the first one
must be located in record 15 so that its location can be determined from
the part in the base extent. As this record is always marked in use,
determining whether it is not really in use requires a specific logic.
This commit is contained in:
Jean-Pierre André 2018-02-13 09:06:49 +01:00
parent f334c1fdc3
commit 1f8b751341

View File

@ -5,7 +5,7 @@
* Copyright (c) 2004-2005 Richard Russon * Copyright (c) 2004-2005 Richard Russon
* Copyright (c) 2004-2008 Szabolcs Szakacsits * Copyright (c) 2004-2008 Szabolcs Szakacsits
* Copyright (c) 2005 Yura Pakhuchiy * Copyright (c) 2005 Yura Pakhuchiy
* Copyright (c) 2014-2015 Jean-Pierre Andre * Copyright (c) 2014-2018 Jean-Pierre Andre
* *
* This program/include file is free software; you can redistribute it and/or * This program/include file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published * modify it under the terms of the GNU General Public License as published
@ -1389,16 +1389,27 @@ ntfs_inode *ntfs_mft_rec_alloc(ntfs_volume *vol, BOOL mft_data)
*/ */
if (ext_ni) { if (ext_ni) {
/* /*
* Make sure record 15 is a base extent and has * Make sure record 15 is a base extent and it has
* no extents. * no name. A base inode with no name cannot be in use.
* Also make sure it has no name : a base inode with * The test based on base_mft_record fails for
* no extents and no name cannot be in use. * extents of MFT, so we need a special check.
* Otherwise apply standard procedure. * If already used, apply standard procedure.
*/ */
if (!ext_ni->mrec->base_mft_record if (!ext_ni->mrec->base_mft_record
&& !ext_ni->nr_extents) && !ext_ni->mrec->link_count)
forced_mft_data = TRUE; forced_mft_data = TRUE;
ntfs_inode_close(ext_ni); ntfs_inode_close(ext_ni);
/* Double-check, in case it is used for MFT */
if (forced_mft_data && base_ni->nr_extents) {
int i;
for (i=0; i<base_ni->nr_extents; i++) {
if (base_ni->extent_nis[i]
&& (base_ni->extent_nis[i]->mft_no
== FILE_mft_data))
forced_mft_data = FALSE;
}
}
} }
} }
if (forced_mft_data) if (forced_mft_data)