3 * Copyright (C) 2002 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
23 * FILE: services/fs/ntfs/mft.c
24 * PURPOSE: NTFS filesystem driver
25 * PROGRAMMER: Eric Kohl
28 /* INCLUDES *****************************************************************/
30 #include <ddk/ntddk.h>
38 /* FUNCTIONS ****************************************************************/
42 NtfsOpenMft(PDEVICE_OBJECT DeviceObject,
43 PDEVICE_EXTENSION Vcb)
46 PFILE_RECORD_HEADER RecordHeader;
50 DPRINT1("NtfsOpenMft() called\n");
52 Buffer = ExAllocatePool(NonPagedPool,
53 Vcb->NtfsInfo.BytesPerCluster);
56 return(STATUS_INSUFFICIENT_RESOURCES);
60 /* read first MFT cluster */
61 Status = NtfsReadRawSectors(DeviceObject,
62 Vcb->NtfsInfo.MftStart.u.LowPart * Vcb->NtfsInfo.SectorsPerCluster,
63 Vcb->NtfsInfo.SectorsPerCluster,
64 Vcb->NtfsInfo.BytesPerSector,
66 if (NT_SUCCESS(Status))
68 /* Enumerate MFT records */
69 RecordHeader = Buffer;
70 while (((ULONG)RecordHeader - (ULONG)Buffer) < Vcb->NtfsInfo.BytesPerCluster)
73 // DbgPrint("Magic: %.04s\n", (PCHAR)&RecordHeader->Ntfs.Type);
74 // DbgPrint("Real size: %lx\n", RecordHeader->RealSize);
75 // DbgPrint("AllocSize: %lx\n", RecordHeader->AllocSize);
77 /* Enumerate attributes */
78 Attribute = (PATTRIBUTE)((ULONG)RecordHeader +
79 RecordHeader->Ntfs.UsnOffset +
80 RecordHeader->Ntfs.UsnSize * sizeof(USHORT));
81 while (Attribute->AttributeType != 0xFFFFFFFF)
83 NtfsDumpAttribute(Attribute);
85 Attribute = (PATTRIBUTE)((ULONG)Attribute + Attribute->Length);
89 RecordHeader = (PFILE_RECORD_HEADER)((ULONG)RecordHeader + RecordHeader->BytesAllocated);